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> Match(JSContext* aCx,
|
2017-08-11 04:04:55 +03:00
|
|
|
const RequestOrUSVString& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
already_AddRefed<Promise> MatchAll(
|
2017-08-11 04:04:55 +03:00
|
|
|
JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aOptions, ErrorResult& aRv);
|
|
|
|
already_AddRefed<Promise> Add(JSContext* aContext,
|
2017-08-11 04:04:55 +03:00
|
|
|
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> AddAll(
|
2015-04-29 18:59:43 +03:00
|
|
|
JSContext* aContext, const Sequence<OwningRequestOrUSVString>& aRequests,
|
2017-02-01 23:43:37 +03:00
|
|
|
CallerType aCallerType, ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
already_AddRefed<Promise> Put(JSContext* aCx,
|
2017-02-01 23:43:37 +03:00
|
|
|
const RequestOrUSVString& aRequest,
|
|
|
|
Response& aResponse, ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
already_AddRefed<Promise> Delete(JSContext* aCx,
|
2017-08-11 04:04:55 +03:00
|
|
|
const RequestOrUSVString& aRequest,
|
|
|
|
const CacheQueryOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
2015-03-02 16:20:00 +03:00
|
|
|
already_AddRefed<Promise> Keys(JSContext* aCx,
|
2017-08-11 04:04:55 +03:00
|
|
|
const Optional<RequestOrUSVString>& aRequest,
|
2015-03-02 16:20:00 +03:00
|
|
|
const CacheQueryOptions& aParams,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
// binding methods
|
|
|
|
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
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsIGlobalObject* 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-10-18 08:24:48 +03:00
|
|
|
already_AddRefed<Promise> AddAll(const GlobalObject& aGlobal,
|
2020-05-11 15:13:48 +03:00
|
|
|
nsTArray<SafeRefPtr<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> PutAll(
|
2020-05-11 15:13:48 +03:00
|
|
|
JSContext* aCx, const nsTArray<SafeRefPtr<Request>>& aRequestList,
|
2015-10-18 08:24:48 +03:00
|
|
|
const nsTArray<RefPtr<Response>>& aResponseList, ErrorResult& aRv);
|
2015-04-29 18:59:43 +03:00
|
|
|
|
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
|
2022-09-07 14:22:51 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(Cache)
|
2015-03-02 16:20:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace cache
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_Cache_h
|