Supply ExecutionContext to DeprecatedStorageQuota's HeapMojo wrappers.
HeapMojo wrappers require ExecutionContext to reset mojo objects when ExecutionContext is detached.
Bug: 1049056
Change-Id: Ie496a4c11cedbbb185fa75524ebd7e94c4f7f9d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2217530
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Kouhei Ueno <kouhei@chromium.org>
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775027}
diff --git a/third_party/blink/renderer/modules/quota/deprecated_storage_info.cc b/third_party/blink/renderer/modules/quota/deprecated_storage_info.cc
index 0463433..223d740 100644
--- a/third_party/blink/renderer/modules/quota/deprecated_storage_info.cc
+++ b/third_party/blink/renderer/modules/quota/deprecated_storage_info.cc
@@ -53,7 +53,8 @@
WebFeature::kQuotaRead);
// Dispatching the request to DeprecatedStorageQuota, as this interface is
// deprecated in favor of DeprecatedStorageQuota.
- DeprecatedStorageQuota* storage_quota = GetStorageQuota(storage_type);
+ DeprecatedStorageQuota* storage_quota =
+ GetStorageQuota(storage_type, ExecutionContext::From(script_state));
if (!storage_quota) {
// Unknown storage type is requested.
DeprecatedStorageQuota::EnqueueStorageErrorCallback(
@@ -76,7 +77,8 @@
WebFeature::kQuotaRead);
// Dispatching the request to DeprecatedStorageQuota, as this interface is
// deprecated in favor of DeprecatedStorageQuota.
- DeprecatedStorageQuota* storage_quota = GetStorageQuota(storage_type);
+ DeprecatedStorageQuota* storage_quota =
+ GetStorageQuota(storage_type, ExecutionContext::From(script_state));
if (!storage_quota) {
// Unknown storage type is requested.
DeprecatedStorageQuota::EnqueueStorageErrorCallback(
@@ -88,18 +90,19 @@
}
DeprecatedStorageQuota* DeprecatedStorageInfo::GetStorageQuota(
- int storage_type) {
+ int storage_type,
+ ExecutionContext* execution_context) {
switch (storage_type) {
case kTemporary:
if (!temporary_storage_) {
temporary_storage_ = MakeGarbageCollected<DeprecatedStorageQuota>(
- DeprecatedStorageQuota::kTemporary);
+ DeprecatedStorageQuota::kTemporary, execution_context);
}
return temporary_storage_.Get();
case kPersistent:
if (!persistent_storage_) {
persistent_storage_ = MakeGarbageCollected<DeprecatedStorageQuota>(
- DeprecatedStorageQuota::kPersistent);
+ DeprecatedStorageQuota::kPersistent, execution_context);
}
return persistent_storage_.Get();
}
diff --git a/third_party/blink/renderer/modules/quota/deprecated_storage_info.h b/third_party/blink/renderer/modules/quota/deprecated_storage_info.h
index 1307480..fe83a649 100644
--- a/third_party/blink/renderer/modules/quota/deprecated_storage_info.h
+++ b/third_party/blink/renderer/modules/quota/deprecated_storage_info.h
@@ -68,7 +68,8 @@
void Trace(Visitor*) const override;
private:
- DeprecatedStorageQuota* GetStorageQuota(int storage_type);
+ DeprecatedStorageQuota* GetStorageQuota(int storage_type,
+ ExecutionContext* execution_context);
mutable Member<DeprecatedStorageQuota> temporary_storage_;
mutable Member<DeprecatedStorageQuota> persistent_storage_;
diff --git a/third_party/blink/renderer/modules/quota/deprecated_storage_quota.cc b/third_party/blink/renderer/modules/quota/deprecated_storage_quota.cc
index 8ba4239..d98c703 100644
--- a/third_party/blink/renderer/modules/quota/deprecated_storage_quota.cc
+++ b/third_party/blink/renderer/modules/quota/deprecated_storage_quota.cc
@@ -122,8 +122,10 @@
WrapPersistent(DOMError::Create(exception_code))));
}
-DeprecatedStorageQuota::DeprecatedStorageQuota(Type type)
- : type_(type), quota_host_(nullptr) {}
+DeprecatedStorageQuota::DeprecatedStorageQuota(
+ Type type,
+ ExecutionContext* execution_context)
+ : type_(type), quota_host_(execution_context) {}
void DeprecatedStorageQuota::queryUsageAndQuota(
ScriptState* script_state,
diff --git a/third_party/blink/renderer/modules/quota/deprecated_storage_quota.h b/third_party/blink/renderer/modules/quota/deprecated_storage_quota.h
index 9cedff8..c4e57cc9 100644
--- a/third_party/blink/renderer/modules/quota/deprecated_storage_quota.h
+++ b/third_party/blink/renderer/modules/quota/deprecated_storage_quota.h
@@ -32,6 +32,7 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_QUOTA_DEPRECATED_STORAGE_QUOTA_H_
#include "third_party/blink/public/mojom/quota/quota_manager_host.mojom-blink.h"
+#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
@@ -59,7 +60,7 @@
V8StorageErrorCallback*,
DOMExceptionCode);
- explicit DeprecatedStorageQuota(Type);
+ DeprecatedStorageQuota(Type, ExecutionContext*);
void queryUsageAndQuota(ScriptState*,
V8StorageUsageCallback*,
diff --git a/third_party/blink/renderer/modules/quota/navigator_storage_quota.cc b/third_party/blink/renderer/modules/quota/navigator_storage_quota.cc
index 7a7fe76..d0d70e45 100644
--- a/third_party/blink/renderer/modules/quota/navigator_storage_quota.cc
+++ b/third_party/blink/renderer/modules/quota/navigator_storage_quota.cc
@@ -69,7 +69,7 @@
DeprecatedStorageQuota* NavigatorStorageQuota::webkitTemporaryStorage() const {
if (!temporary_storage_) {
temporary_storage_ = MakeGarbageCollected<DeprecatedStorageQuota>(
- DeprecatedStorageQuota::kTemporary);
+ DeprecatedStorageQuota::kTemporary, GetSupplementable()->DomWindow());
}
return temporary_storage_.Get();
}
@@ -77,15 +77,15 @@
DeprecatedStorageQuota* NavigatorStorageQuota::webkitPersistentStorage() const {
if (!persistent_storage_) {
persistent_storage_ = MakeGarbageCollected<DeprecatedStorageQuota>(
- DeprecatedStorageQuota::kPersistent);
+ DeprecatedStorageQuota::kPersistent, GetSupplementable()->DomWindow());
}
return persistent_storage_.Get();
}
StorageManager* NavigatorStorageQuota::storage() const {
if (!storage_manager_) {
- storage_manager_ = MakeGarbageCollected<StorageManager>(
- GetSupplementable() ? GetSupplementable()->DomWindow() : nullptr);
+ storage_manager_ =
+ MakeGarbageCollected<StorageManager>(GetSupplementable()->DomWindow());
}
return storage_manager_.Get();
}