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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_cache_Cache_h
|
|
|
|
#define mozilla_dom_cache_Cache_h
|
|
|
|
|
|
|
|
#include "mozilla/dom/cache/Types.h"
|
|
|
|
#include "mozilla/dom/cache/TypeUtils.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
|
|
class nsIGlobalObject;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class OwningRequestOrUSVString;
|
|
|
|
class Promise;
|
|
|
|
struct CacheQueryOptions;
|
|
|
|
class RequestOrUSVString;
|
|
|
|
class Response;
|
|
|
|
template<typename T> class Optional;
|
|
|
|
template<typename T> class Sequence;
|
2017-02-01 23:43:37 +03:00
|
|
|
enum class CallerType : uint32_t;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
namespace cache {
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
class AutoChildOpArgs;
|
2015-03-02 16:20:00 +03:00
|
|
|
class CacheChild;
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
class Cache final : public nsISupports
|
2015-03-22 09:52:12 +03:00
|
|
|
, public nsWrapperCache
|
|
|
|
, public TypeUtils
|
2015-03-02 16:20:00 +03:00
|
|
|
{
|
|
|
|
public:
|
2017-09-15 22:25:41 +03:00
|
|
|
Cache(nsIGlobalObject* aGlobal, CacheChild* aActor, Namespace aNamespace);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
// webidl interface methods
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Match(JSContext* aCx, const RequestOrUSVString& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
MatchAll(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
|
|
|
already_AddRefed<Promise>
|
2015-04-29 18:59:43 +03:00
|
|
|
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
|
|
|
already_AddRefed<Promise>
|
2015-04-29 18:59:43 +03:00
|
|
|
AddAll(JSContext* aContext,
|
2017-02-01 23:43:37 +03:00
|
|
|
const Sequence<OwningRequestOrUSVString>& aRequests,
|
|
|
|
CallerType aCallerType, ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Put(JSContext* aCx, const RequestOrUSVString& aRequest, Response& aResponse,
|
2015-03-02 16:20:00 +03:00
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Delete(JSContext* aCx, const RequestOrUSVString& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
Keys(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aParams, ErrorResult& aRv);
|
|
|
|
|
|
|
|
// binding methods
|
|
|
|
static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() const;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
// Called when CacheChild actor is being destroyed
|
|
|
|
void DestroyInternal(CacheChild* aActor);
|
|
|
|
|
|
|
|
// TypeUtils methods
|
|
|
|
virtual nsIGlobalObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
GetGlobalObject() const override;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void AssertOwningThread() const override;
|
2015-03-02 16:20:00 +03:00
|
|
|
#endif
|
|
|
|
|
2016-05-15 20:32:09 +03:00
|
|
|
virtual mozilla::ipc::PBackgroundChild*
|
|
|
|
GetIPCManager() override;
|
2015-03-22 09:52:12 +03:00
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
private:
|
2015-04-29 18:59:43 +03:00
|
|
|
class FetchHandler;
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
~Cache();
|
|
|
|
|
2015-04-15 10:55:53 +03:00
|
|
|
// Called when we're destroyed or CCed.
|
|
|
|
void DisconnectFromActor();
|
|
|
|
|
2015-04-16 22:00:15 +03:00
|
|
|
already_AddRefed<Promise>
|
|
|
|
ExecuteOp(AutoChildOpArgs& aOpArgs, ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
|
2015-04-29 18:59:43 +03:00
|
|
|
already_AddRefed<Promise>
|
2015-10-18 08:24:48 +03:00
|
|
|
AddAll(const GlobalObject& aGlobal, nsTArray<RefPtr<Request>>&& aRequestList,
|
2017-02-01 23:43:37 +03:00
|
|
|
CallerType aCallerType, ErrorResult& aRv);
|
2015-04-29 18:59:43 +03:00
|
|
|
|
|
|
|
already_AddRefed<Promise>
|
2017-08-11 04:04:55 +03:00
|
|
|
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-09-15 22:25:41 +03:00
|
|
|
OpenMode
|
|
|
|
GetOpenMode() const;
|
|
|
|
|
2015-03-02 16:20:00 +03:00
|
|
|
nsCOMPtr<nsIGlobalObject> mGlobal;
|
|
|
|
CacheChild* mActor;
|
2017-09-15 22:25:41 +03:00
|
|
|
const Namespace mNamespace;
|
2015-03-02 16:20:00 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Cache)
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace cache
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Cache_h
|