Bug 1397128 P9 Make content script usage of Cache API use lazy body loading. r=tt

This commit is contained in:
Ben Kelly 2017-09-15 12:25:41 -07:00
Родитель 9e8538fa6a
Коммит f3bd79bbe8
4 изменённых файлов: 22 добавлений и 4 удалений

12
dom/cache/Cache.cpp поставляемый
Просмотреть файл

@ -288,7 +288,7 @@ Cache::Match(JSContext* aCx, const RequestOrUSVString& aRequest,
ToCacheQueryParams(params, aOptions);
AutoChildOpArgs args(this,
CacheMatchArgs(CacheRequest(), params, OpenMode::Eager),
CacheMatchArgs(CacheRequest(), params, GetOpenMode()),
1);
args.Add(ir, IgnoreBody, IgnoreInvalidScheme, aRv);
@ -314,7 +314,7 @@ Cache::MatchAll(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
ToCacheQueryParams(params, aOptions);
AutoChildOpArgs args(this,
CacheMatchAllArgs(void_t(), params, OpenMode::Eager),
CacheMatchAllArgs(void_t(), params, GetOpenMode()),
1);
if (aRequest.WasPassed()) {
@ -498,7 +498,7 @@ Cache::Keys(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
ToCacheQueryParams(params, aOptions);
AutoChildOpArgs args(this,
CacheKeysArgs(void_t(), params, OpenMode::Eager),
CacheKeysArgs(void_t(), params, GetOpenMode()),
1);
if (aRequest.WasPassed()) {
@ -691,6 +691,12 @@ Cache::PutAll(JSContext* aCx, const nsTArray<RefPtr<Request>>& aRequestList,
return ExecuteOp(args, aRv);
}
OpenMode
Cache::GetOpenMode() const
{
return mNamespace == CHROME_ONLY_NAMESPACE ? OpenMode::Eager : OpenMode::Lazy;
}
} // namespace cache
} // namespace dom
} // namespace mozilla

3
dom/cache/Cache.h поставляемый
Просмотреть файл

@ -107,6 +107,9 @@ private:
const nsTArray<RefPtr<Response>>& aResponseList,
ErrorResult& aRv);
OpenMode
GetOpenMode() const;
nsCOMPtr<nsIGlobalObject> mGlobal;
CacheChild* mActor;
const Namespace mNamespace;

8
dom/cache/CacheStorage.cpp поставляемый
Просмотреть файл

@ -333,7 +333,7 @@ CacheStorage::Match(JSContext* aCx, const RequestOrUSVString& aRequest,
nsAutoPtr<Entry> entry(new Entry());
entry->mPromise = promise;
entry->mArgs = StorageMatchArgs(CacheRequest(), params, OpenMode::Eager);
entry->mArgs = StorageMatchArgs(CacheRequest(), params, GetOpenMode());
entry->mRequest = request;
mPendingRequests.AppendElement(entry.forget());
@ -617,6 +617,12 @@ CacheStorage::MaybeRunPendingRequests()
mPendingRequests.Clear();
}
OpenMode
CacheStorage::GetOpenMode() const
{
return mNamespace == CHROME_ONLY_NAMESPACE ? OpenMode::Eager : OpenMode::Lazy;
}
} // namespace cache
} // namespace dom
} // namespace mozilla

3
dom/cache/CacheStorage.h поставляемый
Просмотреть файл

@ -104,6 +104,9 @@ private:
void MaybeRunPendingRequests();
OpenMode
GetOpenMode() const;
const Namespace mNamespace;
nsCOMPtr<nsIGlobalObject> mGlobal;
UniquePtr<mozilla::ipc::PrincipalInfo> mPrincipalInfo;