Commit 6847f129 authored by Ben Kelly's avatar Ben Kelly
Browse files

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

parent 66d9e5a4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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);
}

+2 −1
Original line number Diff line number Diff line
@@ -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
+3 −3
Original line number Diff line number Diff line
@@ -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;
    }
+2 −0
Original line number Diff line number Diff line
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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: