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 @@
"push",
"pushsubscriptionchange",
"quicstream",
"quotachange",
"ratechange",
"reading",
"readystatechange",
......
......@@ -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_usage_details.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/frame/frame.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
......@@ -84,8 +85,10 @@ void QueryStorageUsageAndQuotaCallback(
} // namespace
StorageManager::StorageManager(ContextLifecycleNotifier* notifier)
: permission_service_(notifier), quota_host_(notifier) {}
StorageManager::StorageManager(ExecutionContext* execution_context)
: ExecutionContextClient(execution_context),
permission_service_(execution_context),
quota_host_(execution_context) {}
ScriptPromise StorageManager::persist(ScriptState* script_state) {
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
......@@ -160,9 +163,19 @@ ScriptPromise StorageManager::estimate(ScriptState* script_state) {
void StorageManager::Trace(Visitor* visitor) const {
visitor->Trace(permission_service_);
visitor->Trace(quota_host_);
EventTargetWithInlineData::Trace(visitor);
ExecutionContextClient::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(
ExecutionContext* execution_context) {
if (!permission_service_.is_bound()) {
......
......@@ -7,6 +7,8 @@
#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/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/heap/heap.h"
#include "third_party/blink/renderer/platform/mojo/heap_mojo_remote.h"
......@@ -19,11 +21,12 @@ class ScriptPromise;
class ScriptPromiseResolver;
class ScriptState;
class StorageManager final : public ScriptWrappable {
class StorageManager final : public EventTargetWithInlineData,
public ExecutionContextClient {
DEFINE_WRAPPERTYPEINFO();
public:
explicit StorageManager(ContextLifecycleNotifier* notifier);
explicit StorageManager(ExecutionContext*);
ScriptPromise persisted(ScriptState*);
ScriptPromise persist(ScriptState*);
......@@ -32,8 +35,14 @@ class StorageManager final : public ScriptWrappable {
void Trace(Visitor* visitor) const override;
// EventTargetWithInlineData
DEFINE_ATTRIBUTE_EVENT_LISTENER(quotachange, kQuotachange)
const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override;
private:
mojom::blink::PermissionService* GetPermissionService(ExecutionContext*);
void PermissionServiceConnectionError();
void PermissionRequestComplete(ScriptPromiseResolver*,
mojom::blink::PermissionStatus);
......
......@@ -7,9 +7,10 @@
[
SecureContext,
Exposed=(Window,Worker)
] interface StorageManager {
] interface StorageManager : EventTarget {
[CallWith=ScriptState, MeasureAs=DurableStoragePersisted] Promise<boolean> persisted();
[Exposed=Window, CallWith=ScriptState, MeasureAs=DurableStoragePersist] Promise<boolean> persist();
[CallWith=ScriptState, MeasureAs=DurableStorageEstimate] Promise<StorageEstimate> estimate();
};
[RuntimeEnabled=QuotaChange] attribute EventHandler onquotachange;
};
\ No newline at end of file
......@@ -1521,6 +1521,10 @@
origin_trial_feature_name: "QuicTransport",
status: "experimental",
},
{
name: "QuotaChange",
status: "experimental",
},
{
// Enabled when blink::features::kRawClipboard is enabled.
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
PASS window.cached_navigator_serviceWorker.oncontrollerchange is null
PASS window.cached_navigator_serviceWorker.onmessage 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.ondisconnect is null
PASS window.cached_navigator_userActivation.hasBeenActive is false
......
......@@ -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.onmessage 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.ondisconnect is null
PASS window.cached_navigator_userActivation.hasBeenActive is false
......
......@@ -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.onmessage 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.ondisconnect is null
PASS window.cached_navigator_userActivation.hasBeenActive is false
......
......@@ -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.onmessage is newChildWindow.navigator.serviceWorker.onmessage
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.ondisconnect is newChildWindow.navigator.usb.ondisconnect
PASS oldChildWindow.navigator.userActivation.hasBeenActive is newChildWindow.navigator.userActivation.hasBeenActive
......
......@@ -1412,11 +1412,13 @@ interface ServiceWorkerRegistration : EventTarget
method unregister
method update
setter onupdatefound
interface StorageManager
interface StorageManager : EventTarget
attribute @@toStringTag
getter onquotachange
method constructor
method estimate
method persisted
setter onquotachange
interface SubtleCrypto
attribute @@toStringTag
method constructor
......
......@@ -1163,7 +1163,7 @@ interface ServiceWorkerRegistration : EventTarget
method unregister
method update
setter onupdatefound
interface StorageManager
interface StorageManager : EventTarget
attribute @@toStringTag
method constructor
method estimate
......
......@@ -1076,7 +1076,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method unregister
[Worker] method update
[Worker] setter onupdatefound
[Worker] interface StorageManager
[Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag
[Worker] method constructor
[Worker] method estimate
......
......@@ -7066,7 +7066,7 @@ interface StorageEvent : Event
getter url
method constructor
method initStorageEvent
interface StorageManager
interface StorageManager : EventTarget
attribute @@toStringTag
method constructor
method estimate
......
......@@ -1076,7 +1076,7 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] attribute PERSISTENT
[Worker] attribute TEMPORARY
[Worker] method constructor
[Worker] interface StorageManager
[Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag
[Worker] method constructor
[Worker] method estimate
......
......@@ -1395,11 +1395,13 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] method constructor
[Worker] setter onaddsourcebuffer
[Worker] setter onremovesourcebuffer
[Worker] interface StorageManager
[Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag
[Worker] getter onquotachange
[Worker] method constructor
[Worker] method estimate
[Worker] method persisted
[Worker] setter onquotachange
[Worker] interface SubtleCrypto
[Worker] attribute @@toStringTag
[Worker] method constructor
......
......@@ -8216,12 +8216,14 @@ interface StorageEvent : Event
getter url
method constructor
method initStorageEvent
interface StorageManager
interface StorageManager : EventTarget
attribute @@toStringTag
getter onquotachange
method constructor
method estimate
method persist
method persisted
setter onquotachange
interface StylePropertyMap : StylePropertyMapReadOnly
attribute @@toStringTag
method append
......
......@@ -1294,11 +1294,13 @@ Starting worker: resources/global-interface-listing-worker.js
[Worker] attribute PERSISTENT
[Worker] attribute TEMPORARY
[Worker] method constructor
[Worker] interface StorageManager
[Worker] interface StorageManager : EventTarget
[Worker] attribute @@toStringTag
[Worker] getter onquotachange
[Worker] method constructor
[Worker] method estimate
[Worker] method persisted
[Worker] setter onquotachange
[Worker] interface SubtleCrypto
[Worker] attribute @@toStringTag
[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