| 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 2f035a201a6dd6e53b3f691d8f07dbd57a52a8e3..76204c509759f29a99fd5270206735f1b57cfba6 100644
|
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBObjectStore.cpp
|
| @@ -37,8 +37,10 @@
|
| #include "modules/indexeddb/IDBAny.h"
|
| #include "modules/indexeddb/IDBCursorWithValue.h"
|
| #include "modules/indexeddb/IDBDatabase.h"
|
| +#include "modules/indexeddb/IDBDatabaseProxy.h"
|
| #include "modules/indexeddb/IDBKeyPath.h"
|
| #include "modules/indexeddb/IDBTracing.h"
|
| +#include "modules/indexeddb/ResponseHandler.h"
|
| #include "modules/indexeddb/WebIDBCallbacksImpl.h"
|
| #include "platform/SharedBuffer.h"
|
| #include "public/platform/WebBlobInfo.h"
|
| @@ -49,11 +51,10 @@
|
| #include <memory>
|
| #include <v8.h>
|
|
|
| -using blink::WebBlobInfo;
|
| -using blink::WebIDBCallbacks;
|
| -using blink::WebIDBCursor;
|
| -using blink::WebIDBDatabase;
|
| -using blink::WebVector;
|
| +using indexed_db::mojom::blink::CursorDirection;
|
| +using indexed_db::mojom::blink::KeyPtr;
|
| +using indexed_db::mojom::blink::KeyRangePtr;
|
| +using indexed_db::mojom::blink::PutMode;
|
|
|
| namespace blink {
|
|
|
| @@ -114,7 +115,7 @@ IDBRequest* IDBObjectStore::get(ScriptState* scriptState, const ScriptValue& key
|
| }
|
|
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| - backendDB()->get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, false, WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->Get(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, false, ResponseHandler::createGetCallback(request));
|
| return request;
|
| }
|
|
|
| @@ -150,7 +151,7 @@ IDBRequest* IDBObjectStore::getAll(ScriptState* scriptState, const ScriptValue&
|
| }
|
|
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| - backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, maxCount, false, WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->GetAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, maxCount, false);
|
| return request;
|
| }
|
|
|
| @@ -186,7 +187,7 @@ IDBRequest* IDBObjectStore::getAllKeys(ScriptState* scriptState, const ScriptVal
|
| }
|
|
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| - backendDB()->getAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, maxCount, true, WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->GetAll(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, maxCount, true);
|
| return request;
|
| }
|
|
|
| @@ -217,16 +218,16 @@ static void generateIndexKeysForValue(v8::Isolate* isolate, const IDBIndexMetada
|
| IDBRequest* IDBObjectStore::add(ScriptState* scriptState, const ScriptValue& value, const ScriptValue& key, ExceptionState& exceptionState)
|
| {
|
| IDB_TRACE("IDBObjectStore::add");
|
| - return put(scriptState, WebIDBPutModeAddOnly, IDBAny::create(this), value, key, exceptionState);
|
| + return put(scriptState, PutMode::AddOnly, IDBAny::create(this), value, key, exceptionState);
|
| }
|
|
|
| IDBRequest* IDBObjectStore::put(ScriptState* scriptState, const ScriptValue& value, const ScriptValue& key, ExceptionState& exceptionState)
|
| {
|
| IDB_TRACE("IDBObjectStore::put");
|
| - return put(scriptState, WebIDBPutModeAddOrUpdate, IDBAny::create(this), value, key, exceptionState);
|
| + return put(scriptState, PutMode::AddOrUpdate, IDBAny::create(this), value, key, exceptionState);
|
| }
|
|
|
| -IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, const ScriptValue& keyValue, ExceptionState& exceptionState)
|
| +IDBRequest* IDBObjectStore::put(ScriptState* scriptState, PutMode putMode, IDBAny* source, const ScriptValue& value, const ScriptValue& keyValue, ExceptionState& exceptionState)
|
| {
|
| IDBKey* key = keyValue.isUndefined() ? nullptr : ScriptValue::to<IDBKey*>(scriptState->isolate(), keyValue, exceptionState);
|
| if (exceptionState.hadException())
|
| @@ -234,7 +235,7 @@ IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode,
|
| return put(scriptState, putMode, source, value, key, exceptionState);
|
| }
|
|
|
| -IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode, IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptionState)
|
| +IDBRequest* IDBObjectStore::put(ScriptState* scriptState, PutMode putMode, IDBAny* source, const ScriptValue& value, IDBKey* key, ExceptionState& exceptionState)
|
| {
|
| if (isDeleted()) {
|
| exceptionState.throwDOMException(InvalidStateError, IDBDatabase::objectStoreDeletedErrorMessage);
|
| @@ -269,13 +270,13 @@ IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode,
|
| const bool usesInLineKeys = !keyPath.isNull();
|
| const bool hasKeyGenerator = autoIncrement();
|
|
|
| - if (putMode != WebIDBPutModeCursorUpdate && usesInLineKeys && key) {
|
| + if (putMode != PutMode::CursorUpdate && usesInLineKeys && key) {
|
| exceptionState.throwDOMException(DataError, "The object store uses in-line keys and the key parameter was provided.");
|
| return nullptr;
|
| }
|
|
|
| // This test logically belongs in IDBCursor, but must operate on the cloned value.
|
| - if (putMode == WebIDBPutModeCursorUpdate && usesInLineKeys) {
|
| + if (putMode == PutMode::CursorUpdate && usesInLineKeys) {
|
| ASSERT(key);
|
| if (clone.isEmpty())
|
| clone = deserializeScriptValue(scriptState, serializedValue.get(), &blobInfo);
|
| @@ -337,11 +338,14 @@ IDBRequest* IDBObjectStore::put(ScriptState* scriptState, WebIDBPutMode putMode,
|
| }
|
|
|
| IDBRequest* request = IDBRequest::create(scriptState, source, m_transaction.get());
|
| - Vector<char> wireBytes;
|
| - serializedValue->toWireBytes(wireBytes);
|
| - RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes);
|
| -
|
| - backendDB()->put(m_transaction->id(), id(), WebData(valueBuffer), blobInfo, key, static_cast<WebIDBPutMode>(putMode), WebIDBCallbacksImpl::create(request).release(), indexIds, indexKeys);
|
| +#if 0
|
| + // Should we be using toWireButes, or instead using Mojo's built-in
|
| + // serialization?
|
| + Vector<int8_t> valueWireBytes;
|
| + serializedValue->toWireBytes(valueWireBytes);
|
| +
|
| + backendDB()->Put(m_transaction->id(), id(), std::move(valueWireBytes), createBlobInfo(blobInfo), createKey(key), putMode, std::move(indexIds), std::move(indexKeys));
|
| +#endif
|
| return request;
|
| }
|
|
|
| @@ -378,7 +382,7 @@ IDBRequest* IDBObjectStore::deleteFunction(ScriptState* scriptState, const Scrip
|
| }
|
|
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| - backendDB()->deleteRange(m_transaction->id(), id(), keyRange, WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->DeleteRange(m_transaction->id(), id(), keyRange);
|
| return request;
|
| }
|
|
|
| @@ -407,7 +411,7 @@ IDBRequest* IDBObjectStore::clear(ScriptState* scriptState, ExceptionState& exce
|
| }
|
|
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| - backendDB()->clear(m_transaction->id(), id(), WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->Clear(m_transaction->id(), id());
|
| return request;
|
| }
|
|
|
| @@ -475,11 +479,11 @@ private:
|
| HeapVector<IDBObjectStore::IndexKeys> indexKeysList;
|
| indexKeysList.append(indexKeys);
|
|
|
| - m_database->backend()->setIndexKeys(m_transactionId, m_objectStoreId, primaryKey, indexIds, indexKeysList);
|
| + m_database->backend()->SetIndexKeys(m_transactionId, m_objectStoreId, primaryKey, indexIds, indexKeysList);
|
| } else {
|
| // Now that we are done indexing, tell the backend to go
|
| // back to processing tasks of type NormalTask.
|
| - m_database->backend()->setIndexesReady(m_transactionId, m_objectStoreId, indexIds);
|
| + m_database->backend()->SetIndexesReady(m_transactionId, m_objectStoreId, indexIds);
|
| m_database.clear();
|
| }
|
|
|
| @@ -493,7 +497,7 @@ private:
|
| };
|
| } // namespace
|
|
|
| -IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& name, const IDBKeyPath& keyPath, const IDBIndexParameters& options, ExceptionState& exceptionState)
|
| +IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& name, const StringOrStringSequence& keyPathSeq, const IDBIndexParameters& options, ExceptionState& exceptionState)
|
| {
|
| IDB_TRACE("IDBObjectStore::createIndex");
|
| if (!m_transaction->isVersionChange()) {
|
| @@ -512,6 +516,7 @@ IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
|
| exceptionState.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
|
| return nullptr;
|
| }
|
| + IDBKeyPath keyPath(keyPathSeq);
|
| if (!keyPath.isValid()) {
|
| exceptionState.throwDOMException(SyntaxError, "The keyPath argument contains an invalid key path.");
|
| return nullptr;
|
| @@ -531,7 +536,7 @@ IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
|
| }
|
|
|
| int64_t indexId = m_metadata.maxIndexId + 1;
|
| - backendDB()->createIndex(m_transaction->id(), id(), indexId, name, keyPath, options.unique(), options.multiEntry());
|
| + backendDB()->CreateIndex(m_transaction->id(), id(), indexId, name, keyPath, options.unique(), options.multiEntry());
|
|
|
| ++m_metadata.maxIndexId;
|
|
|
| @@ -546,7 +551,7 @@ IDBIndex* IDBObjectStore::createIndex(ScriptState* scriptState, const String& na
|
| if (exceptionState.hadException())
|
| return nullptr;
|
|
|
| - IDBRequest* indexRequest = openCursor(scriptState, nullptr, WebIDBCursorDirectionNext, WebIDBTaskTypePreemptive);
|
| + IDBRequest* indexRequest = openCursor(scriptState, nullptr, CursorDirection::Next, indexed_db::mojom::blink::TaskType::Preemptive);
|
| indexRequest->preventPropagation();
|
|
|
| // This is kept alive by being the success handler of the request, which is in turn kept alive by the owning transaction.
|
| @@ -621,7 +626,7 @@ void IDBObjectStore::deleteIndex(const String& name, ExceptionState& exceptionSt
|
| return;
|
| }
|
|
|
| - backendDB()->deleteIndex(m_transaction->id(), id(), indexId);
|
| + backendDB()->DeleteIndex(m_transaction->id(), id(), indexId);
|
|
|
| m_metadata.indexes.remove(indexId);
|
| m_transaction->db()->indexDeleted(id(), indexId);
|
| @@ -648,7 +653,7 @@ IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, const ScriptVal
|
| return nullptr;
|
| }
|
|
|
| - WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionString);
|
| + indexed_db::mojom::blink::CursorDirection direction = IDBCursor::stringToDirection(directionString);
|
| IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecutionContext(), range, exceptionState);
|
| if (exceptionState.hadException())
|
| return nullptr;
|
| @@ -658,15 +663,15 @@ IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, const ScriptVal
|
| return nullptr;
|
| }
|
|
|
| - return openCursor(scriptState, keyRange, direction, WebIDBTaskTypeNormal);
|
| + return openCursor(scriptState, keyRange, direction, indexed_db::mojom::blink::TaskType::Normal);
|
| }
|
|
|
| -IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* range, WebIDBCursorDirection direction, WebIDBTaskType taskType)
|
| +IDBRequest* IDBObjectStore::openCursor(ScriptState* scriptState, IDBKeyRange* range, CursorDirection direction, indexed_db::mojom::blink::TaskType taskType)
|
| {
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
|
|
|
| - backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, direction, false, taskType, WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->OpenCursor(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, range, direction, false, taskType);
|
| return request;
|
| }
|
|
|
| @@ -686,7 +691,7 @@ IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
|
| return nullptr;
|
| }
|
|
|
| - WebIDBCursorDirection direction = IDBCursor::stringToDirection(directionString);
|
| + CursorDirection direction = IDBCursor::stringToDirection(directionString);
|
| IDBKeyRange* keyRange = IDBKeyRange::fromScriptValue(scriptState->getExecutionContext(), range, exceptionState);
|
| if (exceptionState.hadException())
|
| return nullptr;
|
| @@ -699,7 +704,7 @@ IDBRequest* IDBObjectStore::openKeyCursor(ScriptState* scriptState, const Script
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| request->setCursorDetails(IndexedDB::CursorKeyOnly, direction);
|
|
|
| - backendDB()->openCursor(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->OpenCursor(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, direction, true, indexed_db::mojom::blink::TaskType::Normal);
|
| return request;
|
| }
|
|
|
| @@ -729,7 +734,7 @@ IDBRequest* IDBObjectStore::count(ScriptState* scriptState, const ScriptValue& r
|
| }
|
|
|
| IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
|
| - backendDB()->count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange, WebIDBCallbacksImpl::create(request).release());
|
| + backendDB()->Count(m_transaction->id(), id(), IDBIndexMetadata::InvalidId, keyRange);
|
| return request;
|
| }
|
|
|
| @@ -760,7 +765,7 @@ int64_t IDBObjectStore::findIndexId(const String& name) const
|
| return IDBIndexMetadata::InvalidId;
|
| }
|
|
|
| -WebIDBDatabase* IDBObjectStore::backendDB() const
|
| +IDBDatabaseProxy* IDBObjectStore::backendDB() const
|
| {
|
| return m_transaction->backendDB();
|
| }
|
|
|