gecko-dev/dom/cache/CacheStorage.h
Gurzau Raul 321347c110 Backed out 22 changesets (bug 1419771) for build bustage build/src/dom/base/FuzzingFunctions.cpp on a CLOSED TREE
Backed out changeset b2b7b46c8ad0 (bug 1419771)
Backed out changeset 0206657d2ea2 (bug 1419771)
Backed out changeset f0f4b98a07b6 (bug 1419771)
Backed out changeset 4b52904694f4 (bug 1419771)
Backed out changeset 9f40cc12d6c6 (bug 1419771)
Backed out changeset f500a61f564c (bug 1419771)
Backed out changeset 0bd9d964df8a (bug 1419771)
Backed out changeset 1397a6bbb446 (bug 1419771)
Backed out changeset 7e77a00fa8b5 (bug 1419771)
Backed out changeset 5f6df771459a (bug 1419771)
Backed out changeset 7624e70b2965 (bug 1419771)
Backed out changeset b9d674bdc723 (bug 1419771)
Backed out changeset 5e44aeda4196 (bug 1419771)
Backed out changeset 601b49f51b41 (bug 1419771)
Backed out changeset d12dc5557982 (bug 1419771)
Backed out changeset 6c863ab2e986 (bug 1419771)
Backed out changeset 0866d79873ab (bug 1419771)
Backed out changeset 8ecc91474621 (bug 1419771)
Backed out changeset 19b14deed8fe (bug 1419771)
Backed out changeset 000c8d5fbc03 (bug 1419771)
Backed out changeset 2e263a2519c5 (bug 1419771)
Backed out changeset b628d9298be8 (bug 1419771)
2017-12-13 23:41:49 +02:00

125 lines
3.6 KiB
C++

/* -*- 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/. */
#ifndef mozilla_dom_cache_CacheStorage_h
#define mozilla_dom_cache_CacheStorage_h
#include "mozilla/dom/cache/Types.h"
#include "mozilla/dom/cache/TypeUtils.h"
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "nsWrapperCache.h"
class nsIGlobalObject;
namespace mozilla {
class ErrorResult;
namespace ipc {
class PrincipalInfo;
} // namespace ipc
namespace dom {
enum class CacheStorageNamespace : uint8_t;
class Promise;
namespace workers {
class WorkerPrivate;
} // namespace workers
namespace cache {
class CacheStorageChild;
class CacheWorkerHolder;
class CacheStorage final : public nsISupports
, public nsWrapperCache
, public TypeUtils
{
typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
public:
static already_AddRefed<CacheStorage>
CreateOnMainThread(Namespace aNamespace, nsIGlobalObject* aGlobal,
nsIPrincipal* aPrincipal, bool aStorageDisabled,
bool aForceTrustedOrigin, ErrorResult& aRv);
static already_AddRefed<CacheStorage>
CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
workers::WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
static bool
DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
// webidl interface methods
already_AddRefed<Promise>
Match(JSContext* aCx, const RequestOrUSVString& aRequest,
const CacheQueryOptions& aOptions, ErrorResult& aRv);
already_AddRefed<Promise> Has(const nsAString& aKey, ErrorResult& aRv);
already_AddRefed<Promise> Open(const nsAString& aKey, ErrorResult& aRv);
already_AddRefed<Promise> Delete(const nsAString& aKey, ErrorResult& aRv);
already_AddRefed<Promise> Keys(ErrorResult& aRv);
// chrome-only webidl interface methods
static already_AddRefed<CacheStorage>
Constructor(const GlobalObject& aGlobal, CacheStorageNamespace aNamespace,
nsIPrincipal* aPrincipal, ErrorResult& aRv);
// binding methods
static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
nsISupports* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override;
// Called when CacheStorageChild actor is being destroyed
void DestroyInternal(CacheStorageChild* aActor);
// TypeUtils methods
virtual nsIGlobalObject* GetGlobalObject() const override;
#ifdef DEBUG
virtual void AssertOwningThread() const override;
#endif
virtual mozilla::ipc::PBackgroundChild*
GetIPCManager() override;
private:
CacheStorage(Namespace aNamespace, nsIGlobalObject* aGlobal,
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
CacheWorkerHolder* aWorkerHolder);
explicit CacheStorage(nsresult aFailureResult);
~CacheStorage();
struct Entry;
void RunRequest(nsAutoPtr<Entry>&& aEntry);
OpenMode
GetOpenMode() const;
const Namespace mNamespace;
nsCOMPtr<nsIGlobalObject> mGlobal;
UniquePtr<mozilla::ipc::PrincipalInfo> mPrincipalInfo;
// weak ref cleared in DestroyInternal
CacheStorageChild* mActor;
nsresult mStatus;
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CacheStorage)
};
} // namespace cache
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_cache_CacheStorage_h