Bug 1397128 P8 Track which storage "namespace" each Cache object is associated with. r=tt

This commit is contained in:
Ben Kelly 2017-09-15 12:25:41 -07:00
parent 65f88cc067
commit 9e8538fa6a
5 changed files with 13 additions and 6 deletions

4
dom/cache/Cache.cpp vendored
View File

@ -256,12 +256,14 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Cache)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
Cache::Cache(nsIGlobalObject* aGlobal, CacheChild* aActor)
Cache::Cache(nsIGlobalObject* aGlobal, CacheChild* aActor, Namespace aNamespace)
: mGlobal(aGlobal)
, mActor(aActor)
, mNamespace(aNamespace)
{
MOZ_DIAGNOSTIC_ASSERT(mGlobal);
MOZ_DIAGNOSTIC_ASSERT(mActor);
MOZ_DIAGNOSTIC_ASSERT(mNamespace != INVALID_NAMESPACE);
mActor->SetListener(this);
}

3
dom/cache/Cache.h vendored
View File

@ -41,7 +41,7 @@ class Cache final : public nsISupports
, public TypeUtils
{
public:
Cache(nsIGlobalObject* aGlobal, CacheChild* aActor);
Cache(nsIGlobalObject* aGlobal, CacheChild* aActor, Namespace aNamespace);
// webidl interface methods
already_AddRefed<Promise>
@ -109,6 +109,7 @@ private:
nsCOMPtr<nsIGlobalObject> mGlobal;
CacheChild* mActor;
const Namespace mNamespace;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS

View File

@ -158,8 +158,8 @@ CacheOpChild::Recv__delete__(const ErrorResult& aRv,
}
case CacheOpResult::TStorageOpenResult:
{
auto actor = static_cast<CacheChild*>(
aResult.get_StorageOpenResult().actorChild());
auto result = aResult.get_StorageOpenResult();
auto actor = static_cast<CacheChild*>(result.actorChild());
// If we have a success status then we should have an actor. Gracefully
// reject instead of crashing, though, if we get a nullptr here.
@ -176,7 +176,7 @@ CacheOpChild::Recv__delete__(const ErrorResult& aRv,
CacheWorkerHolder::AllowIdleShutdownStart);
actor->SetWorkerHolder(workerHolder);
RefPtr<Cache> cache = new Cache(mGlobal, actor);
RefPtr<Cache> cache = new Cache(mGlobal, actor, result.ns());
mPromise->MaybeResolve(cache);
break;
}

View File

@ -10,6 +10,7 @@ include ChannelInfo;
include PBackgroundSharedTypes;
using HeadersGuardEnum from "mozilla/dom/FetchIPCTypes.h";
using Namespace from "mozilla/dom/cache/IPCUtils.h";
using OpenMode from "mozilla/dom/cache/IPCUtils.h";
using ReferrerPolicy from "mozilla/dom/FetchIPCTypes.h";
using RequestCredentials from "mozilla/dom/FetchIPCTypes.h";
@ -212,6 +213,7 @@ struct StorageHasResult
struct StorageOpenResult
{
nullable PCache actor;
Namespace ns;
};
struct StorageDeleteResult

View File

@ -1342,7 +1342,9 @@ public:
Complete(Listener* aListener, ErrorResult&& aRv) override
{
MOZ_DIAGNOSTIC_ASSERT(aRv.Failed() || mCacheId != INVALID_CACHE_ID);
aListener->OnOpComplete(Move(aRv), StorageOpenResult(), mCacheId);
aListener->OnOpComplete(Move(aRv),
StorageOpenResult(nullptr, nullptr, mNamespace),
mCacheId);
}
private: