#include "third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.h"
#include <memory>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/types/expected.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/core/v8/v8_union_string_stringsequence.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_idb_transaction_options.h"
#include "third_party/blink/renderer/core/dom/dom_string_list.h"
#include "third_party/blink/renderer/core/dom/events/native_event_listener.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/core/inspector/inspected_frames.h"
#include "third_party/blink/renderer/core/inspector/v8_inspector_string.h"
#include "third_party/blink/renderer/modules/buckets/storage_bucket.h"
#include "third_party/blink/renderer/modules/buckets/storage_bucket_manager.h"
#include "third_party/blink/renderer/modules/indexed_db_names.h"
#include "third_party/blink/renderer/modules/indexeddb/global_indexed_db.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_cursor.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_cursor_with_value.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_database.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_factory.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_index.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_key.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_key_path.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_metadata.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_object_store.h"
#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/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
Array;
Maybe;
DatabaseWithObjectStores;
DataEntry;
Key;
KeyPath;
KeyRange;
ObjectStore;
ObjectStoreIndex;
RequestDatabaseNamesCallback;
RequestDatabaseCallback;
RequestDataCallback;
DeleteObjectStoreEntriesCallback;
ClearObjectStoreCallback;
GetMetadataCallback;
DeleteDatabaseCallback;
namespace blink {
namespace {
const char kIndexedDBObjectGroup[] = …;
const char kNoDocumentError[] = …;
base::expected<LocalFrame*, protocol::Response> ResolveFrame(
InspectedFrames* inspected_frames,
const protocol::Maybe<String>& security_origin,
const protocol::Maybe<String>& storage_key,
protocol::Maybe<protocol::Storage::StorageBucket>& storage_bucket) { … }
class ExecutableWithIdbFactory
: public GarbageCollected<ExecutableWithIdbFactory> { … };
void OnGotDatabaseNames(
std::unique_ptr<RequestDatabaseNamesCallback> request_callback,
Vector<mojom::blink::IDBNameAndVersionPtr> names_and_versions,
mojom::blink::IDBErrorPtr error) { … }
class DeleteCallback final : public NativeEventListener { … };
template <typename RequestCallback>
class OpenDatabaseCallback;
template <typename RequestCallback>
class UpgradeDatabaseCallback;
template <typename RequestCallback>
class ExecutableWithDatabase
: public RefCounted<ExecutableWithDatabase<RequestCallback>> { … };
template <typename RequestCallback>
class OpenDatabaseCallback final : public NativeEventListener { … };
template <typename RequestCallback>
class UpgradeDatabaseCallback final : public NativeEventListener { … };
IDBTransaction* TransactionForDatabase(
ScriptState* script_state,
IDBDatabase* idb_database,
const String& object_store_name,
const String& mode = indexed_db_names::kReadonly) { … }
IDBObjectStore* ObjectStoreForTransaction(IDBTransaction* idb_transaction,
const String& object_store_name) { … }
IDBIndex* IndexForObjectStore(IDBObjectStore* idb_object_store,
const String& index_name) { … }
std::unique_ptr<KeyPath> KeyPathFromIDBKeyPath(const IDBKeyPath& idb_key_path) { … }
class DatabaseLoader final
: public ExecutableWithDatabase<RequestDatabaseCallback> { … };
static std::unique_ptr<IDBKey> IdbKeyFromInspectorObject(
protocol::IndexedDB::Key* key) { … }
static IDBKeyRange* IdbKeyRangeFromKeyRange(
protocol::IndexedDB::KeyRange* key_range) { … }
class DataLoader;
class OpenCursorCallback final : public NativeEventListener { … };
class DataLoader final : public ExecutableWithDatabase<RequestDataCallback> { … };
}
InspectorIndexedDBAgent::InspectorIndexedDBAgent(
InspectedFrames* inspected_frames,
v8_inspector::V8InspectorSession* v8_session)
: … { … }
InspectorIndexedDBAgent::~InspectorIndexedDBAgent() = default;
void InspectorIndexedDBAgent::Restore() { … }
void InspectorIndexedDBAgent::DidCommitLoadForLocalFrame(LocalFrame* frame) { … }
protocol::Response InspectorIndexedDBAgent::enable() { … }
protocol::Response InspectorIndexedDBAgent::disable() { … }
void InspectorIndexedDBAgent::requestDatabaseNames(
protocol::Maybe<String> security_origin,
protocol::Maybe<String> storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> storage_bucket,
std::unique_ptr<RequestDatabaseNamesCallback> request_callback) { … }
void InspectorIndexedDBAgent::requestDatabase(
protocol::Maybe<String> security_origin,
protocol::Maybe<String> storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> storage_bucket,
const String& database_name,
std::unique_ptr<RequestDatabaseCallback> request_callback) { … }
void InspectorIndexedDBAgent::requestData(
protocol::Maybe<String> security_origin,
protocol::Maybe<String> storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> storage_bucket,
const String& database_name,
const String& object_store_name,
const String& index_name,
int skip_count,
int page_size,
Maybe<protocol::IndexedDB::KeyRange> key_range,
std::unique_ptr<RequestDataCallback> request_callback) { … }
class GetMetadata;
class GetMetadataListener final : public NativeEventListener { … };
class GetMetadata final : public ExecutableWithDatabase<GetMetadataCallback> { … };
void GetMetadataListener::NotifySubtaskDone(scoped_refptr<GetMetadata> owner,
const String& error) const { … }
void InspectorIndexedDBAgent::getMetadata(
protocol::Maybe<String> security_origin,
protocol::Maybe<String> storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> storage_bucket,
const String& database_name,
const String& object_store_name,
std::unique_ptr<GetMetadataCallback> request_callback) { … }
class DeleteObjectStoreEntriesListener final : public NativeEventListener { … };
class DeleteObjectStoreEntries final
: public ExecutableWithDatabase<DeleteObjectStoreEntriesCallback> { … };
void InspectorIndexedDBAgent::deleteObjectStoreEntries(
protocol::Maybe<String> security_origin,
protocol::Maybe<String> storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> storage_bucket,
const String& database_name,
const String& object_store_name,
std::unique_ptr<protocol::IndexedDB::KeyRange> key_range,
std::unique_ptr<DeleteObjectStoreEntriesCallback> request_callback) { … }
class ClearObjectStoreListener final : public NativeEventListener { … };
class ClearObjectStore final
: public ExecutableWithDatabase<ClearObjectStoreCallback> { … };
void InspectorIndexedDBAgent::clearObjectStore(
protocol::Maybe<String> security_origin,
protocol::Maybe<String> storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> storage_bucket,
const String& database_name,
const String& object_store_name,
std::unique_ptr<ClearObjectStoreCallback> request_callback) { … }
void InspectorIndexedDBAgent::deleteDatabase(
protocol::Maybe<String> security_origin,
protocol::Maybe<String> storage_key,
protocol::Maybe<protocol::Storage::StorageBucket> storage_bucket,
const String& database_name,
std::unique_ptr<DeleteDatabaseCallback> request_callback) { … }
void InspectorIndexedDBAgent::Trace(Visitor* visitor) const { … }
}