diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc | 104 |
1 files changed, 56 insertions, 48 deletions
diff --git a/chromium/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc b/chromium/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc index e278a24906d..6c8b3f073f0 100644 --- a/chromium/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc +++ b/chromium/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc @@ -36,6 +36,7 @@ #include "third_party/blink/public/common/indexeddb/web_idb_types.h" #include "third_party/blink/renderer/bindings/core/v8/script_controller.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" +#include "third_party/blink/renderer/bindings/modules/v8/v8_idb_transaction_options.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/dom_string_list.h" #include "third_party/blink/renderer/core/dom/events/native_event_listener.h" @@ -58,7 +59,6 @@ #include "third_party/blink/renderer/modules/indexeddb/idb_open_db_request.h" #include "third_party/blink/renderer/modules/indexeddb/idb_request.h" #include "third_party/blink/renderer/modules/indexeddb/idb_transaction.h" -#include "third_party/blink/renderer/modules/indexeddb/idb_transaction_options.h" #include "third_party/blink/renderer/modules/indexeddb/web_idb_cursor.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" @@ -101,13 +101,13 @@ const char kNoDocumentError[] = "No document for given frame found"; Response AssertIDBFactory(Document* document, IDBFactory*& result) { LocalDOMWindow* dom_window = document->domWindow(); if (!dom_window) - return Response::Error("No IndexedDB factory for given frame found"); + return Response::ServerError("No IndexedDB factory for given frame found"); IDBFactory* idb_factory = GlobalIndexedDB::indexedDB(*dom_window); if (!idb_factory) - return Response::Error("No IndexedDB factory for given frame found"); + return Response::ServerError("No IndexedDB factory for given frame found"); result = idb_factory; - return Response::OK(); + return Response::Success(); } class GetDatabaseNamesCallback final : public NativeEventListener { @@ -121,7 +121,8 @@ class GetDatabaseNamesCallback final : public NativeEventListener { void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kSuccess) { - request_callback_->sendFailure(Response::Error("Unexpected event type.")); + request_callback_->sendFailure( + Response::ServerError("Unexpected event type.")); return; } @@ -129,7 +130,7 @@ class GetDatabaseNamesCallback final : public NativeEventListener { IDBAny* request_result = idb_request->ResultAsAny(); if (request_result->GetType() != IDBAny::kDOMStringListType) { request_callback_->sendFailure( - Response::Error("Unexpected result type.")); + Response::ServerError("Unexpected result type.")); return; } @@ -156,7 +157,7 @@ class DeleteCallback final : public NativeEventListener { void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kSuccess) { request_callback_->sendFailure( - Response::Error("Failed to delete database.")); + Response::ServerError("Failed to delete database.")); return; } request_callback_->sendSuccess(); @@ -182,12 +183,12 @@ class ExecutableWithDatabase void Start(LocalFrame* frame, const String& database_name) { Document* document = frame ? frame->GetDocument() : nullptr; if (!document) { - SendFailure(Response::Error(kNoDocumentError)); + SendFailure(Response::ServerError(kNoDocumentError)); return; } IDBFactory* idb_factory = nullptr; Response response = AssertIDBFactory(document, idb_factory); - if (!response.isSuccess()) { + if (!response.IsSuccess()) { SendFailure(response); return; } @@ -216,7 +217,7 @@ class ExecutableWithDatabase IDBOpenDBRequest* idb_open_db_request = idb_factory->open(script_state, database_name, exception_state); if (exception_state.HadException()) { - SendFailure(Response::Error("Could not open database.")); + SendFailure(Response::ServerError("Could not open database.")); return; } idb_open_db_request->addEventListener(event_type_names::kUpgradeneeded, @@ -250,7 +251,7 @@ class OpenDatabaseCallback final : public NativeEventListener { void Invoke(ExecutionContext* context, Event* event) override { if (event->type() != event_type_names::kSuccess) { executable_with_database_->GetRequestCallback()->sendFailure( - Response::Error("Unexpected event type.")); + Response::ServerError("Unexpected event type.")); return; } @@ -259,7 +260,7 @@ class OpenDatabaseCallback final : public NativeEventListener { IDBAny* request_result = idb_open_db_request->ResultAsAny(); if (request_result->GetType() != IDBAny::kIDBDatabaseType) { executable_with_database_->GetRequestCallback()->sendFailure( - Response::Error("Unexpected result type.")); + Response::ServerError("Unexpected result type.")); return; } @@ -269,7 +270,7 @@ class OpenDatabaseCallback final : public NativeEventListener { idb_database->close(); } - void Trace(blink::Visitor* visitor) override { + void Trace(Visitor* visitor) override { visitor->Trace(script_state_); NativeEventListener::Trace(visitor); } @@ -297,7 +298,7 @@ class UpgradeDatabaseCallback final : public NativeEventListener { void Invoke(ExecutionContext* context, Event* event) override { if (event->type() != event_type_names::kUpgradeneeded) { executable_with_database_->GetRequestCallback()->sendFailure( - Response::Error("Unexpected event type.")); + Response::ServerError("Unexpected event type.")); return; } @@ -309,7 +310,7 @@ class UpgradeDatabaseCallback final : public NativeEventListener { NonThrowableExceptionState exception_state; idb_open_db_request->transaction()->abort(exception_state); executable_with_database_->GetRequestCallback()->sendFailure( - Response::Error("Aborted upgrade.")); + Response::ServerError("Aborted upgrade.")); } private: @@ -537,7 +538,8 @@ class OpenCursorCallback final : public NativeEventListener { void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kSuccess) { - request_callback_->sendFailure(Response::Error("Unexpected event type.")); + request_callback_->sendFailure( + Response::ServerError("Unexpected event type.")); return; } @@ -549,7 +551,7 @@ class OpenCursorCallback final : public NativeEventListener { } if (request_result->GetType() != IDBAny::kIDBCursorWithValueType) { request_callback_->sendFailure( - Response::Error("Unexpected result type.")); + Response::ServerError("Unexpected result type.")); return; } @@ -560,7 +562,7 @@ class OpenCursorCallback final : public NativeEventListener { idb_cursor->advance(skip_count_, exception_state); if (exception_state.HadException()) { request_callback_->sendFailure( - Response::Error("Could not advance cursor.")); + Response::ServerError("Could not advance cursor.")); } skip_count_ = 0; return; @@ -578,11 +580,11 @@ class OpenCursorCallback final : public NativeEventListener { exception_state); if (exception_state.HadException()) { request_callback_->sendFailure( - Response::Error("Could not continue cursor.")); + Response::ServerError("Could not continue cursor.")); return; } - Document* document = To<Document>(ExecutionContext::From(script_state_)); + Document* document = Document::From(ExecutionContext::From(script_state_)); if (!document) return; ScriptState::Scope scope(script_state_); @@ -608,7 +610,7 @@ class OpenCursorCallback final : public NativeEventListener { request_callback_->sendSuccess(std::move(result_), has_more); } - void Trace(blink::Visitor* visitor) override { + void Trace(Visitor* visitor) override { visitor->Trace(script_state_); NativeEventListener::Trace(visitor); } @@ -644,14 +646,14 @@ class DataLoader final : public ExecutableWithDatabase<RequestDataCallback> { TransactionForDatabase(script_state, idb_database, object_store_name_); if (!idb_transaction) { request_callback_->sendFailure( - Response::Error("Could not get transaction")); + Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::Error("Could not get object store")); + Response::ServerError("Could not get object store")); return; } @@ -659,7 +661,8 @@ class DataLoader final : public ExecutableWithDatabase<RequestDataCallback> { if (!index_name_.IsEmpty()) { IDBIndex* idb_index = IndexForObjectStore(idb_object_store, index_name_); if (!idb_index) { - request_callback_->sendFailure(Response::Error("Could not get index")); + request_callback_->sendFailure( + Response::ServerError("Could not get index")); return; } @@ -729,14 +732,14 @@ void InspectorIndexedDBAgent::DidCommitLoadForLocalFrame(LocalFrame* frame) { Response InspectorIndexedDBAgent::enable() { enabled_.Set(true); - return Response::OK(); + return Response::Success(); } Response InspectorIndexedDBAgent::disable() { enabled_.Clear(); v8_session_->releaseObjectGroup( ToV8InspectorStringView(kIndexedDBObjectGroup)); - return Response::OK(); + return Response::Success(); } void InspectorIndexedDBAgent::requestDatabaseNames( @@ -746,12 +749,12 @@ void InspectorIndexedDBAgent::requestDatabaseNames( inspected_frames_->FrameWithSecurityOrigin(security_origin); Document* document = frame ? frame->GetDocument() : nullptr; if (!document) { - request_callback->sendFailure(Response::Error(kNoDocumentError)); + request_callback->sendFailure(Response::ServerError(kNoDocumentError)); return; } IDBFactory* idb_factory = nullptr; Response response = AssertIDBFactory(document, idb_factory); - if (!response.isSuccess()) { + if (!response.IsSuccess()) { request_callback->sendFailure(response); return; } @@ -767,7 +770,7 @@ void InspectorIndexedDBAgent::requestDatabaseNames( idb_factory->GetDatabaseNames(script_state, exception_state); if (exception_state.HadException()) { request_callback->sendFailure( - Response::Error("Could not obtain database names.")); + Response::ServerError("Could not obtain database names.")); return; } idb_request->addEventListener( @@ -802,7 +805,8 @@ void InspectorIndexedDBAgent::requestData( key_range.isJust() ? IdbKeyRangeFromKeyRange(key_range.fromJust()) : nullptr; if (key_range.isJust() && !idb_key_range) { - request_callback->sendFailure(Response::Error("Can not parse key range.")); + request_callback->sendFailure( + Response::ServerError("Can not parse key range.")); return; } @@ -857,7 +861,7 @@ class GetMetadata final : public ExecutableWithDatabase<GetMetadataCallback> { void NotifySubtaskDone(const String& error) { if (!error.IsNull()) { - request_callback_->sendFailure(Response::Error(error)); + request_callback_->sendFailure(Response::ServerError(error.Utf8())); return; } if (--subtask_pending_ == 0) { @@ -881,14 +885,14 @@ class GetMetadata final : public ExecutableWithDatabase<GetMetadataCallback> { indexed_db_names::kReadonly); if (!idb_transaction) { request_callback_->sendFailure( - Response::Error("Could not get transaction")); + Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::Error("Could not get object store")); + Response::ServerError("Could not get object store")); return; } @@ -901,9 +905,10 @@ class GetMetadata final : public ExecutableWithDatabase<GetMetadataCallback> { DCHECK(!exception_state.HadException()); if (exception_state.HadException()) { ExceptionCode ec = exception_state.Code(); - request_callback_->sendFailure(Response::Error( + request_callback_->sendFailure(Response::ServerError( String::Format("Could not count entries in object store '%s': %d", - object_store_name_.Utf8().c_str(), ec))); + object_store_name_.Latin1().c_str(), ec) + .Utf8())); return; } GetMetadataListener* listener_get_entries_count = @@ -964,7 +969,7 @@ class DeleteObjectStoreEntriesListener final : public NativeEventListener { void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kSuccess) { request_callback_->sendFailure( - Response::Error("Failed to delete specified entries")); + Response::ServerError("Failed to delete specified entries")); return; } @@ -1000,14 +1005,14 @@ class DeleteObjectStoreEntries final indexed_db_names::kReadwrite); if (!idb_transaction) { request_callback_->sendFailure( - Response::Error("Could not get transaction")); + Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::Error("Could not get object store")); + Response::ServerError("Could not get object store")); return; } @@ -1038,7 +1043,8 @@ void InspectorIndexedDBAgent::deleteObjectStoreEntries( std::unique_ptr<DeleteObjectStoreEntriesCallback> request_callback) { IDBKeyRange* idb_key_range = IdbKeyRangeFromKeyRange(key_range.get()); if (!idb_key_range) { - request_callback->sendFailure(Response::Error("Can not parse key range")); + request_callback->sendFailure( + Response::ServerError("Can not parse key range")); return; } scoped_refptr<DeleteObjectStoreEntries> delete_object_store_entries = @@ -1058,7 +1064,8 @@ class ClearObjectStoreListener final : public NativeEventListener { void Invoke(ExecutionContext*, Event* event) override { if (event->type() != event_type_names::kComplete) { - request_callback_->sendFailure(Response::Error("Unexpected event type.")); + request_callback_->sendFailure( + Response::ServerError("Unexpected event type.")); return; } @@ -1090,14 +1097,14 @@ class ClearObjectStore final indexed_db_names::kReadwrite); if (!idb_transaction) { request_callback_->sendFailure( - Response::Error("Could not get transaction")); + Response::ServerError("Could not get transaction")); return; } IDBObjectStore* idb_object_store = ObjectStoreForTransaction(idb_transaction, object_store_name_); if (!idb_object_store) { request_callback_->sendFailure( - Response::Error("Could not get object store")); + Response::ServerError("Could not get object store")); return; } @@ -1106,9 +1113,10 @@ class ClearObjectStore final DCHECK(!exception_state.HadException()); if (exception_state.HadException()) { ExceptionCode ec = exception_state.Code(); - request_callback_->sendFailure(Response::Error( + request_callback_->sendFailure(Response::ServerError( String::Format("Could not clear object store '%s': %d", - object_store_name_.Utf8().c_str(), ec))); + object_store_name_.Latin1().c_str(), ec) + .Utf8())); return; } idb_transaction->addEventListener( @@ -1147,12 +1155,12 @@ void InspectorIndexedDBAgent::deleteDatabase( inspected_frames_->FrameWithSecurityOrigin(security_origin); Document* document = frame ? frame->GetDocument() : nullptr; if (!document) { - request_callback->sendFailure(Response::Error(kNoDocumentError)); + request_callback->sendFailure(Response::ServerError(kNoDocumentError)); return; } IDBFactory* idb_factory = nullptr; Response response = AssertIDBFactory(document, idb_factory); - if (!response.isSuccess()) { + if (!response.IsSuccess()) { request_callback->sendFailure(response); return; } @@ -1168,7 +1176,7 @@ void InspectorIndexedDBAgent::deleteDatabase( script_state, database_name, exception_state); if (exception_state.HadException()) { request_callback->sendFailure( - Response::Error("Could not delete database.")); + Response::ServerError("Could not delete database.")); return; } idb_request->addEventListener( @@ -1179,7 +1187,7 @@ void InspectorIndexedDBAgent::deleteDatabase( false); } -void InspectorIndexedDBAgent::Trace(blink::Visitor* visitor) { +void InspectorIndexedDBAgent::Trace(Visitor* visitor) { visitor->Trace(inspected_frames_); InspectorBaseAgent::Trace(visitor); } |