Bug 1791867 - Add GetStorageManager to nsIGlobalObject; r=smaug,dom-storage-reviewers,asuth

Differential Revision: https://phabricator.services.mozilla.com/D157902
This commit is contained in:
Jan Varga 2022-11-30 09:51:14 +00:00
parent cc0e44a847
commit e95f3b4eec
5 changed files with 15 additions and 0 deletions

View File

@ -1678,6 +1678,10 @@ nsGlobalWindowInner::GetStorageKey() {
return std::move(principalInfo);
}
mozilla::dom::StorageManager* nsGlobalWindowInner::GetStorageManager() {
return Navigator()->Storage();
}
nsresult nsGlobalWindowInner::EnsureScriptEnvironment() {
// NOTE: We can't use FORWARD_TO_OUTER here because we don't want to fail if
// we're called on an inactive inner window.

View File

@ -266,6 +266,8 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
mozilla::Result<mozilla::ipc::PrincipalInfo, nsresult> GetStorageKey()
override;
mozilla::dom::StorageManager* GetStorageManager() override;
void TraceGlobalJSObject(JSTracer* aTrc);
virtual nsresult EnsureScriptEnvironment() override;

View File

@ -49,6 +49,7 @@ class ReportingObserver;
class ServiceWorker;
class ServiceWorkerRegistration;
class ServiceWorkerRegistrationDescriptor;
class StorageManager;
} // namespace dom
namespace ipc {
class PrincipalInfo;
@ -278,6 +279,8 @@ class nsIGlobalObject : public nsISupports,
mozilla::Result<bool, nsresult> HasEqualStorageKey(
const mozilla::ipc::PrincipalInfo& aStorageKey);
virtual mozilla::dom::StorageManager* GetStorageManager() { return nullptr; }
protected:
virtual ~nsIGlobalObject();

View File

@ -842,6 +842,10 @@ WorkerGlobalScope::GetOrCreateServiceWorkerRegistration(
return ref;
}
mozilla::dom::StorageManager* WorkerGlobalScope::GetStorageManager() {
return RefPtr(Navigator())->Storage();
}
void WorkerGlobalScope::StorageAccessPermissionGranted() {
// Reset the IndexedDB factory.
mIndexedDB = nullptr;

View File

@ -234,6 +234,8 @@ class WorkerGlobalScope : public WorkerGlobalScopeBase {
Maybe<EventCallbackDebuggerNotificationType> GetDebuggerNotificationType()
const final;
mozilla::dom::StorageManager* GetStorageManager() final;
// WorkerGlobalScope WebIDL implementation
WorkerGlobalScope* Self() { return this; }