| Index: third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
|
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
|
| index e799703de7fdd455cf1246e44287fb97eba5a2ee..b4af48b5c2756c817eada2b21b5a4f2e3bff9b7f 100644
|
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
|
| @@ -43,6 +43,7 @@
|
| #include "platform/Histogram.h"
|
| #include "platform/SharedBuffer.h"
|
| #include "platform/bindings/ScriptState.h"
|
| +#include "platform/wtf/PtrUtil.h"
|
| #include "public/platform/WebBlobInfo.h"
|
| #include "public/platform/WebData.h"
|
| #include "public/platform/WebVector.h"
|
| @@ -127,7 +128,9 @@ DOMStringList* IDBObjectStore::indexNames() const {
|
| IDBRequest* IDBObjectStore::get(ScriptState* script_state,
|
| const ScriptValue& key,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::get");
|
| + IDB_TRACE("IDBObjectStore::getCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::get", this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -153,8 +156,9 @@ IDBRequest* IDBObjectStore::get(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| BackendDB()->Get(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId,
|
| key_range, /*key_only=*/false,
|
| request->CreateWebCallbacks().release());
|
| @@ -164,7 +168,9 @@ IDBRequest* IDBObjectStore::get(ScriptState* script_state,
|
| IDBRequest* IDBObjectStore::getKey(ScriptState* script_state,
|
| const ScriptValue& key,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::getKey");
|
| + IDB_TRACE("IDBObjectStore::getKeyCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::getKey", this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -190,8 +196,9 @@ IDBRequest* IDBObjectStore::getKey(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| BackendDB()->Get(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId,
|
| key_range, /*key_only=*/true,
|
| request->CreateWebCallbacks().release());
|
| @@ -209,7 +216,9 @@ IDBRequest* IDBObjectStore::getAll(ScriptState* script_state,
|
| const ScriptValue& key_range,
|
| unsigned long max_count,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::getAll");
|
| + IDB_TRACE("IDBObjectStore::getAllCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::getAll", this);
|
| if (!max_count)
|
| max_count = std::numeric_limits<uint32_t>::max();
|
|
|
| @@ -233,8 +242,9 @@ IDBRequest* IDBObjectStore::getAll(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| BackendDB()->GetAll(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId,
|
| range, max_count, false,
|
| request->CreateWebCallbacks().release());
|
| @@ -252,7 +262,9 @@ IDBRequest* IDBObjectStore::getAllKeys(ScriptState* script_state,
|
| const ScriptValue& key_range,
|
| unsigned long max_count,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::getAll");
|
| + IDB_TRACE("IDBObjectStore::getAllKeysCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::getAllKeys", this);
|
| if (!max_count)
|
| max_count = std::numeric_limits<uint32_t>::max();
|
|
|
| @@ -276,8 +288,9 @@ IDBRequest* IDBObjectStore::getAllKeys(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| BackendDB()->GetAll(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId,
|
| range, max_count, true,
|
| request->CreateWebCallbacks().release());
|
| @@ -323,7 +336,7 @@ IDBRequest* IDBObjectStore::add(ScriptState* script_state,
|
| const ScriptValue& value,
|
| const ScriptValue& key,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::add");
|
| + IDB_TRACE("IDBObjectStore::addCall");
|
| return put(script_state, kWebIDBPutModeAddOnly, IDBAny::Create(this), value,
|
| key, exception_state);
|
| }
|
| @@ -332,7 +345,7 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state,
|
| const ScriptValue& value,
|
| const ScriptValue& key,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::put");
|
| + IDB_TRACE("IDBObjectStore::putCall");
|
| return put(script_state, kWebIDBPutModeAddOrUpdate, IDBAny::Create(this),
|
| value, key, exception_state);
|
| }
|
| @@ -358,6 +371,20 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state,
|
| const ScriptValue& value,
|
| IDBKey* key,
|
| ExceptionState& exception_state) {
|
| + const char* tracing_name = nullptr;
|
| + switch (put_mode) {
|
| + case kWebIDBPutModeAddOrUpdate:
|
| + tracing_name = "IDBObjectStore::put";
|
| + break;
|
| + case kWebIDBPutModeAddOnly:
|
| + tracing_name = "IDBObjectStore::add";
|
| + break;
|
| + case kWebIDBPutModeCursorUpdate:
|
| + tracing_name = "IDBCursor::update";
|
| + break;
|
| + }
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, tracing_name, this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -505,8 +532,8 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state,
|
| index_keys.push_back(keys);
|
| }
|
|
|
| - IDBRequest* request =
|
| - IDBRequest::Create(script_state, source, transaction_.Get());
|
| + IDBRequest* request = IDBRequest::Create(
|
| + script_state, source, transaction_.Get(), std::move(metrics));
|
| Vector<char> wire_bytes;
|
| serialized_value->ToWireBytes(wire_bytes);
|
| RefPtr<SharedBuffer> value_buffer = SharedBuffer::AdoptVector(wire_bytes);
|
| @@ -523,7 +550,9 @@ IDBRequest* IDBObjectStore::put(ScriptState* script_state,
|
| IDBRequest* IDBObjectStore::deleteFunction(ScriptState* script_state,
|
| const ScriptValue& key,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::delete");
|
| + IDB_TRACE("IDBObjectStore::deleteCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::delete", this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -555,8 +584,9 @@ IDBRequest* IDBObjectStore::deleteFunction(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| BackendDB()->DeleteRange(transaction_->Id(), Id(), key_range,
|
| request->CreateWebCallbacks().release());
|
| return request;
|
| @@ -564,7 +594,9 @@ IDBRequest* IDBObjectStore::deleteFunction(ScriptState* script_state,
|
|
|
| IDBRequest* IDBObjectStore::clear(ScriptState* script_state,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::clear");
|
| + IDB_TRACE("IDBObjectStore::clearCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::clear", this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -586,8 +618,9 @@ IDBRequest* IDBObjectStore::clear(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| BackendDB()->Clear(transaction_->Id(), Id(),
|
| request->CreateWebCallbacks().release());
|
| return request;
|
| @@ -695,7 +728,9 @@ IDBIndex* IDBObjectStore::createIndex(ScriptState* script_state,
|
| const IDBKeyPath& key_path,
|
| const IDBIndexParameters& options,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::createIndex");
|
| + IDB_TRACE("IDBObjectStore::createIndexCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::createIndex", this);
|
| if (!transaction_->IsVersionChange()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError,
|
| @@ -753,7 +788,7 @@ IDBIndex* IDBObjectStore::createIndex(ScriptState* script_state,
|
|
|
| IDBRequest* index_request =
|
| openCursor(script_state, nullptr, kWebIDBCursorDirectionNext,
|
| - kWebIDBTaskTypePreemptive);
|
| + kWebIDBTaskTypePreemptive, std::move(metrics));
|
| index_request->PreventPropagation();
|
|
|
| // This is kept alive by being the success handler of the request, which is in
|
| @@ -845,7 +880,9 @@ IDBRequest* IDBObjectStore::openCursor(ScriptState* script_state,
|
| const ScriptValue& range,
|
| const String& direction_string,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::openCursor");
|
| + IDB_TRACE("IDBObjectStore::openCursorCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::openCursor", this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -870,15 +907,19 @@ IDBRequest* IDBObjectStore::openCursor(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - return openCursor(script_state, key_range, direction, kWebIDBTaskTypeNormal);
|
| + return openCursor(script_state, key_range, direction, kWebIDBTaskTypeNormal,
|
| + std::move(metrics));
|
| }
|
|
|
| -IDBRequest* IDBObjectStore::openCursor(ScriptState* script_state,
|
| - IDBKeyRange* range,
|
| - WebIDBCursorDirection direction,
|
| - WebIDBTaskType task_type) {
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| +IDBRequest* IDBObjectStore::openCursor(
|
| + ScriptState* script_state,
|
| + IDBKeyRange* range,
|
| + WebIDBCursorDirection direction,
|
| + WebIDBTaskType task_type,
|
| + std::unique_ptr<IDBRequest::ScopedMetricsTracker> metrics) {
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| request->SetCursorDetails(IndexedDB::kCursorKeyAndValue, direction);
|
|
|
| BackendDB()->OpenCursor(transaction_->Id(), Id(),
|
| @@ -891,7 +932,9 @@ IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* script_state,
|
| const ScriptValue& range,
|
| const String& direction_string,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::openKeyCursor");
|
| + IDB_TRACE("IDBObjectStore::openKeyCursorCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::openKeyCursor", this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -916,8 +959,9 @@ IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| request->SetCursorDetails(IndexedDB::kCursorKeyOnly, direction);
|
|
|
| BackendDB()->OpenCursor(transaction_->Id(), Id(),
|
| @@ -930,7 +974,9 @@ IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* script_state,
|
| IDBRequest* IDBObjectStore::count(ScriptState* script_state,
|
| const ScriptValue& range,
|
| ExceptionState& exception_state) {
|
| - IDB_TRACE("IDBObjectStore::count");
|
| + IDB_TRACE("IDBObjectStore::countCall");
|
| + auto metrics = WTF::MakeUnique<IDBRequest::ScopedMetricsTracker>(
|
| + nullptr, "IDBObjectStore::count", this);
|
| if (IsDeleted()) {
|
| exception_state.ThrowDOMException(
|
| kInvalidStateError, IDBDatabase::kObjectStoreDeletedErrorMessage);
|
| @@ -953,8 +999,9 @@ IDBRequest* IDBObjectStore::count(ScriptState* script_state,
|
| return nullptr;
|
| }
|
|
|
| - IDBRequest* request = IDBRequest::Create(script_state, IDBAny::Create(this),
|
| - transaction_.Get());
|
| + IDBRequest* request =
|
| + IDBRequest::Create(script_state, IDBAny::Create(this), transaction_.Get(),
|
| + std::move(metrics));
|
| BackendDB()->Count(transaction_->Id(), Id(), IDBIndexMetadata::kInvalidId,
|
| key_range, request->CreateWebCallbacks().release());
|
| return request;
|
|
|