2021-06-10 06:01:26 +00: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_NavigationPreloadManager_h
|
|
|
|
#define mozilla_dom_NavigationPreloadManager_h
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2021-06-10 06:01:27 +00:00
|
|
|
#include "mozilla/dom/ServiceWorkerRegistration.h"
|
2021-06-10 06:01:26 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
|
|
|
|
class nsIGlobalObject;
|
|
|
|
|
2022-05-09 20:41:13 +00:00
|
|
|
namespace mozilla::dom {
|
2021-06-10 06:01:26 +00:00
|
|
|
|
|
|
|
class Promise;
|
|
|
|
|
|
|
|
class NavigationPreloadManager final : public nsISupports,
|
|
|
|
public nsWrapperCache {
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(NavigationPreloadManager)
|
|
|
|
|
|
|
|
static bool IsValidHeader(const nsACString& aHeader);
|
|
|
|
|
2022-05-16 23:27:10 +00:00
|
|
|
NavigationPreloadManager(nsCOMPtr<nsIGlobalObject>&& aGlobal,
|
|
|
|
RefPtr<ServiceWorkerRegistration::Inner>& aInner);
|
2021-06-10 06:01:26 +00:00
|
|
|
|
|
|
|
// Webidl binding
|
|
|
|
nsIGlobalObject* GetParentObject() const { return mGlobal; }
|
|
|
|
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
// WebIdl implementation
|
2022-05-03 08:23:25 +00:00
|
|
|
already_AddRefed<Promise> Enable(ErrorResult& aError);
|
2021-06-10 06:01:26 +00:00
|
|
|
|
2022-05-03 08:23:25 +00:00
|
|
|
already_AddRefed<Promise> Disable(ErrorResult& aError);
|
2021-06-10 06:01:26 +00:00
|
|
|
|
2022-05-03 08:23:25 +00:00
|
|
|
already_AddRefed<Promise> SetHeaderValue(const nsACString& aHeader,
|
|
|
|
ErrorResult& aError);
|
2021-06-10 06:01:26 +00:00
|
|
|
|
2022-05-03 08:23:25 +00:00
|
|
|
already_AddRefed<Promise> GetState(ErrorResult& aError);
|
2021-06-10 06:01:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
~NavigationPreloadManager() = default;
|
|
|
|
|
|
|
|
// General method for Enable()/Disable()
|
2022-05-03 08:23:25 +00:00
|
|
|
already_AddRefed<Promise> SetEnabled(bool aEnabled, ErrorResult& aError);
|
2021-06-10 06:01:26 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIGlobalObject> mGlobal;
|
2022-05-16 23:27:10 +00:00
|
|
|
RefPtr<ServiceWorkerRegistration::Inner> mInner;
|
2021-06-10 06:01:26 +00:00
|
|
|
};
|
|
|
|
|
2022-05-09 20:41:13 +00:00
|
|
|
} // namespace mozilla::dom
|
2021-06-10 06:01:26 +00:00
|
|
|
|
|
|
|
#endif // mozilla_dom_NavigationPreloadManager_h
|