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"
|
|
|
|
#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"
|
2015-04-15 10:54:39 +03:00
|
|
|
#include "mozilla/dom/cache/CacheOpChild.h"
|
2015-03-22 09:52:12 +03:00
|
|
|
#include "mozilla/dom/cache/CachePushStreamChild.h"
|
2015-03-02 16:20:00 +03:00
|
|
|
#include "mozilla/dom/cache/ReadStream.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "nsIGlobalObject.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
using mozilla::ErrorResult;
|
|
|
|
using mozilla::dom::MSG_INVALID_REQUEST_METHOD;
|
|
|
|
using mozilla::dom::OwningRequestOrUSVString;
|
|
|
|
using mozilla::dom::Request;
|
|
|
|
using mozilla::dom::RequestOrUSVString;
|
|
|
|
|
|
|
|
static bool
|
|
|
|
IsValidPutRequestMethod(const Request& aRequest, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsAutoCString method;
|
|
|
|
aRequest.GetMethod(method);
|
|
|
|
bool valid = method.LowerCaseEqualsLiteral("get");
|
|
|
|
if (!valid) {
|
|
|
|
NS_ConvertASCIItoUTF16 label(method);
|
|
|
|
aRv.ThrowTypeError(MSG_INVALID_REQUEST_METHOD, &label);
|
|
|
|
}
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
IsValidPutRequestMethod(const RequestOrUSVString& aRequest,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
IsValidPutRequestMethod(const OwningRequestOrUSVString& aRequest,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
if (!aRequest.IsRequest()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return IsValidPutRequestMethod(*aRequest.GetAsRequest().get(), aRv);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
namespace cache {
|
|
|
|
|
|
|
|
using mozilla::ErrorResult;
|
|
|
|
using mozilla::unused;
|
|
|
|
using mozilla::dom::workers::GetCurrentThreadWorkerPrivate;
|
|
|
|
using mozilla::dom::workers::WorkerPrivate;
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::cache::Cache);
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(mozilla::dom::cache::Cache);
|
2015-04-15 03:11:19 +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
|
|
|
|
|
|
|
|
Cache::Cache(nsIGlobalObject* aGlobal, CacheChild* aActor)
|
|
|
|
: mGlobal(aGlobal)
|
|
|
|
, mActor(aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mGlobal);
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
mActor->SetListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::Match(const RequestOrUSVString& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
|
2015-04-14 01:18:19 +03:00
|
|
|
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequest, IgnoreBody, aRv);
|
2015-04-15 03:11:19 +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-15 10:54:48 +03:00
|
|
|
PCacheQueryParams params;
|
|
|
|
ToPCacheQueryParams(params, aOptions);
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-15 10:54:48 +03:00
|
|
|
AutoChildOpArgs args(this, CacheMatchArgs(PCacheRequest(), params));
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
args.Add(ir, IgnoreBody, PassThroughReferrer, IgnoreInvalidScheme, aRv);
|
|
|
|
if (NS_WARN_IF(aRv.Failed())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::MatchAll(const Optional<RequestOrUSVString>& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
|
2015-04-15 10:54:48 +03:00
|
|
|
PCacheQueryParams params;
|
|
|
|
ToPCacheQueryParams(params, aOptions);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
AutoChildOpArgs args(this, CacheMatchAllArgs(void_t(), params));
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
if (aRequest.WasPassed()) {
|
|
|
|
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequest.Value(),
|
|
|
|
IgnoreBody, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
args.Add(ir, IgnoreBody, PassThroughReferrer, IgnoreInvalidScheme, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::Add(const RequestOrUSVString& aRequest, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
|
|
|
|
if (!IsValidPutRequestMethod(aRequest, aRv)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequest, ReadBody, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
AutoChildOpArgs args(this, CacheAddAllArgs());
|
|
|
|
|
|
|
|
args.Add(ir, ReadBody, ExpandReferrer, NetworkErrorOnInvalidScheme, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::AddAll(const Sequence<OwningRequestOrUSVString>& aRequests,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
|
|
|
|
// If there is no work to do, then resolve immediately
|
|
|
|
if (aRequests.IsEmpty()) {
|
2015-04-15 03:11:19 +03:00
|
|
|
nsRefPtr<Promise> promise = Promise::Create(mGlobal, aRv);
|
|
|
|
if (!promise) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
promise->MaybeResolve(JS::UndefinedHandleValue);
|
|
|
|
return promise.forget();
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
AutoChildOpArgs args(this, CacheAddAllArgs());
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < aRequests.Length(); ++i) {
|
|
|
|
if (!IsValidPutRequestMethod(aRequests[i], aRv)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequests[i], ReadBody,
|
|
|
|
aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
args.Add(ir, ReadBody, ExpandReferrer, NetworkErrorOnInvalidScheme, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::Put(const RequestOrUSVString& aRequest, Response& aResponse,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
|
|
|
|
if (!IsValidPutRequestMethod(aRequest, aRv)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequest, ReadBody, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
AutoChildOpArgs args(this, CachePutAllArgs());
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
args.Add(ir, ReadBody, PassThroughReferrer, TypeErrorOnInvalidScheme,
|
|
|
|
aResponse, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::Delete(const RequestOrUSVString& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
|
|
|
|
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequest, IgnoreBody, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 10:54:48 +03:00
|
|
|
PCacheQueryParams params;
|
|
|
|
ToPCacheQueryParams(params, aOptions);
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-15 10:54:48 +03:00
|
|
|
AutoChildOpArgs args(this, CacheDeleteArgs(PCacheRequest(), params));
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
args.Add(ir, IgnoreBody, PassThroughReferrer, IgnoreInvalidScheme, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2015-04-14 01:18:19 +03:00
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
|
|
|
Cache::Keys(const Optional<RequestOrUSVString>& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
|
2015-04-15 10:54:48 +03:00
|
|
|
PCacheQueryParams params;
|
|
|
|
ToPCacheQueryParams(params, aOptions);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
AutoChildOpArgs args(this, CacheKeysArgs(void_t(), params));
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
if (aRequest.WasPassed()) {
|
|
|
|
nsRefPtr<InternalRequest> ir = ToInternalRequest(aRequest.Value(),
|
|
|
|
IgnoreBody, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
args.Add(ir, IgnoreBody, PassThroughReferrer, IgnoreInvalidScheme, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return ExecuteOp(args, aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
bool
|
|
|
|
Cache::PrefEnabled(JSContext* aCx, JSObject* aObj)
|
|
|
|
{
|
|
|
|
using mozilla::dom::workers::WorkerPrivate;
|
|
|
|
using mozilla::dom::workers::GetWorkerPrivateFromContext;
|
|
|
|
|
|
|
|
// If we're on the main thread, then check the pref directly.
|
|
|
|
if (NS_IsMainThread()) {
|
|
|
|
bool enabled = false;
|
|
|
|
Preferences::GetBool("dom.caches.enabled", &enabled);
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise check the pref via the work private helper
|
|
|
|
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
|
|
|
if (!workerPrivate) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return workerPrivate->DOMCachesEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
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
|
|
|
return CacheBinding::Wrap(aContext, this, aGivenProto);
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Cache::DestroyInternal(CacheChild* aActor)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
MOZ_ASSERT(mActor == aActor);
|
|
|
|
mActor->ClearListener();
|
|
|
|
mActor = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIGlobalObject*
|
|
|
|
Cache::GetGlobalObject() const
|
|
|
|
{
|
|
|
|
return mGlobal;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
Cache::AssertOwningThread() const
|
|
|
|
{
|
|
|
|
NS_ASSERT_OWNINGTHREAD(Cache);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-22 09:52:12 +03:00
|
|
|
CachePushStreamChild*
|
|
|
|
Cache::CreatePushStream(nsIAsyncInputStream* aStream)
|
|
|
|
{
|
|
|
|
NS_ASSERT_OWNINGTHREAD(Cache);
|
|
|
|
MOZ_ASSERT(mActor);
|
|
|
|
MOZ_ASSERT(aStream);
|
2015-04-15 10:54:39 +03:00
|
|
|
auto actor = mActor->SendPCachePushStreamConstructor(
|
|
|
|
new CachePushStreamChild(mActor->GetFeature(), aStream));
|
|
|
|
MOZ_ASSERT(actor);
|
|
|
|
return static_cast<CachePushStreamChild*>(actor);
|
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-15 03:11:19 +03:00
|
|
|
NS_ASSERT_OWNINGTHREAD(Cache);
|
2015-03-02 16:20:00 +03:00
|
|
|
if (mActor) {
|
|
|
|
mActor->StartDestroy();
|
|
|
|
// DestroyInternal() is called synchronously by StartDestroy(). So we
|
|
|
|
// should have already cleared the mActor.
|
|
|
|
MOZ_ASSERT(!mActor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 01:27:48 +03:00
|
|
|
already_AddRefed<Promise>
|
2015-04-15 03:11:19 +03:00
|
|
|
Cache::ExecuteOp(AutoChildOpArgs& aOpArgs, ErrorResult& aRv)
|
2015-04-15 01:27:48 +03:00
|
|
|
{
|
2015-04-15 03:11:19 +03:00
|
|
|
nsRefPtr<Promise> promise = Promise::Create(mGlobal, aRv);
|
|
|
|
if (!promise) {
|
|
|
|
return nullptr;
|
2015-04-15 01:27:48 +03:00
|
|
|
}
|
2015-04-15 03:11:19 +03:00
|
|
|
|
2015-04-15 10:54:39 +03:00
|
|
|
unused << mActor->SendPCacheOpConstructor(
|
|
|
|
new CacheOpChild(mActor->GetFeature(), mGlobal, this, promise),
|
|
|
|
aOpArgs.SendAsOpArgs());
|
|
|
|
|
2015-04-15 03:11:19 +03:00
|
|
|
return promise.forget();
|
2015-03-02 16:20:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace cache
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|