#include "third_party/blink/renderer/modules/indexeddb/idb_request.h"
#include <atomic>
#include <memory>
#include <optional>
#include <utility>
#include "base/debug/stack_trace.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "third_party/blink/public/platform/web_blob_info.h"
#include "third_party/blink/renderer/bindings/core/v8/to_v8_traits.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_binding_for_modules.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_idbcursor_idbindex_idbobjectstore.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_idbindex_idbobjectstore.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/modules/indexed_db_names.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_event_dispatcher.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_factory_client.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_request_queue_item.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_value.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_value_wrapping.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
namespace blink {
namespace {
const char* RequestTypeToName(IDBRequest::TypeForMetrics type) { … }
void RecordHistogram(IDBRequest::TypeForMetrics type,
bool success,
base::TimeDelta duration) { … }
}
IDBRequest::AsyncTraceState::AsyncTraceState(TypeForMetrics type)
: … { … }
void IDBRequest::AsyncTraceState::WillDispatchResult(bool success) { … }
void IDBRequest::AsyncTraceState::RecordAndReset() { … }
IDBRequest::AsyncTraceState::~AsyncTraceState() { … }
IDBRequest* IDBRequest::Create(ScriptState* script_state,
IDBIndex* source,
IDBTransaction* transaction,
IDBRequest::AsyncTraceState metrics) { … }
IDBRequest* IDBRequest::Create(ScriptState* script_state,
IDBObjectStore* source,
IDBTransaction* transaction,
IDBRequest::AsyncTraceState metrics) { … }
IDBRequest* IDBRequest::Create(ScriptState* script_state,
IDBCursor* source,
IDBTransaction* transaction,
IDBRequest::AsyncTraceState metrics) { … }
IDBRequest* IDBRequest::Create(ScriptState* script_state,
const Source* source,
IDBTransaction* transaction,
IDBRequest::AsyncTraceState metrics) { … }
IDBRequest::IDBRequest(ScriptState* script_state,
const Source* source,
IDBTransaction* transaction,
AsyncTraceState metrics)
: … { … }
IDBRequest::~IDBRequest() { … }
void IDBRequest::Trace(Visitor* visitor) const { … }
ScriptValue IDBRequest::result(ScriptState* script_state,
ExceptionState& exception_state) { … }
DOMException* IDBRequest::error(ExceptionState& exception_state) const { … }
const IDBRequest::Source* IDBRequest::source(ScriptState* script_state) const { … }
const String& IDBRequest::readyState() const { … }
void IDBRequest::Abort(bool queue_dispatch) { … }
void IDBRequest::SetCursorDetails(indexed_db::CursorType cursor_type,
mojom::IDBCursorDirection direction) { … }
void IDBRequest::SetPendingCursor(IDBCursor* cursor) { … }
IDBCursor* IDBRequest::GetResultCursor() const { … }
void IDBRequest::SendResultCursorInternal(IDBCursor* cursor,
std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key,
std::unique_ptr<IDBValue> value) { … }
bool IDBRequest::CanStillSendResult() const { … }
void IDBRequest::HandleResponse(std::unique_ptr<IDBKey> key) { … }
void IDBRequest::HandleResponse(int64_t value) { … }
void IDBRequest::HandleResponse() { … }
void IDBRequest::HandleResponse(std::unique_ptr<IDBValue> value) { … }
void IDBRequest::HandleResponseAdvanceCursor(
std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key,
std::unique_ptr<IDBValue> optional_value) { … }
void IDBRequest::OnClear(bool success) { … }
void IDBRequest::OnGetAll(
bool key_only,
mojo::PendingAssociatedReceiver<mojom::blink::IDBDatabaseGetAllResultSink>
receiver) { … }
void IDBRequest::OnDelete(bool success) { … }
void IDBRequest::OnCount(bool success, uint32_t count) { … }
void IDBRequest::OnPut(mojom::blink::IDBTransactionPutResultPtr result) { … }
void IDBRequest::OnGet(mojom::blink::IDBDatabaseGetResultPtr result) { … }
void IDBRequest::OnOpenCursor(
mojom::blink::IDBDatabaseOpenCursorResultPtr result) { … }
void IDBRequest::OnAdvanceCursor(mojom::blink::IDBCursorResultPtr result) { … }
void IDBRequest::OnGotKeyGeneratorCurrentNumber(
int64_t number,
mojom::blink::IDBErrorPtr error) { … }
void IDBRequest::SendError(DOMException* error, bool force) { … }
void IDBRequest::HandleError(mojom::blink::IDBErrorPtr error) { … }
void IDBRequest::SendResultCursor(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor>
pending_remote_cursor,
std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key,
std::unique_ptr<IDBValue> value) { … }
#if DCHECK_IS_ON()
static IDBObjectStore* EffectiveObjectStore(const IDBRequest::Source* source) { … }
#endif
void IDBRequest::SendResult(IDBAny* result) { … }
void IDBRequest::SetResult(IDBAny* result) { … }
void IDBRequest::SendResultValue(std::unique_ptr<IDBValue> value) { … }
void IDBRequest::SendResultAdvanceCursor(std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key,
std::unique_ptr<IDBValue> value) { … }
bool IDBRequest::HasPendingActivity() const { … }
void IDBRequest::ContextDestroyed() { … }
const AtomicString& IDBRequest::InterfaceName() const { … }
ExecutionContext* IDBRequest::GetExecutionContext() const { … }
DispatchEventResult IDBRequest::DispatchEventInternal(Event& event) { … }
void IDBRequest::TransactionDidFinishAndDispatch() { … }
}