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(
key_only, callbacks);
}
void DatabaseImpl::GetAll(int64_t transaction_id,
int64_t object_store_id,
int64_t index_id,
const IndexedDBKeyRange& key_range,
bool key_only,
int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback) {
void DatabaseImpl::GetAll(
int64_t transaction_id,
int64_t object_store_id,
int64_t index_id,
const IndexedDBKeyRange& key_range,
bool key_only,
int64_t max_count,
blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!connection_->IsConnected()) {
IndexedDBDatabaseError error(blink::kWebIDBDatabaseExceptionUnknownError,
"Unknown error");
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
scoped_refptr<IndexedDBCallbacks> callbacks(
new IndexedDBCallbacks(dispatcher_host_->AsWeakPtr(), origin_,
std::move(callbacks_info), idb_runner_));
if (!connection_->IsConnected())
return;
}
IndexedDBTransaction* transaction =
connection_->GetTransaction(transaction_id);
if (!transaction) {
IndexedDBDatabaseError error(blink::kWebIDBDatabaseExceptionUnknownError,
"Unknown error");
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
if (!transaction)
return;
}
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::move(callback));
std::move(callbacks));
}
void DatabaseImpl::SetIndexKeys(
......
......@@ -66,7 +66,7 @@ class DatabaseImpl : public blink::mojom::IDBDatabase {
const blink::IndexedDBKeyRange& key_range,
bool key_only,
int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback) override;
blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks) override;
void SetIndexKeys(
int64_t transaction_id,
int64_t object_store_id,
......
......@@ -922,33 +922,24 @@ void IndexedDBDatabase::SendObservations(
}
}
void IndexedDBDatabase::GetAll(
base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
IndexedDBTransaction* transaction,
int64_t object_store_id,
int64_t index_id,
std::unique_ptr<IndexedDBKeyRange> key_range,
bool key_only,
int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback) {
void IndexedDBDatabase::GetAll(IndexedDBTransaction* transaction,
int64_t object_store_id,
int64_t index_id,
std::unique_ptr<IndexedDBKeyRange> key_range,
bool key_only,
int64_t max_count,
scoped_refptr<IndexedDBCallbacks> callbacks) {
DCHECK(transaction);
IDB_TRACE1("IndexedDBDatabase::GetAll", "txn.id", transaction->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())));
if (!ValidateObjectStoreId(object_store_id))
return;
}
transaction->ScheduleTask(base::BindOnce(
&IndexedDBDatabase::GetAllOperation, this, std::move(dispatcher_host),
object_store_id, index_id, std::move(key_range),
&IndexedDBDatabase::GetAllOperation, this, object_store_id, index_id,
std::move(key_range),
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,
......@@ -1098,13 +1089,12 @@ static_assert(blink::mojom::kIDBMaxMessageOverhead <= INT32_MAX,
"kIDBMaxMessageOverhead is more than INT32_MAX");
Status IndexedDBDatabase::GetAllOperation(
base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
int64_t object_store_id,
int64_t index_id,
std::unique_ptr<IndexedDBKeyRange> key_range,
indexed_db::CursorType cursor_type,
int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback,
scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction) {
IDB_TRACE1("IndexedDBDatabase::GetAllOperation", "txn.id", transaction->id());
......@@ -1116,15 +1106,6 @@ Status IndexedDBDatabase::GetAllOperation(
metadata_.object_stores[object_store_id];
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;
......@@ -1158,12 +1139,6 @@ Status IndexedDBDatabase::GetAllOperation(
if (!s.ok()) {
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;
}
......@@ -1172,9 +1147,7 @@ Status IndexedDBDatabase::GetAllOperation(
if (!cursor) {
// Doesn't matter if key or value array here - will be empty array when it
// hits JavaScript.
std::vector<blink::mojom::IDBReturnValuePtr> mojo_found_values;
std::move(callback).Run(blink::mojom::IDBDatabaseGetAllResult::NewValues(
std::move(mojo_found_values)));
callbacks->OnSuccessArray(&found_values);
return s;
}
......@@ -1192,15 +1165,8 @@ Status IndexedDBDatabase::GetAllOperation(
cursor_valid = cursor->FirstSeek(&s);
did_first_seek = true;
}
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())));
if (!s.ok())
return s;
}
if (!cursor_valid)
break;
......@@ -1224,12 +1190,9 @@ Status IndexedDBDatabase::GetAllOperation(
else
response_size += return_value.SizeEstimate();
if (response_size > GetUsableMessageSizeInBytes()) {
IndexedDBDatabaseError error =
callbacks->OnError(
CreateError(blink::kWebIDBDatabaseExceptionUnknownError,
"Maximum IPC message size exceeded.", transaction);
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewErrorResult(
blink::mojom::IDBError::New(error.code(), error.message())));
"Maximum IPC message size exceeded.", transaction));
return s;
}
......@@ -1242,32 +1205,10 @@ Status IndexedDBDatabase::GetAllOperation(
if (cursor_type == indexed_db::CURSOR_KEY_ONLY) {
// 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.
std::move(callback).Run(blink::mojom::IDBDatabaseGetAllResult::NewKey(
IndexedDBKey(std::move(found_keys))));
return s;
}
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;
callbacks->OnSuccess(IndexedDBKey(std::move(found_keys)));
} else {
callbacks->OnSuccessArray(&found_values);
}
std::move(callback).Run(
blink::mojom::IDBDatabaseGetAllResult::NewValues(std::move(mojo_values)));
return s;
}
......
......@@ -161,14 +161,13 @@ class CONTENT_EXPORT IndexedDBDatabase
std::unique_ptr<blink::IndexedDBKeyRange> key_range,
bool key_only,
scoped_refptr<IndexedDBCallbacks> callbacks);
void GetAll(base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
IndexedDBTransaction* transaction,
void GetAll(IndexedDBTransaction* transaction,
int64_t object_store_id,
int64_t index_id,
std::unique_ptr<blink::IndexedDBKeyRange> key_range,
bool key_only,
int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback);
scoped_refptr<IndexedDBCallbacks> callbacks);
void Put(IndexedDBTransaction* transaction,
int64_t object_store_id,
IndexedDBValue* value,
......@@ -249,13 +248,12 @@ class CONTENT_EXPORT IndexedDBDatabase
scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction);
leveldb::Status GetAllOperation(
base::WeakPtr<IndexedDBDispatcherHost> dispatcher_host,
int64_t object_store_id,
int64_t index_id,
std::unique_ptr<blink::IndexedDBKeyRange> key_range,
indexed_db::CursorType cursor_type,
int64_t max_count,
blink::mojom::IDBDatabase::GetAllCallback callback,
scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction);
struct PutOperationParams;
leveldb::Status PutOperation(std::unique_ptr<PutOperationParams> params,
......
......@@ -302,12 +302,6 @@ interface IDBTransaction {
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 {
RenameObjectStore(int64 transaction_id,
int64 object_store_id,
......@@ -336,8 +330,8 @@ interface IDBDatabase {
int64 index_id,
IDBKeyRange key_range,
bool key_only,
int64 max_count)
=> (IDBDatabaseGetAllResult result);
int64 max_count,
associated IDBCallbacks callbacks);
SetIndexKeys(int64 transaction_id,
int64 object_store_id,
IDBKey primary_key,
......
......@@ -106,7 +106,7 @@ class BackendDatabaseWithMockedClose
mojom::blink::IDBKeyRangePtr key_range,
bool key_only,
int64_t max_count,
mojom::blink::IDBDatabase::GetAllCallback callback) override {}
mojom::blink::IDBCallbacksAssociatedPtrInfo callbacks) override {}
void SetIndexKeys(int64_t transaction_id,
int64_t object_store_id,
std::unique_ptr<::blink::IDBKey> primary_key,
......
......@@ -11,7 +11,6 @@
#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_dispatcher.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
......@@ -88,8 +87,7 @@ void WebIDBDatabaseImpl::GetAll(int64_t transaction_id,
const IDBKeyRange* key_range,
int64_t max_count,
bool key_only,
WebIDBCallbacks* callbacks_ptr) {
std::unique_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
WebIDBCallbacks* callbacks) {
IndexedDBDispatcher::ResetCursorPrefetchCaches(transaction_id, nullptr);
mojom::blink::IDBKeyRangePtr key_range_ptr =
......@@ -97,31 +95,7 @@ void WebIDBDatabaseImpl::GetAll(int64_t transaction_id,
callbacks->SetState(nullptr, transaction_id);
database_->GetAll(transaction_id, object_store_id, index_id,
std::move(key_range_ptr), key_only, max_count,
WTF::Bind(&WebIDBDatabaseImpl::GetAllCallback,
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;
}
GetCallbacksProxy(base::WrapUnique(callbacks)));
}
void WebIDBDatabaseImpl::SetIndexKeys(int64_t transaction_id,
......
......@@ -60,8 +60,6 @@ class MODULES_EXPORT WebIDBDatabaseImpl : public WebIDBDatabase {
int64_t max_count,
bool key_only,
WebIDBCallbacks*) override;
void GetAllCallback(std::unique_ptr<WebIDBCallbacks> callbacks,
mojom::blink::IDBDatabaseGetAllResultPtr result);
void SetIndexKeys(int64_t transaction_id,
int64_t object_store_id,
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