Commit 7b9b3dd3 authored by Chase Phillips's avatar Chase Phillips Committed by Commit Bot

Revert "IndexedDB: Convert IDBDatabase.GetAll to native Mojo callback"

This reverts commit 379c0975.

Reason for revert: crbug.com/961487, FindIt detected this CL as causing flake in large-requests-abort.html:
17:54:55.845 50941 [18/20] external/wpt/IndexedDB/large-requests-abort.html failed unexpectedly (test timed out)

Original change's description:
> IndexedDB: Convert IDBDatabase.GetAll to native Mojo callback
> 
> Bug: 717812
> Change-Id: Ide1572f90b9b576af0f0bc53a6c735b3394d9c75
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1534709
> Commit-Queue: Chase Phillips <cmp@chromium.org>
> Reviewed-by: Tom Sepez <tsepez@chromium.org>
> Reviewed-by: Daniel Murphy <dmurph@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#658224}

TBR=cmp@chromium.org,dmurph@chromium.org,tsepez@chromium.org

Change-Id: I625f219b1642a18daa0006b55653a43114539b4f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 717812
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605151Reviewed-by: default avatarChase Phillips <cmp@chromium.org>
Commit-Queue: Chase Phillips <cmp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658384}
parent 12305e46
...@@ -176,38 +176,30 @@ void DatabaseImpl::Get( ...@@ -176,38 +176,30 @@ void DatabaseImpl::Get(
key_only, callbacks); key_only, callbacks);
} }
void DatabaseImpl::GetAll(int64_t transaction_id, void DatabaseImpl::GetAll(
int64_t transaction_id,
int64_t object_store_id, int64_t object_store_id,
int64_t index_id, int64_t index_id,
const IndexedDBKeyRange& key_range, const IndexedDBKeyRange& key_range,
bool key_only, bool key_only,
int64_t max_count, int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback) { blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!connection_->IsConnected()) { scoped_refptr<IndexedDBCallbacks> callbacks(
IndexedDBDatabaseError error(blink::kWebIDBDatabaseExceptionUnknownError, new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_,
"Unknown error"); std::move(callbacks_info), idb_runner_));
std::move(callback).Run( if (!connection_->IsConnected())
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
return; return;
}
IndexedDBTransaction* transaction = IndexedDBTransaction* transaction =
connection_->GetTransaction(transaction_id); connection_->GetTransaction(transaction_id);
if (!transaction) { if (!transaction)
IndexedDBDatabaseError error(blink::kWebIDBDatabaseExceptionUnknownError,
"Unknown error");
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
return; return;
}
connection_->database()->GetAll( connection_->database()->GetAll(
dispatcher_host_->AsWeakPtr(), transaction, object_store_id, index_id, transaction, object_store_id, index_id,
std::make_unique<IndexedDBKeyRange>(key_range), key_only, max_count, std::make_unique<IndexedDBKeyRange>(key_range), key_only, max_count,
std::move(callback)); std::move(callbacks));
} }
void DatabaseImpl::SetIndexKeys( void DatabaseImpl::SetIndexKeys(
......
...@@ -66,7 +66,7 @@ class DatabaseImpl : public blink::mojom::IDBDatabase { ...@@ -66,7 +66,7 @@ class DatabaseImpl : public blink::mojom::IDBDatabase {
const blink::IndexedDBKeyRange& key_range, const blink::IndexedDBKeyRange& key_range,
bool key_only, bool key_only,
int64_t max_count, int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback) override; blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks) override;
void SetIndexKeys( void SetIndexKeys(
int64_t transaction_id, int64_t transaction_id,
int64_t object_store_id, int64_t object_store_id,
......
...@@ -922,33 +922,24 @@ void IndexedDBDatabase::SendObservations( ...@@ -922,33 +922,24 @@ void IndexedDBDatabase::SendObservations(
} }
} }
void IndexedDBDatabase::GetAll( void IndexedDBDatabase::GetAll(IndexedDBTransaction* transaction,
base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
IndexedDBTransaction* transaction,
int64_t object_store_id, int64_t object_store_id,
int64_t index_id, int64_t index_id,
std::unique_ptr<IndexedDBKeyRange> key_range, std::unique_ptr<IndexedDBKeyRange> key_range,
bool key_only, bool key_only,
int64_t max_count, int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback) { scoped_refptr<IndexedDBCallbacks> callbacks) {
DCHECK(transaction); DCHECK(transaction);
IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction->id()); IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction->id());
if (!ValidateObjectStoreId(object_store_id)) { if (!ValidateObjectStoreId(object_store_id))
IndexedDBDatabaseError error =
CreateError(blink::kWebIDBDatabaseExceptionUnknownError,
"Unknown error", transaction);
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
return; return;
}
transaction->ScheduleTask(base::BindOnce( transaction->ScheduleTask(base::BindOnce(
&IndexedDBDatabase::GetAllOperation, this, std::move(dispatcher_host), &IndexedDBDatabase::GetAllOperation, this, object_store_id, index_id,
object_store_id, index_id, std::move(key_range), std::move(key_range),
key_only ? indexed_db::CURSOR_KEY_ONLY : indexed_db::CURSOR_KEY_AND_VALUE, key_only ? indexed_db::CURSOR_KEY_ONLY : indexed_db::CURSOR_KEY_AND_VALUE,
max_count, std::move(callback))); max_count, callbacks));
} }
void IndexedDBDatabase::Get(IndexedDBTransaction* transaction, void IndexedDBDatabase::Get(IndexedDBTransaction* transaction,
...@@ -1098,13 +1089,12 @@ static_assert(blink::mojom::kIDBMaxMessageOverhead <= INT32_MAX, ...@@ -1098,13 +1089,12 @@ static_assert(blink::mojom::kIDBMaxMessageOverhead <= INT32_MAX,
"kIDBMaxMessageOverhead is more than INT32_MAX"); "kIDBMaxMessageOverhead is more than INT32_MAX");
Status IndexedDBDatabase::GetAllOperation( Status IndexedDBDatabase::GetAllOperation(
base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
int64_t object_store_id, int64_t object_store_id,
int64_t index_id, int64_t index_id,
std::unique_ptr<IndexedDBKeyRange> key_range, std::unique_ptr<IndexedDBKeyRange> key_range,
indexed_db::CursorType cursor_type, indexed_db::CursorType cursor_type,
int64_t max_count, int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback, scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction) { IndexedDBTransaction* transaction) {
IDB_TRACE1("IndexedDBDatabase::GetAllOperation", "txn.id", transaction->id()); IDB_TRACE1("IndexedDBDatabase::GetAllOperation", "txn.id", transaction->id());
...@@ -1116,15 +1106,6 @@ Status IndexedDBDatabase::GetAllOperation( ...@@ -1116,15 +1106,6 @@ Status IndexedDBDatabase::GetAllOperation(
metadata_.object_stores[object_store_id]; metadata_.object_stores[object_store_id];
Status s = Status::OK(); Status s = Status::OK();
if (!dispatcher_host) {
IndexedDBDatabaseError error =
CreateError(blink::kWebIDBDatabaseExceptionUnknownError,
"Unknown error", transaction);
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
return s;
}
std::unique_ptr<IndexedDBBackingStore::Cursor> cursor; std::unique_ptr<IndexedDBBackingStore::Cursor> cursor;
...@@ -1158,12 +1139,6 @@ Status IndexedDBDatabase::GetAllOperation( ...@@ -1158,12 +1139,6 @@ Status IndexedDBDatabase::GetAllOperation(
if (!s.ok()) { if (!s.ok()) {
DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString(); DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString();
IndexedDBDatabaseError error =
CreateError(blink::kWebIDBDatabaseExceptionUnknownError,
"Corruption detected, unable to continue", transaction);
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
return s; return s;
} }
...@@ -1172,9 +1147,7 @@ Status IndexedDBDatabase::GetAllOperation( ...@@ -1172,9 +1147,7 @@ Status IndexedDBDatabase::GetAllOperation(
if (!cursor) { if (!cursor) {
// Doesn't matter if key or value array here - will be empty array when it // Doesn't matter if key or value array here - will be empty array when it
// hits JavaScript. // hits JavaScript.
std::vector<blink::mojom::IDBReturnValuePtr> mojo_found_values; callbacks->OnSuccessArray(&found_values);
std::move(callback).Run(blink::mojom::IDBDatabaseGetAllResult::NewValues(
std::move(mojo_found_values)));
return s; return s;
} }
...@@ -1192,15 +1165,8 @@ Status IndexedDBDatabase::GetAllOperation( ...@@ -1192,15 +1165,8 @@ Status IndexedDBDatabase::GetAllOperation(
cursor_valid = cursor->FirstSeek(&s); cursor_valid = cursor->FirstSeek(&s);
did_first_seek = true; did_first_seek = true;
} }
if (!s.ok()) { if (!s.ok())
IndexedDBDatabaseError error =
CreateError(blink::kWebIDBDatabaseExceptionUnknownError,
"Seek failure, unable to continue", transaction);
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
return s; return s;
}
if (!cursor_valid) if (!cursor_valid)
break; break;
...@@ -1224,12 +1190,9 @@ Status IndexedDBDatabase::GetAllOperation( ...@@ -1224,12 +1190,9 @@ Status IndexedDBDatabase::GetAllOperation(
else else
response_size += return_value.SizeEstimate(); response_size += return_value.SizeEstimate();
if (response_size > GetUsableMessageSizeInBytes()) { if (response_size > GetUsableMessageSizeInBytes()) {
IndexedDBDatabaseError error = callbacks->OnError(
CreateError(blink::kWebIDBDatabaseExceptionUnknownError, CreateError(blink::kWebIDBDatabaseExceptionUnknownError,
"Maximum IPC message size exceeded.", transaction); "Maximum IPC message size exceeded.", transaction));
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
return s; return s;
} }
...@@ -1242,32 +1205,10 @@ Status IndexedDBDatabase::GetAllOperation( ...@@ -1242,32 +1205,10 @@ Status IndexedDBDatabase::GetAllOperation(
if (cursor_type == indexed_db::CURSOR_KEY_ONLY) { if (cursor_type == indexed_db::CURSOR_KEY_ONLY) {
// IndexedDBKey already supports an array of values so we can leverage this // IndexedDBKey already supports an array of values so we can leverage this
// to return an array of keys - no need to create our own array of keys. // to return an array of keys - no need to create our own array of keys.
std::move(callback).Run(blink::mojom::IDBDatabaseGetAllResult::NewKey( callbacks->OnSuccess(IndexedDBKey(std::move(found_keys)));
IndexedDBKey(std::move(found_keys)))); } else {
return s; callbacks->OnSuccessArray(&found_values);
}
std::vector<blink::mojom::IDBReturnValuePtr> mojo_values;
mojo_values.reserve(found_values.size());
for (size_t i = 0; i < found_values.size(); ++i) {
mojo_values.push_back(
IndexedDBReturnValue::ConvertReturnValue(&found_values[i]));
}
std::vector<IndexedDBCallbacks::IndexedDBValueBlob> value_blobs;
for (size_t i = 0; i < mojo_values.size(); ++i) {
IndexedDBCallbacks::IndexedDBValueBlob::GetIndexedDBValueBlobs(
&value_blobs, found_values[i].blob_info,
&mojo_values[i]->value->blob_or_file_info);
}
if (!IndexedDBCallbacks::CreateAllBlobs(
dispatcher_host->blob_storage_context(), std::move(value_blobs))) {
return s;
} }
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewValues(std::move(mojo_values)));
return s; return s;
} }
......
...@@ -161,14 +161,13 @@ class CONTENT_EXPORT IndexedDBDatabase ...@@ -161,14 +161,13 @@ class CONTENT_EXPORT IndexedDBDatabase
std::unique_ptr<blink::IndexedDBKeyRange> key_range, std::unique_ptr<blink::IndexedDBKeyRange> key_range,
bool key_only, bool key_only,
scoped_refptr<IndexedDBCallbacks> callbacks); scoped_refptr<IndexedDBCallbacks> callbacks);
void GetAll(base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host, void GetAll(IndexedDBTransaction* transaction,
IndexedDBTransaction* transaction,
int64_t object_store_id, int64_t object_store_id,
int64_t index_id, int64_t index_id,
std::unique_ptr<blink::IndexedDBKeyRange> key_range, std::unique_ptr<blink::IndexedDBKeyRange> key_range,
bool key_only, bool key_only,
int64_t max_count, int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback); scoped_refptr<IndexedDBCallbacks> callbacks);
void Put(IndexedDBTransaction* transaction, void Put(IndexedDBTransaction* transaction,
int64_t object_store_id, int64_t object_store_id,
IndexedDBValue* value, IndexedDBValue* value,
...@@ -249,13 +248,12 @@ class CONTENT_EXPORT IndexedDBDatabase ...@@ -249,13 +248,12 @@ class CONTENT_EXPORT IndexedDBDatabase
scoped_refptr<IndexedDBCallbacks> callbacks, scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction); IndexedDBTransaction* transaction);
leveldb::Status GetAllOperation( leveldb::Status GetAllOperation(
base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
int64_t object_store_id, int64_t object_store_id,
int64_t index_id, int64_t index_id,
std::unique_ptr<blink::IndexedDBKeyRange> key_range, std::unique_ptr<blink::IndexedDBKeyRange> key_range,
indexed_db::CursorType cursor_type, indexed_db::CursorType cursor_type,
int64_t max_count, int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback, scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction); IndexedDBTransaction* transaction);
struct PutOperationParams; struct PutOperationParams;
leveldb::Status PutOperation(std::unique_ptr<PutOperationParams> params, leveldb::Status PutOperation(std::unique_ptr<PutOperationParams> params,
......
...@@ -302,12 +302,6 @@ interface IDBTransaction { ...@@ -302,12 +302,6 @@ interface IDBTransaction {
Commit(int64 num_errors_handled); Commit(int64 num_errors_handled);
}; };
union IDBDatabaseGetAllResult {
IDBError error_result; // |error| is reserved, so call this |error_result|.
IDBKey key;
array<IDBReturnValue> values;
};
interface IDBDatabase { interface IDBDatabase {
RenameObjectStore(int64 transaction_id, RenameObjectStore(int64 transaction_id,
int64 object_store_id, int64 object_store_id,
...@@ -336,8 +330,8 @@ interface IDBDatabase { ...@@ -336,8 +330,8 @@ interface IDBDatabase {
int64 index_id, int64 index_id,
IDBKeyRange key_range, IDBKeyRange key_range,
bool key_only, bool key_only,
int64 max_count) int64 max_count,
=> (IDBDatabaseGetAllResult result); associated IDBCallbacks callbacks);
SetIndexKeys(int64 transaction_id, SetIndexKeys(int64 transaction_id,
int64 object_store_id, int64 object_store_id,
IDBKey primary_key, IDBKey primary_key,
......
...@@ -106,7 +106,7 @@ class BackendDatabaseWithMockedClose ...@@ -106,7 +106,7 @@ class BackendDatabaseWithMockedClose
mojom::blink::IDBKeyRangePtr key_range, mojom::blink::IDBKeyRangePtr key_range,
bool key_only, bool key_only,
int64_t max_count, int64_t max_count,
mojom::blink::IDBDatabase::GetAllCallback callback) override {} mojom::blink::IDBCallbacksAssociatedPtrInfo callbacks) override {}
void SetIndexKeys(int64_t transaction_id, void SetIndexKeys(int64_t transaction_id,
int64_t object_store_id, int64_t object_store_id,
std::unique_ptr<::blink::IDBKey> primary_key, std::unique_ptr<::blink::IDBKey> primary_key,
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h" #include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h"
#include "third_party/blink/renderer/modules/indexeddb/indexed_db_blink_mojom_traits.h" #include "third_party/blink/renderer/modules/indexeddb/indexed_db_blink_mojom_traits.h"
#include "third_party/blink/renderer/modules/indexeddb/indexed_db_dispatcher.h" #include "third_party/blink/renderer/modules/indexeddb/indexed_db_dispatcher.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink { namespace blink {
...@@ -88,8 +87,7 @@ void WebIDBDatabaseImpl::GetAll(int64_t transaction_id, ...@@ -88,8 +87,7 @@ void WebIDBDatabaseImpl::GetAll(int64_t transaction_id,
const IDBKeyRange* key_range, const IDBKeyRange* key_range,
int64_t max_count, int64_t max_count,
bool key_only, bool key_only,
WebIDBCallbacks* callbacks_ptr) { WebIDBCallbacks* callbacks) {
std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
IndexedDBDispatcher::ResetCursorPrefetchCaches(transaction_id, nullptr); IndexedDBDispatcher::ResetCursorPrefetchCaches(transaction_id, nullptr);
mojom::blink::IDBKeyRangePtr key_range_ptr = mojom::blink::IDBKeyRangePtr key_range_ptr =
...@@ -97,31 +95,7 @@ void WebIDBDatabaseImpl::GetAll(int64_t transaction_id, ...@@ -97,31 +95,7 @@ void WebIDBDatabaseImpl::GetAll(int64_t transaction_id,
callbacks->SetState(nullptr, transaction_id); callbacks->SetState(nullptr, transaction_id);
database_->GetAll(transaction_id, object_store_id, index_id, database_->GetAll(transaction_id, object_store_id, index_id,
std::move(key_range_ptr), key_only, max_count, std::move(key_range_ptr), key_only, max_count,
WTF::Bind(&WebIDBDatabaseImpl::GetAllCallback, GetCallbacksProxy(base::WrapUnique(callbacks)));
WTF::Unretained(this), std::move(callbacks)));
}
void WebIDBDatabaseImpl::GetAllCallback(
std::unique_ptr<WebIDBCallbacks> callbacks,
mojom::blink::IDBDatabaseGetAllResultPtr result) {
if (result->is_error_result()) {
callbacks->Error(result->get_error_result()->error_code,
std::move(result->get_error_result()->error_message));
callbacks.reset();
return;
}
if (result->is_key()) {
callbacks->SuccessKey(std::move(result->get_key()));
callbacks.reset();
return;
}
if (result->is_values()) {
callbacks->SuccessArray(std::move(result->get_values()));
callbacks.reset();
return;
}
} }
void WebIDBDatabaseImpl::SetIndexKeys(int64_t transaction_id, void WebIDBDatabaseImpl::SetIndexKeys(int64_t transaction_id,
......
...@@ -60,8 +60,6 @@ class MODULES_EXPORT WebIDBDatabaseImpl : public WebIDBDatabase { ...@@ -60,8 +60,6 @@ class MODULES_EXPORT WebIDBDatabaseImpl : public WebIDBDatabase {
int64_t max_count, int64_t max_count,
bool key_only, bool key_only,
WebIDBCallbacks*) override; WebIDBCallbacks*) override;
void GetAllCallback(std::unique_ptr<WebIDBCallbacks> callbacks,
mojom::blink::IDBDatabaseGetAllResultPtr result);
void SetIndexKeys(int64_t transaction_id, void SetIndexKeys(int64_t transaction_id,
int64_t object_store_id, int64_t object_store_id,
std::unique_ptr<IDBKey> primary_key, std::unique_ptr<IDBKey> primary_key,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment