chromium/third_party/blink/renderer/modules/indexeddb/inspector_indexed_db_agent.cc

/*
 * Copyright (C) 2012 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#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) {}

// Gets the IDBFactory for the given frame and optional storage bucket, and
// passes it to the callback given to Start.
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> {};

}  // namespace

// static
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 {}

}  // namespace blink