Commit 7980f060 authored by Lexi Stavrakos's avatar Lexi Stavrakos Committed by Commit Bot

Quota: Add quotachange event and make StorageManager inherit from EventTargetWithInlineData.

Bug: 1088004
Change-Id: Ic606b07825aa79be971d8d97a0409573d1aecb0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2242846
Commit-Queue: Lexi Stavrakos <astavrakos@google.com>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Reviewed-by: default avatarDarwin Huang <huangdarwin@chromium.org>
Reviewed-by: default avatarJarryd Goodman <jarrydg@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790163}
parent b15152b2
...@@ -230,6 +230,7 @@ ...@@ -230,6 +230,7 @@
"push", "push",
"pushsubscriptionchange", "pushsubscriptionchange",
"quicstream", "quicstream",
"quotachange",
"ratechange", "ratechange",
"reading", "reading",
"readystatechange", "readystatechange",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_storage_estimate.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_storage_estimate.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_storage_usage_details.h" #include "third_party/blink/renderer/bindings/modules/v8/v8_storage_usage_details.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/frame.h" #include "third_party/blink/renderer/core/frame/frame.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h"
...@@ -84,8 +85,10 @@ void QueryStorageUsageAndQuotaCallback( ...@@ -84,8 +85,10 @@ void QueryStorageUsageAndQuotaCallback(
} // namespace } // namespace
StorageManager::StorageManager(ContextLifecycleNotifier* notifier) StorageManager::StorageManager(ExecutionContext* execution_context)
: permission_service_(notifier), quota_host_(notifier) {} : ExecutionContextClient(execution_context),
permission_service_(execution_context),
quota_host_(execution_context) {}
ScriptPromise StorageManager::persist(ScriptState* script_state) { ScriptPromise StorageManager::persist(ScriptState* script_state) {
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
...@@ -160,9 +163,19 @@ ScriptPromise StorageManager::estimate(ScriptState* script_state) { ...@@ -160,9 +163,19 @@ ScriptPromise StorageManager::estimate(ScriptState* script_state) {
void StorageManager::Trace(Visitor* visitor) const { void StorageManager::Trace(Visitor* visitor) const {
visitor->Trace(permission_service_); visitor->Trace(permission_service_);
visitor->Trace(quota_host_); visitor->Trace(quota_host_);
EventTargetWithInlineData::Trace(visitor);
ExecutionContextClient::Trace(visitor);
ScriptWrappable::Trace(visitor); ScriptWrappable::Trace(visitor);
} }
const AtomicString& StorageManager::InterfaceName() const {
return event_type_names::kQuotachange;
}
ExecutionContext* StorageManager::GetExecutionContext() const {
return ExecutionContextClient::GetExecutionContext();
}
PermissionService* StorageManager::GetPermissionService( PermissionService* StorageManager::GetPermissionService(
ExecutionContext* execution_context) { ExecutionContext* execution_context) {
if (!permission_service_.is_bound()) { if (!permission_service_.is_bound()) {
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "third_party/blink/public/mojom/permissions/permission.mojom-blink.h" #include "third_party/blink/public/mojom/permissions/permission.mojom-blink.h"
#include "third_party/blink/public/mojom/quota/quota_manager_host.mojom-blink.h" #include "third_party/blink/public/mojom/quota/quota_manager_host.mojom-blink.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/platform/bindings/script_wrappable.h" #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h" #include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
...@@ -19,11 +21,12 @@ class ScriptPromise; ...@@ -19,11 +21,12 @@ class ScriptPromise;
class ScriptPromiseResolver; class ScriptPromiseResolver;
class ScriptState; class ScriptState;
class StorageManager final : public ScriptWrappable { class StorageManager final : public EventTargetWithInlineData,
public ExecutionContextClient {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
explicit StorageManager(ContextLifecycleNotifier* notifier); explicit StorageManager(ExecutionContext*);
ScriptPromise persisted(ScriptState*); ScriptPromise persisted(ScriptState*);
ScriptPromise persist(ScriptState*); ScriptPromise persist(ScriptState*);
...@@ -32,8 +35,14 @@ class StorageManager final : public ScriptWrappable { ...@@ -32,8 +35,14 @@ class StorageManager final : public ScriptWrappable {
void Trace(Visitor* visitor) const override; void Trace(Visitor* visitor) const override;
// EventTargetWithInlineData
DEFINE_ATTRIBUTE_EVENT_LISTENER(quotachange, kQuotachange)
const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override;
private: private:
mojom::blink::PermissionService* GetPermissionService(ExecutionContext*); mojom::blink::PermissionService* GetPermissionService(ExecutionContext*);
void PermissionServiceConnectionError(); void PermissionServiceConnectionError();
void PermissionRequestComplete(ScriptPromiseResolver*, void PermissionRequestComplete(ScriptPromiseResolver*,
mojom::blink::PermissionStatus); mojom::blink::PermissionStatus);
......
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
[ [
SecureContext, SecureContext,
Exposed=(Window,Worker) Exposed=(Window,Worker)
] interface StorageManager { ] interface StorageManager : EventTarget {
[CallWith=ScriptState, MeasureAs=DurableStoragePersisted] Promise<boolean> persisted(); [CallWith=ScriptState, MeasureAs=DurableStoragePersisted] Promise<boolean> persisted();
[Exposed=Window, CallWith=ScriptState, MeasureAs=DurableStoragePersist] Promise<boolean> persist(); [Exposed=Window, CallWith=ScriptState, MeasureAs=DurableStoragePersist] Promise<boolean> persist();
[CallWith=ScriptState, MeasureAs=DurableStorageEstimate] Promise<StorageEstimate> estimate(); [CallWith=ScriptState, MeasureAs=DurableStorageEstimate] Promise<StorageEstimate> estimate();
}; [RuntimeEnabled=QuotaChange] attribute EventHandler onquotachange;
};
\ No newline at end of file
...@@ -1521,6 +1521,10 @@ ...@@ -1521,6 +1521,10 @@
origin_trial_feature_name: "QuicTransport", origin_trial_feature_name: "QuicTransport",
status: "experimental", status: "experimental",
}, },
{
name: "QuotaChange",
status: "experimental",
},
{ {
// Enabled when blink::features::kRawClipboard is enabled. // Enabled when blink::features::kRawClipboard is enabled.
name: "RawClipboard", name: "RawClipboard",
......
This is a testharness.js-based test.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface mixin NavigatorID: member names are unique
PASS Navigator includes NavigatorStorage: member names are unique
PASS Navigator includes NavigatorID: member names are unique
PASS Navigator includes NavigatorLanguage: member names are unique
PASS Navigator includes NavigatorOnLine: member names are unique
PASS Navigator includes NavigatorContentUtils: member names are unique
PASS Navigator includes NavigatorCookies: member names are unique
PASS Navigator includes NavigatorPlugins: member names are unique
PASS Navigator includes NavigatorConcurrentHardware: member names are unique
PASS WorkerNavigator includes NavigatorStorage: member names are unique
PASS WorkerNavigator includes NavigatorID: member names are unique
PASS WorkerNavigator includes NavigatorLanguage: member names are unique
PASS WorkerNavigator includes NavigatorOnLine: member names are unique
PASS WorkerNavigator includes NavigatorConcurrentHardware: member names are unique
FAIL StorageManager interface: existence and properties of interface object assert_equals: prototype of self's property "StorageManager" is not Function.prototype expected function "function () { [native code] }" but got function "function EventTarget() { [native code] }"
PASS StorageManager interface object length
PASS StorageManager interface object name
FAIL StorageManager interface: existence and properties of interface prototype object assert_equals: prototype of StorageManager.prototype is not Object.prototype expected object "[object Object]" but got object "[object EventTarget]"
PASS StorageManager interface: existence and properties of interface prototype object's "constructor" property
PASS StorageManager interface: existence and properties of interface prototype object's @@unscopables property
PASS StorageManager interface: operation persisted()
PASS StorageManager interface: operation persist()
PASS StorageManager interface: operation estimate()
PASS StorageManager must be primary interface of navigator.storage
PASS Stringification of navigator.storage
PASS StorageManager interface: navigator.storage must inherit property "persisted()" with the proper type
PASS StorageManager interface: navigator.storage must inherit property "persist()" with the proper type
PASS StorageManager interface: navigator.storage must inherit property "estimate()" with the proper type
PASS Navigator interface: attribute storage
PASS Navigator interface: navigator must inherit property "storage" with the proper type
PASS WorkerNavigator interface: existence and properties of interface object
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS idl_test setup
PASS idl_test validation
PASS Partial interface mixin NavigatorID: member names are unique
PASS Navigator includes NavigatorStorage: member names are unique
PASS Navigator includes NavigatorID: member names are unique
PASS Navigator includes NavigatorLanguage: member names are unique
PASS Navigator includes NavigatorOnLine: member names are unique
PASS Navigator includes NavigatorContentUtils: member names are unique
PASS Navigator includes NavigatorCookies: member names are unique
PASS Navigator includes NavigatorPlugins: member names are unique
PASS Navigator includes NavigatorConcurrentHardware: member names are unique
PASS WorkerNavigator includes NavigatorStorage: member names are unique
PASS WorkerNavigator includes NavigatorID: member names are unique
PASS WorkerNavigator includes NavigatorLanguage: member names are unique
PASS WorkerNavigator includes NavigatorOnLine: member names are unique
PASS WorkerNavigator includes NavigatorConcurrentHardware: member names are unique
FAIL StorageManager interface: existence and properties of interface object assert_equals: prototype of self's property "StorageManager" is not Function.prototype expected function "function () { [native code] }" but got function "function EventTarget() { [native code] }"
PASS StorageManager interface object length
PASS StorageManager interface object name
FAIL StorageManager interface: existence and properties of interface prototype object assert_equals: prototype of StorageManager.prototype is not Object.prototype expected object "[object Object]" but got object "[object EventTarget]"
PASS StorageManager interface: existence and properties of interface prototype object's "constructor" property
PASS StorageManager interface: existence and properties of interface prototype object's @@unscopables property
PASS StorageManager interface: operation persisted()
PASS StorageManager interface: member persist
PASS StorageManager interface: operation estimate()
PASS StorageManager must be primary interface of navigator.storage
PASS Stringification of navigator.storage
PASS StorageManager interface: navigator.storage must inherit property "persisted()" with the proper type
PASS StorageManager interface: navigator.storage must not have property "persist"
PASS StorageManager interface: navigator.storage must inherit property "estimate()" with the proper type
PASS Navigator interface: existence and properties of interface object
PASS WorkerNavigator interface: attribute storage
PASS WorkerNavigator interface: navigator must inherit property "storage" with the proper type
Harness: the test ran to completion.
...@@ -49,6 +49,7 @@ PASS window.cached_navigator_serviceWorker.controller is null ...@@ -49,6 +49,7 @@ PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_navigator_serviceWorker.oncontrollerchange is null PASS window.cached_navigator_serviceWorker.oncontrollerchange is null
PASS window.cached_navigator_serviceWorker.onmessage is null PASS window.cached_navigator_serviceWorker.onmessage is null
PASS window.cached_navigator_serviceWorker.onmessageerror is null PASS window.cached_navigator_serviceWorker.onmessageerror is null
PASS window.cached_navigator_storage.onquotachange is null
PASS window.cached_navigator_usb.onconnect is null PASS window.cached_navigator_usb.onconnect is null
PASS window.cached_navigator_usb.ondisconnect is null PASS window.cached_navigator_usb.ondisconnect is null
PASS window.cached_navigator_userActivation.hasBeenActive is false PASS window.cached_navigator_userActivation.hasBeenActive is false
......
...@@ -49,6 +49,7 @@ PASS window.cached_navigator_serviceWorker.controller is null ...@@ -49,6 +49,7 @@ PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_navigator_serviceWorker.oncontrollerchange is null PASS window.cached_navigator_serviceWorker.oncontrollerchange is null
PASS window.cached_navigator_serviceWorker.onmessage is null PASS window.cached_navigator_serviceWorker.onmessage is null
PASS window.cached_navigator_serviceWorker.onmessageerror is null PASS window.cached_navigator_serviceWorker.onmessageerror is null
PASS window.cached_navigator_storage.onquotachange is null
PASS window.cached_navigator_usb.onconnect is null PASS window.cached_navigator_usb.onconnect is null
PASS window.cached_navigator_usb.ondisconnect is null PASS window.cached_navigator_usb.ondisconnect is null
PASS window.cached_navigator_userActivation.hasBeenActive is false PASS window.cached_navigator_userActivation.hasBeenActive is false
......
...@@ -49,6 +49,7 @@ PASS window.cached_navigator_serviceWorker.controller is null ...@@ -49,6 +49,7 @@ PASS window.cached_navigator_serviceWorker.controller is null
PASS window.cached_navigator_serviceWorker.oncontrollerchange is null PASS window.cached_navigator_serviceWorker.oncontrollerchange is null
PASS window.cached_navigator_serviceWorker.onmessage is null PASS window.cached_navigator_serviceWorker.onmessage is null
PASS window.cached_navigator_serviceWorker.onmessageerror is null PASS window.cached_navigator_serviceWorker.onmessageerror is null
PASS window.cached_navigator_storage.onquotachange is null
PASS window.cached_navigator_usb.onconnect is null PASS window.cached_navigator_usb.onconnect is null
PASS window.cached_navigator_usb.ondisconnect is null PASS window.cached_navigator_usb.ondisconnect is null
PASS window.cached_navigator_userActivation.hasBeenActive is false PASS window.cached_navigator_userActivation.hasBeenActive is false
......
...@@ -56,6 +56,7 @@ PASS oldChildWindow.navigator.serviceWorker.controller is newChildWindow.navigat ...@@ -56,6 +56,7 @@ PASS oldChildWindow.navigator.serviceWorker.controller is newChildWindow.navigat
PASS oldChildWindow.navigator.serviceWorker.oncontrollerchange is newChildWindow.navigator.serviceWorker.oncontrollerchange PASS oldChildWindow.navigator.serviceWorker.oncontrollerchange is newChildWindow.navigator.serviceWorker.oncontrollerchange
PASS oldChildWindow.navigator.serviceWorker.onmessage is newChildWindow.navigator.serviceWorker.onmessage PASS oldChildWindow.navigator.serviceWorker.onmessage is newChildWindow.navigator.serviceWorker.onmessage
PASS oldChildWindow.navigator.serviceWorker.onmessageerror is newChildWindow.navigator.serviceWorker.onmessageerror PASS oldChildWindow.navigator.serviceWorker.onmessageerror is newChildWindow.navigator.serviceWorker.onmessageerror
PASS oldChildWindow.navigator.storage.onquotachange is newChildWindow.navigator.storage.onquotachange
PASS oldChildWindow.navigator.usb.onconnect is newChildWindow.navigator.usb.onconnect PASS oldChildWindow.navigator.usb.onconnect is newChildWindow.navigator.usb.onconnect
PASS oldChildWindow.navigator.usb.ondisconnect is newChildWindow.navigator.usb.ondisconnect PASS oldChildWindow.navigator.usb.ondisconnect is newChildWindow.navigator.usb.ondisconnect
PASS oldChildWindow.navigator.userActivation.hasBeenActive is newChildWindow.navigator.userActivation.hasBeenActive PASS oldChildWindow.navigator.userActivation.hasBeenActive is newChildWindow.navigator.userActivation.hasBeenActive
......
...@@ -1412,11 +1412,13 @@ interface ServiceWorkerRegistration : EventTarget ...@@ -1412,11 +1412,13 @@ interface ServiceWorkerRegistration : EventTarget
method unregister method unregister
method update method update
setter onupdatefound setter onupdatefound
interface StorageManager interface StorageManager : EventTarget
attribute @@toStringTag attribute @@toStringTag
getter onquotachange
method constructor method constructor
method estimate method estimate
method persisted method persisted
setter onquotachange
interface SubtleCrypto interface SubtleCrypto
attribute @@toStringTag attribute @@toStringTag
method constructor method constructor
......
...@@ -1163,7 +1163,7 @@ interface ServiceWorkerRegistration : EventTarget ...@@ -1163,7 +1163,7 @@ interface ServiceWorkerRegistration : EventTarget
method unregister method unregister
method update method update
setter onupdatefound setter onupdatefound
interface StorageManager interface StorageManager : EventTarget
attribute @@toStringTag attribute @@toStringTag
method constructor method constructor
method estimate method estimate
......
...@@ -1076,7 +1076,7 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -1076,7 +1076,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method unregister [Worker] method unregister
[Worker] method update [Worker] method update
[Worker] setter onupdatefound [Worker] setter onupdatefound
[Worker] interface StorageManager [Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
[Worker] method estimate [Worker] method estimate
......
...@@ -7066,7 +7066,7 @@ interface StorageEvent : Event ...@@ -7066,7 +7066,7 @@ interface StorageEvent : Event
getter url getter url
method constructor method constructor
method initStorageEvent method initStorageEvent
interface StorageManager interface StorageManager : EventTarget
attribute @@toStringTag attribute @@toStringTag
method constructor method constructor
method estimate method estimate
......
...@@ -1076,7 +1076,7 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -1076,7 +1076,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] attribute PERSISTENT [Worker] attribute PERSISTENT
[Worker] attribute TEMPORARY [Worker] attribute TEMPORARY
[Worker] method constructor [Worker] method constructor
[Worker] interface StorageManager [Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
[Worker] method estimate [Worker] method estimate
......
...@@ -1395,11 +1395,13 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -1395,11 +1395,13 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method constructor [Worker] method constructor
[Worker] setter onaddsourcebuffer [Worker] setter onaddsourcebuffer
[Worker] setter onremovesourcebuffer [Worker] setter onremovesourcebuffer
[Worker] interface StorageManager [Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] getter onquotachange
[Worker] method constructor [Worker] method constructor
[Worker] method estimate [Worker] method estimate
[Worker] method persisted [Worker] method persisted
[Worker] setter onquotachange
[Worker] interface SubtleCrypto [Worker] interface SubtleCrypto
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
......
...@@ -8216,12 +8216,14 @@ interface StorageEvent : Event ...@@ -8216,12 +8216,14 @@ interface StorageEvent : Event
getter url getter url
method constructor method constructor
method initStorageEvent method initStorageEvent
interface StorageManager interface StorageManager : EventTarget
attribute @@toStringTag attribute @@toStringTag
getter onquotachange
method constructor method constructor
method estimate method estimate
method persist method persist
method persisted method persisted
setter onquotachange
interface StylePropertyMap : StylePropertyMapReadOnly interface StylePropertyMap : StylePropertyMapReadOnly
attribute @@toStringTag attribute @@toStringTag
method append method append
......
...@@ -1294,11 +1294,13 @@ Starting worker: resources/global-interface-listing-worker.js ...@@ -1294,11 +1294,13 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] attribute PERSISTENT [Worker] attribute PERSISTENT
[Worker] attribute TEMPORARY [Worker] attribute TEMPORARY
[Worker] method constructor [Worker] method constructor
[Worker] interface StorageManager [Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] getter onquotachange
[Worker] method constructor [Worker] method constructor
[Worker] method estimate [Worker] method estimate
[Worker] method persisted [Worker] method persisted
[Worker] setter onquotachange
[Worker] interface SubtleCrypto [Worker] interface SubtleCrypto
[Worker] attribute @@toStringTag [Worker] attribute @@toStringTag
[Worker] method constructor [Worker] method constructor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment