mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1694662 - Remove nsICachingChannel r=necko-reviewers,dragana
Differential Revision: https://phabricator.services.mozilla.com/D106432
This commit is contained in:
parent
87d676a1e4
commit
6e7f34c437
@ -36,15 +36,6 @@ interface nsICachingChannel : nsICacheInfoChannel
|
||||
*/
|
||||
attribute nsISupports cacheToken;
|
||||
|
||||
/**
|
||||
* The same as above but accessing the offline app cache token if there
|
||||
* is any.
|
||||
*
|
||||
* @throws
|
||||
* NS_ERROR_NOT_AVAILABLE when there is not offline cache token
|
||||
*/
|
||||
attribute nsISupports offlineCacheToken;
|
||||
|
||||
/**
|
||||
* Instructs the channel to only store the metadata of the entry, and not
|
||||
* the content. When reading an existing entry, this automatically sets
|
||||
|
@ -304,7 +304,6 @@ nsHttpChannel::nsHttpChannel()
|
||||
mLogicalOffset(0),
|
||||
mPostID(0),
|
||||
mRequestTime(0),
|
||||
mOfflineCacheLastModifiedTime(0),
|
||||
mSuspendTotalTime(0),
|
||||
mRedirectType(0),
|
||||
mCacheOpenWithPriority(false),
|
||||
@ -3226,11 +3225,6 @@ nsresult nsHttpChannel::ProcessPartialContent(
|
||||
|
||||
rv = InstallCacheListener(mLogicalOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (mOfflineCacheEntry) {
|
||||
rv = InstallOfflineCacheListener(mLogicalOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
} else {
|
||||
// suspend the current transaction
|
||||
rv = mTransactionPump->Suspend();
|
||||
@ -4302,47 +4296,9 @@ nsresult nsHttpChannel::UpdateExpirationTime() {
|
||||
expirationTime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mOfflineCacheEntry) {
|
||||
rv = mOfflineCacheEntry->SetExpirationTime(expirationTime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsHttpChannel::ShouldUpdateOfflineCacheEntry() {
|
||||
if (!mApplicationCacheForWrite || !mOfflineCacheEntry) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if we're updating the cache entry, update the offline cache entry too
|
||||
if (mCacheEntry && LoadCacheEntryIsWriteOnly()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if there's nothing in the offline cache, add it
|
||||
if (mOfflineCacheEntry) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if the document is newer than the offline entry, update it
|
||||
uint32_t docLastModifiedTime;
|
||||
nsresult rv = mResponseHead->GetLastModifiedValue(&docLastModifiedTime);
|
||||
if (NS_FAILED(rv)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mOfflineCacheLastModifiedTime == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (docLastModifiedTime > mOfflineCacheLastModifiedTime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
nsresult nsHttpChannel::OpenCacheInputStream(nsICacheEntry* cacheEntry,
|
||||
bool startBuffering,
|
||||
bool checkingAppCacheEntry) {
|
||||
@ -4627,25 +4583,13 @@ nsresult nsHttpChannel::ReadFromCache(bool alreadyMarkedValid) {
|
||||
}
|
||||
|
||||
if ((mLoadFlags & LOAD_ONLY_IF_MODIFIED) && !LoadCachedContentIsPartial()) {
|
||||
if (!mApplicationCacheForWrite) {
|
||||
LOG(
|
||||
("Skipping read from cache based on LOAD_ONLY_IF_MODIFIED "
|
||||
"load flag\n"));
|
||||
MOZ_ASSERT(!mCacheInputStream);
|
||||
// TODO: Bug 759040 - We should call HandleAsyncNotModified directly
|
||||
// here, to avoid event dispatching latency.
|
||||
return AsyncCall(&nsHttpChannel::HandleAsyncNotModified);
|
||||
}
|
||||
|
||||
if (!ShouldUpdateOfflineCacheEntry()) {
|
||||
LOG(
|
||||
("Skipping read from cache based on LOAD_ONLY_IF_MODIFIED "
|
||||
"load flag (mApplicationCacheForWrite not null case)\n"));
|
||||
mCacheInputStream.CloseAndRelease();
|
||||
// TODO: Bug 759040 - We should call HandleAsyncNotModified directly
|
||||
// here, to avoid event dispatching latency.
|
||||
return AsyncCall(&nsHttpChannel::HandleAsyncNotModified);
|
||||
}
|
||||
LOG(
|
||||
("Skipping read from cache based on LOAD_ONLY_IF_MODIFIED "
|
||||
"load flag\n"));
|
||||
MOZ_ASSERT(!mCacheInputStream);
|
||||
// TODO: Bug 759040 - We should call HandleAsyncNotModified directly
|
||||
// here, to avoid event dispatching latency.
|
||||
return AsyncCall(&nsHttpChannel::HandleAsyncNotModified);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mCacheInputStream);
|
||||
@ -5097,31 +5041,6 @@ nsresult nsHttpChannel::InstallCacheListener(int64_t offset) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsHttpChannel::InstallOfflineCacheListener(int64_t offset) {
|
||||
nsresult rv;
|
||||
|
||||
LOG(("Preparing to write data into the offline cache [uri=%s]\n",
|
||||
mSpec.get()));
|
||||
|
||||
MOZ_ASSERT(mOfflineCacheEntry);
|
||||
MOZ_ASSERT(mListener);
|
||||
|
||||
nsCOMPtr<nsIOutputStream> out;
|
||||
rv = mOfflineCacheEntry->OpenOutputStream(offset, -1, getter_AddRefs(out));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIStreamListenerTee> tee =
|
||||
do_CreateInstance(kStreamListenerTeeCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = tee->Init(mListener, out, nullptr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mListener = tee;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsHttpChannel::ClearBogusContentEncodingIfNeeded() {
|
||||
// For .gz files, apache sends both a Content-Type: application/x-gzip
|
||||
// as well as Content-Encoding: gzip, which is completely wrong. In
|
||||
@ -8161,18 +8080,6 @@ nsHttpChannel::SetCacheToken(nsISupports* token) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetOfflineCacheToken(nsISupports** token) {
|
||||
NS_ENSURE_ARG_POINTER(token);
|
||||
if (!mOfflineCacheEntry) return NS_ERROR_NOT_AVAILABLE;
|
||||
return CallQueryInterface(mOfflineCacheEntry, token);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::SetOfflineCacheToken(nsISupports* token) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetCacheKey(uint32_t* key) {
|
||||
NS_ENSURE_ARG_POINTER(key);
|
||||
|
@ -381,7 +381,6 @@ class nsHttpChannel final : public HttpBaseChannel,
|
||||
[[nodiscard]] nsresult OnNormalCacheEntryAvailable(nsICacheEntry* aEntry,
|
||||
bool aNew,
|
||||
nsresult aResult);
|
||||
[[nodiscard]] nsresult OpenOfflineCacheEntryForWriting();
|
||||
[[nodiscard]] nsresult OnCacheEntryAvailableInternal(
|
||||
nsICacheEntry* entry, bool aNew, nsIApplicationCache* aAppCache,
|
||||
nsresult status);
|
||||
@ -389,7 +388,6 @@ class nsHttpChannel final : public HttpBaseChannel,
|
||||
[[nodiscard]] nsresult UpdateExpirationTime();
|
||||
[[nodiscard]] nsresult CheckPartial(nsICacheEntry* aEntry, int64_t* aSize,
|
||||
int64_t* aContentLength);
|
||||
bool ShouldUpdateOfflineCacheEntry();
|
||||
[[nodiscard]] nsresult ReadFromCache(bool alreadyMarkedValid);
|
||||
void CloseCacheEntry(bool doomOnFailure);
|
||||
[[nodiscard]] nsresult InitCacheEntry();
|
||||
@ -397,7 +395,6 @@ class nsHttpChannel final : public HttpBaseChannel,
|
||||
[[nodiscard]] nsresult AddCacheEntryHeaders(nsICacheEntry* entry);
|
||||
[[nodiscard]] nsresult FinalizeCacheEntry();
|
||||
[[nodiscard]] nsresult InstallCacheListener(int64_t offset = 0);
|
||||
[[nodiscard]] nsresult InstallOfflineCacheListener(int64_t offset = 0);
|
||||
void MaybeInvalidateCacheEntryForSubsequentGet();
|
||||
void AsyncOnExamineCachedResponse();
|
||||
|
||||
@ -590,9 +587,6 @@ class nsHttpChannel final : public HttpBaseChannel,
|
||||
uint32_t mPostID;
|
||||
uint32_t mRequestTime;
|
||||
|
||||
nsCOMPtr<nsICacheEntry> mOfflineCacheEntry;
|
||||
uint32_t mOfflineCacheLastModifiedTime;
|
||||
|
||||
nsTArray<StreamFilterRequest> mStreamFilterRequests;
|
||||
|
||||
mozilla::TimeStamp mOnStartRequestTimestamp;
|
||||
|
@ -1000,22 +1000,6 @@ nsresult nsOfflineManifestItem::CheckNewManifestContentHash(
|
||||
mNeedsUpdate = false;
|
||||
}
|
||||
|
||||
// Store the manifest content hash value to the new
|
||||
// offline cache token
|
||||
nsCOMPtr<nsICachingChannel> cachingChannel = do_QueryInterface(aRequest, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsISupports> cacheToken;
|
||||
cachingChannel->GetOfflineCacheToken(getter_AddRefs(cacheToken));
|
||||
if (cacheToken) {
|
||||
nsCOMPtr<nsICacheEntry> cacheDescriptor(do_QueryInterface(cacheToken, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = cacheDescriptor->SetMetaDataElement("offline-manifest-hash",
|
||||
mManifestHashValue.get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user