Commit c8094898 authored by Staphany Park's avatar Staphany Park Committed by Commit Bot

Storage Service: Add use counters for IndexedDB read/write.

Bug: 1000932
Change-Id: Iec2b4ffc50d8688b3727da7d4cfb8a4a1b22c63e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787340
Commit-Queue: Staphany Park <staphany@chromium.org>
Auto-Submit: Staphany Park <staphany@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693895}
parent 3fa5c3f3
......@@ -2403,6 +2403,8 @@ enum WebFeature {
kDOMStorageWrite = 3020,
kCacheStorageRead = 3021,
kCacheStorageWrite = 3022,
kIndexedDBRead = 3023,
kIndexedDBWrite = 3024,
// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
......
......@@ -26,27 +26,40 @@
// https://w3c.github.io/IndexedDB/#idl-def-IDBCursorDirection
enum IDBCursorDirection {
"next",
"nextunique",
"prev",
"prevunique"
"next",
"nextunique",
"prev",
"prevunique"
};
// https://w3c.github.io/IndexedDB/#idl-def-IDBCursor
[
Exposed=(Window,Worker)
Exposed=(Window,Worker)
] interface IDBCursor {
readonly attribute (IDBObjectStore or IDBIndex) source;
readonly attribute IDBCursorDirection direction;
[CallWith=ScriptState, CachedAttribute=isKeyDirty] readonly attribute any key;
[CallWith=ScriptState, CachedAttribute=isPrimaryKeyDirty] readonly attribute any primaryKey;
[SameObject] readonly attribute IDBRequest request;
[RaisesException] void advance([EnforceRange] unsigned long count);
[CallWith=ScriptState, ImplementedAs=Continue, RaisesException] void continue([DefaultValue=Undefined] optional any key);
[CallWith=ScriptState, RaisesException] void continuePrimaryKey(any key, any primaryKey);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest update(any value);
[NewObject, CallWith=ScriptState, ImplementedAs=Delete, RaisesException] IDBRequest delete();
readonly attribute (IDBObjectStore or IDBIndex) source;
readonly attribute IDBCursorDirection direction;
[CachedAttribute=isKeyDirty, CallWith=ScriptState] readonly attribute any key;
[CachedAttribute=isPrimaryKeyDirty, CallWith=ScriptState]
readonly attribute any primaryKey;
[SameObject] readonly attribute IDBRequest request;
[RaisesException] void advance([EnforceRange] unsigned long count);
[CallWith=ScriptState, ImplementedAs=Continue, RaisesException]
void continue([DefaultValue=Undefined] optional any key);
[CallWith=ScriptState, RaisesException]
void continuePrimaryKey(any key, any primaryKey);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBRequest update(any value);
[
CallWith=ScriptState,
ImplementedAs=Delete,
MeasureAs=IndexedDBWrite,
NewObject,
RaisesException
] IDBRequest delete();
};
......@@ -39,9 +39,12 @@
optional IDBTransactionOptions options);
void close();
[NewObject, RaisesException] IDBObjectStore createObjectStore(DOMString name,
optional IDBObjectStoreParameters options);
[RaisesException] void deleteObjectStore(DOMString name);
[MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBObjectStore createObjectStore(DOMString name,
optional IDBObjectStoreParameters options);
[MeasureAs=IndexedDBWrite, RaisesException]
void deleteObjectStore(DOMString name);
attribute EventHandler onabort;
attribute EventHandler onclose;
......
......@@ -229,6 +229,12 @@ WebIDBFactory* IDBFactory::GetFactory(ExecutionContext* execution_context) {
ScriptPromise IDBFactory::GetDatabaseInfo(ScriptState* script_state,
ExceptionState& exception_state) {
// The BlinkIDL definition for GetDatabaseInfo already has a [MeasureAs]
// attribute, so the kIndexedDBRead use counter for kIndexedDBRead must be
// explicitly updated.
UseCounter::Count(ExecutionContext::From(script_state),
WebFeature::kIndexedDBRead);
auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state);
if (!IsContextValid(ExecutionContext::From(script_state))) {
......
......@@ -26,22 +26,26 @@
// https://w3c.github.io/IndexedDB/#idbfactory
[
Exposed=(Window,Worker)
Exposed=(Window,Worker)
] interface IDBFactory {
[
NewObject,
CallWith=ScriptState,
Measure,
RaisesException
] IDBOpenDBRequest open(DOMString name,
optional [EnforceRange] unsigned long long version);
[NewObject, CallWith=ScriptState, RaisesException] IDBOpenDBRequest deleteDatabase(DOMString name);
[CallWith=ScriptState, RaisesException] short cmp(any first, any second);
[
CallWith=ScriptState,
ImplementedAs=GetDatabaseInfo,
Measure,
RaisesException
] Promise<sequence<IDBDatabaseInfo>> databases();
[
CallWith=ScriptState,
Measure,
NewObject,
RaisesException
] IDBOpenDBRequest open(DOMString name,
optional [EnforceRange] unsigned long long version);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBOpenDBRequest deleteDatabase(DOMString name);
[CallWith=ScriptState, RaisesException] short cmp(any first, any second);
[
CallWith=ScriptState,
ImplementedAs=GetDatabaseInfo,
Measure,
RaisesException
] Promise<sequence<IDBDatabaseInfo>> databases();
};
......@@ -34,26 +34,55 @@
[SameObject] readonly attribute IDBTransaction transaction;
readonly attribute boolean autoIncrement;
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest put(any value, [DefaultValue=Undefined] optional any key);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest add(any value, [DefaultValue=Undefined] optional any key);
[NewObject, CallWith=ScriptState, ImplementedAs=Delete, RaisesException] IDBRequest delete(any key);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest clear();
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest get(any key);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest getKey(any key);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest getAll([DefaultValue=Undefined] optional any query,
optional [EnforceRange] unsigned long count);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest getAllKeys([DefaultValue=Undefined] optional any query,
optional [EnforceRange] unsigned long count);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest count([DefaultValue=Undefined] optional any key);
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest openCursor([DefaultValue=Undefined] optional any range,
optional IDBCursorDirection direction = "next");
[NewObject, CallWith=ScriptState, RaisesException] IDBRequest openKeyCursor([DefaultValue=Undefined] optional any range,
optional IDBCursorDirection direction = "next");
[RaisesException] IDBIndex index(DOMString name);
[NewObject, CallWith=ScriptState, RaisesException] IDBIndex createIndex(DOMString name,
(DOMString or sequence<DOMString>) keyPath,
optional IDBIndexParameters options);
[RaisesException] void deleteIndex(DOMString name);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBRequest put(any value, [DefaultValue=Undefined] optional any key);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBRequest add(any value, [DefaultValue=Undefined] optional any key);
[
CallWith=ScriptState,
ImplementedAs=Delete,
MeasureAs=IndexedDBWrite,
NewObject,
RaisesException
] IDBRequest delete(any key);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBRequest clear();
[CallWith=ScriptState, MeasureAs=IndexedDBRead, NewObject, RaisesException]
IDBRequest get(any key);
[CallWith=ScriptState, MeasureAs=IndexedDBRead, NewObject, RaisesException]
IDBRequest getKey(any key);
[CallWith=ScriptState, MeasureAs=IndexedDBRead, NewObject, RaisesException]
IDBRequest getAll([DefaultValue=Undefined] optional any query,
optional [EnforceRange] unsigned long count);
[CallWith=ScriptState, MeasureAs=IndexedDBRead, NewObject, RaisesException]
IDBRequest getAllKeys([DefaultValue=Undefined] optional any query,
optional [EnforceRange] unsigned long count);
[CallWith=ScriptState, MeasureAs=IndexedDBRead, NewObject, RaisesException]
IDBRequest count([DefaultValue=Undefined] optional any key);
[CallWith=ScriptState, MeasureAs=IndexedDBRead, NewObject, RaisesException]
IDBRequest openCursor([DefaultValue=Undefined] optional any range,
optional IDBCursorDirection direction = "next");
[CallWith=ScriptState, MeasureAs=IndexedDBRead, NewObject, RaisesException]
IDBRequest openKeyCursor([DefaultValue=Undefined] optional any range,
optional IDBCursorDirection direction = "next");
[MeasureAs=IndexedDBRead, RaisesException] IDBIndex index(DOMString name);
[CallWith=ScriptState, MeasureAs=IndexedDBWrite, NewObject, RaisesException]
IDBIndex createIndex(DOMString name,
(DOMString or sequence<DOMString>) keyPath,
optional IDBIndexParameters options);
[MeasureAs=IndexedDBWrite, RaisesException]
void deleteIndex(DOMString name);
};
......@@ -24589,6 +24589,8 @@ Called by update_net_error_codes.py.-->
<int value="3020" label="DOMStorageWrite"/>
<int value="3021" label="CacheStorageRead"/>
<int value="3022" label="CacheStorageWrite"/>
<int value="3023" label="IndexedDBRead"/>
<int value="3024" label="IndexedDBWrite"/>
</enum>
<enum name="FeaturePolicyAllowlistType">
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