2015-03-02 16:20:00 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/dom/cache/Cache.h"
|
|
|
|
|
|
|
|
#include "mozilla/dom/Headers.h"
|
|
|
|
#include "mozilla/dom/InternalResponse.h"
|
|
|
|
#include "mozilla/dom/Promise.h"
|
2015-04-29 18:59:43 +03:00
|
|
|
#include "mozilla/dom/PromiseNativeHandler.h"
|
2015-03-02 16:20:00 +03:00
|
|
|
#include "mozilla/dom/Response.h"
|
|
|
|
#include "mozilla/dom/WorkerPrivate.h"
|
|
|
|
#include "mozilla/dom/CacheBinding.h"
|
|
|
|
#include "mozilla/dom/cache/AutoUtils.h"
|
|
|
|
#include "mozilla/dom/cache/CacheChild.h"
|
2016-06-23 11:53:14 +03:00
|
|
|
#include "mozilla/dom/cache/CacheWorkerHolder.h"
|
2015-03-02 16:20:00 +03:00
|
|
|
#include "mozilla/dom/cache/ReadStream.h"
|
2018-01-08 16:05:03 +03:00
|
|
|
#include "mozilla/dom/DOMPrefs.h"
|
2015-03-02 16:20:00 +03:00
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
2016-08-23 07:09:32 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2015-03-02 16:20:00 +03:00
|
|
|
#include "nsIGlobalObject.h"
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace cache {
|
|
|
|
|
2016-05-15 20:32:09 +03:00
|
|
|
using mozilla::ipc::PBackgroundChild;
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
namespace {
|
|
|
|
|
2016-12-22 04:25:18 +03:00
|
|
|
enum class PutStatusPolicy {
|
|
|
|
Default,
|
|
|
|
RequireOK
|
|
|
|
};
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
bool
|
|
|
|
IsValidPutRequestURL(const nsAString& aUrl, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
bool validScheme = false;
|
|
|
|
|
|
|
|
// make a copy because ProcessURL strips the fragmet
|
2015-06-17 03:39:05 +03:00
|
|
|
NS_ConvertUTF16toUTF8 url(aUrl);
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2015-06-17 03:39:05 +03:00
|
|
|
TypeUtils::ProcessURL(url, &validScheme, nullptr, nullptr, aRv);
|
2015-04-29 18:59:43 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!validScheme) {
|
2015-11-20 21:36:46 +03:00
|
|
|
aRv.ThrowTypeError<MSG_INVALID_URL_SCHEME>(NS_LITERAL_STRING("Request"),
|
|
|
|
aUrl);
|
2015-04-29 18:59:43 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
static bool
|
|
|
|
IsValidPutRequestMethod(const Request& aRequest, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsAutoCString method;
|
|
|
|
aRequest.GetMethod(method);
|
2015-04-29 18:59:43 +03:00
|
|
|
if (!method.LowerCaseEqualsLiteral("get")) {
|
2015-03-02 16:20:00 +03:00
|
|
|
NS_ConvertASCIItoUTF16 label(method);
|
2015-11-20 21:36:46 +03:00
|
|
|
aRv.ThrowTypeError<MSG_INVALID_REQUEST_METHOD>(label);
|
2015-04-29 18:59:43 +03:00
|
|
|
return false;
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
2015-04-29 18:59:43 +03:00
|
|
|
|
|
|
|
return true;
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
2015-04-29 18:59:43 +03:00
|
|
|
IsValidPutRequestMethod(const RequestOrUSVString& aRequest, ErrorResult& aRv)
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
|
|
|
// If the provided request is a string URL, then it will default to
|
|
|
|
// a valid http method automatically.
|
|
|
|
if (!aRequest.IsRequest()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return IsValidPutRequestMethod(aRequest.GetAsRequest(), aRv);
|
|
|
|
}
|
|
|
|
|
2016-12-22 04:25:18 +03:00
|
|
|
static bool
|
|
|
|
IsValidPutResponseStatus(Response& aResponse, PutStatusPolicy aPolicy,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
if ((aPolicy == PutStatusPolicy::RequireOK && !aResponse.Ok()) ||
|
|
|
|
aResponse.Status() == 206) {
|
|
|
|
uint32_t t = static_cast<uint32_t>(aResponse.Type());
|
|
|
|
NS_ConvertASCIItoUTF16 type(ResponseTypeValues::strings[t].value,
|
|
|
|
ResponseTypeValues::strings[t].length);
|
|
|
|
nsAutoString status;
|
|
|
|
status.AppendInt(aResponse.Status());
|
|
|
|
nsAutoString url;
|
|
|
|
aResponse.GetUrl(url);
|
|
|
|
aRv.ThrowTypeError<MSG_CACHE_ADD_FAILED_RESPONSE>(type, status, url);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2015-04-29 18:59:43 +03:00
|
|
|
|
|
|
|
// Helper class to wait for Add()/AddAll() fetch requests to complete and
|
2016-06-23 11:53:14 +03:00
|
|
|
// then perform a PutAll() with the responses. This class holds a WorkerHolder
|
2015-04-29 18:59:43 +03:00
|
|
|
// to keep the Worker thread alive. This is mainly to ensure that Add/AddAll
|
|
|
|
// act the same as other Cache operations that directly create a CacheOpChild
|
|
|
|
// actor.
|
|
|
|
class Cache::FetchHandler final : public PromiseNativeHandler
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2015-04-29 18:59:43 +03:00
|
|
|
public:
|
2016-06-23 11:53:14 +03:00
|
|
|
FetchHandler(CacheWorkerHolder* aWorkerHolder, Cache* aCache,
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<Request>>&& aRequestList, Promise* aPromise)
|
2016-06-23 11:53:14 +03:00
|
|
|
: mWorkerHolder(aWorkerHolder)
|
2015-04-29 18:59:43 +03:00
|
|
|
, mCache(aCache)
|
2018-05-30 22:15:35 +03:00
|
|
|
, mRequestList(std::move(aRequestList))
|
2015-04-29 18:59:43 +03:00
|
|
|
, mPromise(aPromise)
|
|
|
|
{
|
2016-06-23 11:53:14 +03:00
|
|
|
MOZ_ASSERT_IF(!NS_IsMainThread(), mWorkerHolder);
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mCache);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mPromise);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
virtual void
|
|
|
|
ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
|
|
|
|
{
|
|
|
|
NS_ASSERT_OWNINGTHREAD(FetchHandler);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
// Stop holding the worker alive when we leave this method.
|
2016-06-23 11:53:14 +03:00
|
|
|
RefPtr<CacheWorkerHolder> workerHolder;
|
|
|
|
workerHolder.swap(mWorkerHolder);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
// Promise::All() passed an array of fetch() Promises should give us
|
|
|
|
// an Array of Response objects. The following code unwraps these
|
2015-10-18 08:24:48 +03:00
|
|
|
// JS values back to an nsTArray<RefPtr<Response>>.
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<RefPtr<Response>, 256> responseList;
|
2015-04-29 18:59:43 +03:00
|
|
|
responseList.SetCapacity(mRequestList.Length());
|
|
|
|
|
2015-08-29 07:55:40 +03:00
|
|
|
bool isArray;
|
|
|
|
if (NS_WARN_IF(!JS_IsArrayObject(aCx, aValue, &isArray) || !isArray)) {
|
2015-04-29 18:59:43 +03:00
|
|
|
Fail();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
|
|
|
|
|
|
|
|
uint32_t length;
|
|
|
|
if (NS_WARN_IF(!JS_GetArrayLength(aCx, obj, &length))) {
|
|
|
|
Fail();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
|
|
|
JS::Rooted<JS::Value> value(aCx);
|
|
|
|
|
|
|
|
if (NS_WARN_IF(!JS_GetElement(aCx, obj, i, &value))) {
|
|
|
|
Fail();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_WARN_IF(!value.isObject())) {
|
|
|
|
Fail();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
JS::Rooted<JSObject*> responseObj(aCx, &value.toObject());
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Response> response;
|
2015-04-29 18:59:43 +03:00
|
|
|
nsresult rv = UNWRAP_OBJECT(Response, responseObj, response);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
Fail();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_WARN_IF(response->Type() == ResponseType::Error)) {
|
|
|
|
Fail();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-04 18:59:52 +03:00
|
|
|
// Do not allow the convenience methods .add()/.addAll() to store failed
|
2016-12-22 04:25:18 +03:00
|
|
|
// or invalid responses. A consequence of this is that these methods
|
|
|
|
// cannot be used to store opaque or opaqueredirect responses since they
|
|
|
|
// always expose a 0 status value.
|
|
|
|
ErrorResult errorResult;
|
|
|
|
if (!IsValidPutResponseStatus(*response, PutStatusPolicy::RequireOK,
|
|
|
|
errorResult)) {
|
2016-02-04 18:59:52 +03:00
|
|
|
// TODO: abort the fetch requests we have running (bug 1157434)
|
2016-12-22 04:25:18 +03:00
|
|
|
mPromise->MaybeReject(errorResult);
|
2016-02-04 18:59:52 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
responseList.AppendElement(std::move(response));
|
2015-04-29 18:59:43 +03:00
|
|
|
}
|
|
|
|
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mRequestList.Length() == responseList.Length());
|
2015-04-29 18:59:43 +03:00
|
|
|
|
|
|
|
// Now store the unwrapped Response list in the Cache.
|
|
|
|
ErrorResult result;
|
2017-08-11 04:04:55 +03:00
|
|
|
// TODO: Here we use the JSContext as received by the ResolvedCallback, and
|
|
|
|
// its state could be the wrong one. The spec doesn't say anything
|
|
|
|
// about it, yet (bug 1384006)
|
|
|
|
RefPtr<Promise> put = mCache->PutAll(aCx, mRequestList, responseList, result);
|
2015-04-29 18:59:43 +03:00
|
|
|
if (NS_WARN_IF(result.Failed())) {
|
|
|
|
// TODO: abort the fetch requests we have running (bug 1157434)
|
|
|
|
mPromise->MaybeReject(result);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chain the Cache::Put() promise to the original promise returned to
|
|
|
|
// the content script.
|
|
|
|
mPromise->MaybeResolve(put);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override
|
|
|
|
{
|
|
|
|
NS_ASSERT_OWNINGTHREAD(FetchHandler);
|
|
|
|
Fail();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
~FetchHandler()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Fail()
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
2015-10-05 19:38:14 +03:00
|
|
|
rv.ThrowTypeError<MSG_FETCH_FAILED>();
|
2015-04-29 18:59:43 +03:00
|
|
|
mPromise->MaybeReject(rv);
|
|
|
|
}
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
RefPtr<CacheWorkerHolder> mWorkerHolder;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Cache> mCache;
|
|
|
|
nsTArray<RefPtr<Request>> mRequestList;
|
|
|
|
RefPtr<Promise> mPromise;
|
2015-04-29 18:59:43 +03:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS0(Cache::FetchHandler)
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::cache::Cache);
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::cache::Cache);
|
2015-04-16 22:00:15 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(mozilla::dom::cache::Cache, mGlobal);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Cache)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2015-03-24 17:34:17 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
2015-03-02 16:20:00 +03:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2017-09-15 22:25:41 +03:00
|
|
|
Cache::Cache(nsIGlobalObject* aGlobal, CacheChild* aActor, Namespace aNamespace)
|
2015-03-02 16:20:00 +03:00
|
|
|
: mGlobal(aGlobal)
|
|
|
|
, mActor(aActor)
|
2017-09-15 22:25:41 +03:00
|
|
|
, mNamespace(aNamespace)
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mGlobal);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mActor);
|
2017-09-15 22:25:41 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mNamespace != INVALID_NAMESPACE);
|
2015-03-02 16:20:00 +03:00
|
|
|
mActor->SetListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Cache::Match(JSContext* aCx, const RequestOrUSVString& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2017-08-11 04:04:55 +03:00
|
|
|
RefPtr<InternalRequest> ir =
|
|
|
|
ToInternalRequest(aCx, aRequest, IgnoreBody, aRv);
|
2015-04-16 22:00:15 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-04-14 00:05:57 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
CacheQueryParams params;
|
|
|
|
ToCacheQueryParams(params, aOptions);
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2017-09-15 22:25:41 +03:00
|
|
|
AutoChildOpArgs args(this,
|
2017-09-15 22:25:41 +03:00
|
|
|
CacheMatchArgs(CacheRequest(), params, GetOpenMode()),
|
2017-09-15 22:25:41 +03:00
|
|
|
1);
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
args.Add(ir, IgnoreBody, IgnoreInvalidScheme, aRv);
|
2015-04-16 22:00:15 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Cache::MatchAll(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
CacheQueryParams params;
|
|
|
|
ToCacheQueryParams(params, aOptions);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2017-09-15 22:25:41 +03:00
|
|
|
AutoChildOpArgs args(this,
|
2017-09-15 22:25:41 +03:00
|
|
|
CacheMatchAllArgs(void_t(), params, GetOpenMode()),
|
2017-09-15 22:25:41 +03:00
|
|
|
1);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
if (aRequest.WasPassed()) {
|
2017-08-11 04:04:55 +03:00
|
|
|
RefPtr<InternalRequest> ir = ToInternalRequest(aCx, aRequest.Value(),
|
|
|
|
IgnoreBody, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
args.Add(ir, IgnoreBody, IgnoreInvalidScheme, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2015-04-29 18:59:43 +03:00
|
|
|
Cache::Add(JSContext* aContext, const RequestOrUSVString& aRequest,
|
2017-02-01 23:43:37 +03:00
|
|
|
CallerType aCallerType, ErrorResult& aRv)
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
if (!IsValidPutRequestMethod(aRequest, aRv)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
GlobalObject global(aContext, mGlobal->GetGlobalJSObject());
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!global.Failed());
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<Request>> requestList(1);
|
|
|
|
RefPtr<Request> request = Request::Constructor(global, aRequest,
|
2018-10-11 22:18:43 +03:00
|
|
|
RequestInit(), aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
nsAutoString url;
|
|
|
|
request->GetUrl(url);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!IsValidPutRequestURL(url, aRv))) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
requestList.AppendElement(std::move(request));
|
|
|
|
return AddAll(global, std::move(requestList), aCallerType, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2015-04-29 18:59:43 +03:00
|
|
|
Cache::AddAll(JSContext* aContext,
|
|
|
|
const Sequence<OwningRequestOrUSVString>& aRequestList,
|
2017-02-01 23:43:37 +03:00
|
|
|
CallerType aCallerType,
|
2015-03-02 16:20:00 +03:00
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
GlobalObject global(aContext, mGlobal->GetGlobalJSObject());
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!global.Failed());
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<Request>> requestList(aRequestList.Length());
|
2015-04-29 18:59:43 +03:00
|
|
|
for (uint32_t i = 0; i < aRequestList.Length(); ++i) {
|
|
|
|
RequestOrUSVString requestOrString;
|
|
|
|
|
|
|
|
if (aRequestList[i].IsRequest()) {
|
|
|
|
requestOrString.SetAsRequest() = aRequestList[i].GetAsRequest();
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!IsValidPutRequestMethod(requestOrString.GetAsRequest(),
|
|
|
|
aRv))) {
|
2015-04-29 18:59:43 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
requestOrString.SetAsUSVString().Rebind(
|
|
|
|
aRequestList[i].GetAsUSVString().Data(),
|
|
|
|
aRequestList[i].GetAsUSVString().Length());
|
2015-04-16 22:00:15 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Request> request = Request::Constructor(global, requestOrString,
|
2018-10-11 22:18:43 +03:00
|
|
|
RequestInit(), aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
nsAutoString url;
|
|
|
|
request->GetUrl(url);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!IsValidPutRequestURL(url, aRv))) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
requestList.AppendElement(std::move(request));
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
return AddAll(global, std::move(requestList), aCallerType, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Cache::Put(JSContext* aCx, const RequestOrUSVString& aRequest,
|
|
|
|
Response& aResponse, ErrorResult& aRv)
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!IsValidPutRequestMethod(aRequest, aRv))) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-12-22 04:25:18 +03:00
|
|
|
if (!IsValidPutResponseStatus(aResponse, PutStatusPolicy::Default, aRv)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-08-11 04:04:55 +03:00
|
|
|
RefPtr<InternalRequest> ir = ToInternalRequest(aCx, aRequest, ReadBody, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-05-15 20:32:09 +03:00
|
|
|
AutoChildOpArgs args(this, CachePutAllArgs(), 1);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2017-08-11 04:04:55 +03:00
|
|
|
args.Add(aCx, ir, ReadBody, TypeErrorOnInvalidScheme,
|
2015-04-16 22:00:15 +03:00
|
|
|
aResponse, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Cache::Delete(JSContext* aCx, const RequestOrUSVString& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2017-08-11 04:04:55 +03:00
|
|
|
RefPtr<InternalRequest> ir =
|
|
|
|
ToInternalRequest(aCx, aRequest, IgnoreBody, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
CacheQueryParams params;
|
|
|
|
ToCacheQueryParams(params, aOptions);
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2016-05-15 20:32:09 +03:00
|
|
|
AutoChildOpArgs args(this, CacheDeleteArgs(CacheRequest(), params), 1);
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
args.Add(ir, IgnoreBody, IgnoreInvalidScheme, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-04-16 22:00:15 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Cache::Keys(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
CacheQueryParams params;
|
|
|
|
ToCacheQueryParams(params, aOptions);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2017-09-15 22:25:41 +03:00
|
|
|
AutoChildOpArgs args(this,
|
2017-09-15 22:25:41 +03:00
|
|
|
CacheKeysArgs(void_t(), params, GetOpenMode()),
|
2017-09-15 22:25:41 +03:00
|
|
|
1);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
if (aRequest.WasPassed()) {
|
2017-08-11 04:04:55 +03:00
|
|
|
RefPtr<InternalRequest> ir =
|
|
|
|
ToInternalRequest(aCx, aRequest.Value(), IgnoreBody, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
args.Add(ir, IgnoreBody, IgnoreInvalidScheme, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-03-02 16:20:00 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports*
|
|
|
|
Cache::GetParentObject() const
|
|
|
|
{
|
|
|
|
return mGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
Cache::WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto)
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
2018-06-26 00:20:54 +03:00
|
|
|
return Cache_Binding::Wrap(aContext, this, aGivenProto);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Cache::DestroyInternal(CacheChild* aActor)
|
|
|
|
{
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mActor);
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mActor == aActor);
|
2015-03-02 16:20:00 +03:00
|
|
|
mActor->ClearListener();
|
|
|
|
mActor = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIGlobalObject*
|
|
|
|
Cache::GetGlobalObject() const
|
|
|
|
{
|
|
|
|
return mGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
Cache::AssertOwningThread() const
|
|
|
|
{
|
|
|
|
NS_ASSERT_OWNINGTHREAD(Cache);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-05-15 20:32:09 +03:00
|
|
|
PBackgroundChild*
|
|
|
|
Cache::GetIPCManager()
|
2015-03-22 09:52:12 +03:00
|
|
|
{
|
|
|
|
NS_ASSERT_OWNINGTHREAD(Cache);
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mActor);
|
2016-05-15 20:32:09 +03:00
|
|
|
return mActor->Manager();
|
2015-03-22 09:52:12 +03:00
|
|
|
}
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
Cache::~Cache()
|
2015-03-19 22:31:02 +03:00
|
|
|
{
|
2015-04-16 22:00:15 +03:00
|
|
|
NS_ASSERT_OWNINGTHREAD(Cache);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (mActor) {
|
2015-05-01 18:13:36 +03:00
|
|
|
mActor->StartDestroyFromListener();
|
|
|
|
// DestroyInternal() is called synchronously by StartDestroyFromListener().
|
|
|
|
// So we should have already cleared the mActor.
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(!mActor);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 10:55:53 +03:00
|
|
|
already_AddRefed<Promise>
|
2015-04-16 22:00:15 +03:00
|
|
|
Cache::ExecuteOp(AutoChildOpArgs& aOpArgs, ErrorResult& aRv)
|
2015-04-15 10:55:53 +03:00
|
|
|
{
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mActor);
|
2016-01-04 23:03:11 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Promise> promise = Promise::Create(mGlobal, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!promise)) {
|
2015-04-16 22:00:15 +03:00
|
|
|
return nullptr;
|
2015-04-15 10:55:53 +03:00
|
|
|
}
|
2015-04-16 22:00:15 +03:00
|
|
|
|
2015-05-01 18:13:36 +03:00
|
|
|
mActor->ExecuteOp(mGlobal, promise, this, aOpArgs.SendAsOpArgs());
|
2015-04-16 22:00:15 +03:00
|
|
|
return promise.forget();
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::AddAll(const GlobalObject& aGlobal,
|
2017-02-01 23:43:37 +03:00
|
|
|
nsTArray<RefPtr<Request>>&& aRequestList,
|
|
|
|
CallerType aCallerType, ErrorResult& aRv)
|
2015-04-29 18:59:43 +03:00
|
|
|
{
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(mActor);
|
2015-04-29 18:59:43 +03:00
|
|
|
|
|
|
|
// If there is no work to do, then resolve immediately
|
|
|
|
if (aRequestList.IsEmpty()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Promise> promise = Promise::Create(mGlobal, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!promise)) {
|
2015-04-29 18:59:43 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-08-09 12:15:13 +03:00
|
|
|
promise->MaybeResolveWithUndefined();
|
2015-04-29 18:59:43 +03:00
|
|
|
return promise.forget();
|
|
|
|
}
|
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<RefPtr<Promise>, 256> fetchList;
|
2015-04-29 18:59:43 +03:00
|
|
|
fetchList.SetCapacity(aRequestList.Length());
|
|
|
|
|
|
|
|
// Begin fetching each request in parallel. For now, if an error occurs just
|
|
|
|
// abandon our previous fetch calls. In theory we could cancel them in the
|
|
|
|
// future once fetch supports it.
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < aRequestList.Length(); ++i) {
|
|
|
|
RequestOrUSVString requestOrString;
|
|
|
|
requestOrString.SetAsRequest() = aRequestList[i];
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Promise> fetch = FetchRequest(mGlobal, requestOrString,
|
2017-02-01 23:43:37 +03:00
|
|
|
RequestInit(), aCallerType, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-04-29 18:59:43 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2018-05-30 22:15:35 +03:00
|
|
|
fetchList.AppendElement(std::move(fetch));
|
2015-04-29 18:59:43 +03:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Promise> promise = Promise::Create(mGlobal, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-04-29 18:59:43 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-06-23 11:53:14 +03:00
|
|
|
RefPtr<FetchHandler> handler =
|
|
|
|
new FetchHandler(mActor->GetWorkerHolder(), this,
|
2018-05-30 22:15:35 +03:00
|
|
|
std::move(aRequestList), promise);
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2018-04-14 02:31:42 +03:00
|
|
|
RefPtr<Promise> fetchPromise = Promise::All(aGlobal.Context(), fetchList, aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-04-29 18:59:43 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
fetchPromise->AppendNativeHandler(handler);
|
|
|
|
|
|
|
|
return promise.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Cache::PutAll(JSContext* aCx, const nsTArray<RefPtr<Request>>& aRequestList,
|
2015-10-18 08:24:48 +03:00
|
|
|
const nsTArray<RefPtr<Response>>& aResponseList,
|
2015-04-29 18:59:43 +03:00
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2017-01-06 23:41:15 +03:00
|
|
|
MOZ_DIAGNOSTIC_ASSERT(aRequestList.Length() == aResponseList.Length());
|
2015-04-29 18:59:43 +03:00
|
|
|
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(!mActor)) {
|
2015-05-01 18:13:36 +03:00
|
|
|
aRv.Throw(NS_ERROR_UNEXPECTED);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-01-04 23:03:11 +03:00
|
|
|
CacheChild::AutoLock actorLock(mActor);
|
|
|
|
|
2016-05-15 20:32:09 +03:00
|
|
|
AutoChildOpArgs args(this, CachePutAllArgs(), aRequestList.Length());
|
2015-04-29 18:59:43 +03:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < aRequestList.Length(); ++i) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<InternalRequest> ir = aRequestList[i]->GetInternalRequest();
|
2017-08-11 04:04:55 +03:00
|
|
|
args.Add(aCx, ir, ReadBody, TypeErrorOnInvalidScheme, *aResponseList[i],
|
|
|
|
aRv);
|
2015-05-01 18:15:52 +03:00
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
2015-04-29 18:59:43 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ExecuteOp(args, aRv);
|
|
|
|
}
|
|
|
|
|
2017-09-15 22:25:41 +03:00
|
|
|
OpenMode
|
|
|
|
Cache::GetOpenMode() const
|
|
|
|
{
|
|
|
|
return mNamespace == CHROME_ONLY_NAMESPACE ? OpenMode::Eager : OpenMode::Lazy;
|
|
|
|
}
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
} // namespace cache
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|