Commit b01eb3f0 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Migrate references of blink::mojom::IDBCursor to new Mojo types

Convert both the implementation and clients in the browser and renderer
processes for the blink.mojom.IDBCursor interface, and
adapt unit tests.

Bug: 955171, 978694
Change-Id: I80027402a0bce5dcf568cbbcb4229385cd9d6ea0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768471
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarChase Phillips <cmp@chromium.org>
Reviewed-by: default avatarOksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692014}
parent 2e7c66a9
...@@ -94,7 +94,7 @@ void DatabaseImpl::RenameObjectStore(int64_t transaction_id, ...@@ -94,7 +94,7 @@ void DatabaseImpl::RenameObjectStore(int64_t transaction_id,
void DatabaseImpl::CreateTransaction( void DatabaseImpl::CreateTransaction(
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction>
pending_receiver, transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
const std::vector<int64_t>& object_store_ids, const std::vector<int64_t>& object_store_ids,
blink::mojom::IDBTransactionMode mode) { blink::mojom::IDBTransactionMode mode) {
...@@ -121,7 +121,7 @@ void DatabaseImpl::CreateTransaction( ...@@ -121,7 +121,7 @@ void DatabaseImpl::CreateTransaction(
connection_->database()->RegisterAndScheduleTransaction(transaction); connection_->database()->RegisterAndScheduleTransaction(transaction);
dispatcher_host_->CreateAndBindTransactionImpl( dispatcher_host_->CreateAndBindTransactionImpl(
std::move(pending_receiver), origin_, transaction->AsWeakPtr()); std::move(transaction_receiver), origin_, transaction->AsWeakPtr());
} }
void DatabaseImpl::Close() { void DatabaseImpl::Close() {
......
...@@ -44,7 +44,7 @@ class DatabaseImpl : public blink::mojom::IDBDatabase { ...@@ -44,7 +44,7 @@ class DatabaseImpl : public blink::mojom::IDBDatabase {
int64_t object_store_id, int64_t object_store_id,
const base::string16& new_name) override; const base::string16& new_name) override;
void CreateTransaction(mojo::PendingAssociatedReceiver< void CreateTransaction(mojo::PendingAssociatedReceiver<
blink::mojom::IDBTransaction> pending_receiver, blink::mojom::IDBTransaction> transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
const std::vector<int64_t>& object_store_ids, const std::vector<int64_t>& object_store_ids,
blink::mojom::IDBTransactionMode mode) override; blink::mojom::IDBTransactionMode mode) override;
......
...@@ -94,7 +94,7 @@ void IndexedDBDispatcherHost::AddDatabaseBinding( ...@@ -94,7 +94,7 @@ void IndexedDBDispatcherHost::AddDatabaseBinding(
database_bindings_.AddBinding(std::move(database), std::move(request)); database_bindings_.AddBinding(std::move(database), std::move(request));
} }
blink::mojom::IDBCursorAssociatedPtrInfo mojo::PendingAssociatedRemote<blink::mojom::IDBCursor>
IndexedDBDispatcherHost::CreateCursorBinding( IndexedDBDispatcherHost::CreateCursorBinding(
const url::Origin& origin, const url::Origin& origin,
std::unique_ptr<IndexedDBCursor> cursor) { std::unique_ptr<IndexedDBCursor> cursor) {
...@@ -102,26 +102,26 @@ IndexedDBDispatcherHost::CreateCursorBinding( ...@@ -102,26 +102,26 @@ IndexedDBDispatcherHost::CreateCursorBinding(
auto cursor_impl = std::make_unique<CursorImpl>(std::move(cursor), origin, auto cursor_impl = std::make_unique<CursorImpl>(std::move(cursor), origin,
this, IDBTaskRunner()); this, IDBTaskRunner());
auto* cursor_impl_ptr = cursor_impl.get(); auto* cursor_impl_ptr = cursor_impl.get();
blink::mojom::IDBCursorAssociatedPtrInfo ptr_info; mojo::PendingAssociatedRemote<blink::mojom::IDBCursor> pending_remote;
mojo::BindingId binding_id = cursor_bindings_.AddBinding( mojo::ReceiverId receiver_id = cursor_receivers_.Add(
std::move(cursor_impl), mojo::MakeRequest(&ptr_info)); std::move(cursor_impl),
pending_remote.InitWithNewEndpointAndPassReceiver());
cursor_impl_ptr->OnRemoveBinding( cursor_impl_ptr->OnRemoveBinding(
base::BindOnce(&IndexedDBDispatcherHost::RemoveCursorBinding, base::BindOnce(&IndexedDBDispatcherHost::RemoveCursorBinding,
weak_factory_.GetWeakPtr(), binding_id)); weak_factory_.GetWeakPtr(), receiver_id));
return ptr_info; return pending_remote;
} }
void IndexedDBDispatcherHost::RemoveCursorBinding(mojo::BindingId binding_id) { void IndexedDBDispatcherHost::RemoveCursorBinding(
cursor_bindings_.RemoveBinding(binding_id); mojo::ReceiverId receiver_id) {
cursor_receivers_.Remove(receiver_id);
} }
void IndexedDBDispatcherHost::AddTransactionBinding( void IndexedDBDispatcherHost::AddTransactionBinding(
std::unique_ptr<blink::mojom::IDBTransaction> transaction, std::unique_ptr<blink::mojom::IDBTransaction> transaction,
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> receiver) {
pending_receiver) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
transaction_receivers_.Add(std::move(transaction), transaction_receivers_.Add(std::move(transaction), std::move(receiver));
std::move(pending_receiver));
} }
void IndexedDBDispatcherHost::RenderProcessExited( void IndexedDBDispatcherHost::RenderProcessExited(
...@@ -170,7 +170,7 @@ void IndexedDBDispatcherHost::Open( ...@@ -170,7 +170,7 @@ void IndexedDBDispatcherHost::Open(
const base::string16& name, const base::string16& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction>
transaction_pending_receiver, transaction_receiver,
int64_t transaction_id) { int64_t transaction_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
...@@ -186,7 +186,7 @@ void IndexedDBDispatcherHost::Open( ...@@ -186,7 +186,7 @@ void IndexedDBDispatcherHost::Open(
auto create_transaction_callback = base::BindOnce( auto create_transaction_callback = base::BindOnce(
&IndexedDBDispatcherHost::CreateAndBindTransactionImpl, AsWeakPtr(), &IndexedDBDispatcherHost::CreateAndBindTransactionImpl, AsWeakPtr(),
std::move(transaction_pending_receiver), context.origin); std::move(transaction_receiver), context.origin);
std::unique_ptr<IndexedDBPendingConnection> connection = std::unique_ptr<IndexedDBPendingConnection> connection =
std::make_unique<IndexedDBPendingConnection>( std::make_unique<IndexedDBPendingConnection>(
std::move(callbacks), std::move(database_callbacks), ipc_process_id_, std::move(callbacks), std::move(database_callbacks), ipc_process_id_,
...@@ -236,20 +236,20 @@ void IndexedDBDispatcherHost::AbortTransactionsForDatabase( ...@@ -236,20 +236,20 @@ void IndexedDBDispatcherHost::AbortTransactionsForDatabase(
void IndexedDBDispatcherHost::CreateAndBindTransactionImpl( void IndexedDBDispatcherHost::CreateAndBindTransactionImpl(
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction>
transaction_pending_receiver, transaction_receiver,
const url::Origin& origin, const url::Origin& origin,
base::WeakPtr<IndexedDBTransaction> transaction) { base::WeakPtr<IndexedDBTransaction> transaction) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto transaction_impl = std::make_unique<TransactionImpl>( auto transaction_impl = std::make_unique<TransactionImpl>(
transaction, origin, this->AsWeakPtr(), IDBTaskRunner()); transaction, origin, this->AsWeakPtr(), IDBTaskRunner());
AddTransactionBinding(std::move(transaction_impl), AddTransactionBinding(std::move(transaction_impl),
std::move(transaction_pending_receiver)); std::move(transaction_receiver));
} }
void IndexedDBDispatcherHost::InvalidateWeakPtrsAndClearBindings() { void IndexedDBDispatcherHost::InvalidateWeakPtrsAndClearBindings() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
weak_factory_.InvalidateWeakPtrs(); weak_factory_.InvalidateWeakPtrs();
cursor_bindings_.CloseAllBindings(); cursor_receivers_.Clear();
database_bindings_.CloseAllBindings(); database_bindings_.CloseAllBindings();
transaction_receivers_.Clear(); transaction_receivers_.Clear();
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host_observer.h" #include "content/public/browser/render_process_host_observer.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/strong_associated_binding_set.h" #include "mojo/public/cpp/bindings/strong_associated_binding_set.h"
#include "mojo/public/cpp/bindings/unique_associated_receiver_set.h" #include "mojo/public/cpp/bindings/unique_associated_receiver_set.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h"
...@@ -57,15 +58,14 @@ class CONTENT_EXPORT IndexedDBDispatcherHost ...@@ -57,15 +58,14 @@ class CONTENT_EXPORT IndexedDBDispatcherHost
void AddDatabaseBinding(std::unique_ptr<blink::mojom::IDBDatabase> database, void AddDatabaseBinding(std::unique_ptr<blink::mojom::IDBDatabase> database,
blink::mojom::IDBDatabaseAssociatedRequest request); blink::mojom::IDBDatabaseAssociatedRequest request);
blink::mojom::IDBCursorAssociatedPtrInfo CreateCursorBinding( mojo::PendingAssociatedRemote<blink::mojom::IDBCursor> CreateCursorBinding(
const url::Origin& origin, const url::Origin& origin,
std::unique_ptr<IndexedDBCursor> cursor); std::unique_ptr<IndexedDBCursor> cursor);
void RemoveCursorBinding(mojo::BindingId binding_id); void RemoveCursorBinding(mojo::ReceiverId receiver_id);
void AddTransactionBinding( void AddTransactionBinding(
std::unique_ptr<blink::mojom::IDBTransaction> transaction, std::unique_ptr<blink::mojom::IDBTransaction> transaction,
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> receiver);
pending_receiver);
// A shortcut for accessing our context. // A shortcut for accessing our context.
IndexedDBContextImpl* context() const { return indexed_db_context_.get(); } IndexedDBContextImpl* context() const { return indexed_db_context_.get(); }
...@@ -81,7 +81,7 @@ class CONTENT_EXPORT IndexedDBDispatcherHost ...@@ -81,7 +81,7 @@ class CONTENT_EXPORT IndexedDBDispatcherHost
void CreateAndBindTransactionImpl( void CreateAndBindTransactionImpl(
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction>
transaction_pending_receiver, transaction_receiver,
const url::Origin& origin, const url::Origin& origin,
base::WeakPtr<IndexedDBTransaction> transaction); base::WeakPtr<IndexedDBTransaction> transaction);
...@@ -110,7 +110,7 @@ class CONTENT_EXPORT IndexedDBDispatcherHost ...@@ -110,7 +110,7 @@ class CONTENT_EXPORT IndexedDBDispatcherHost
const base::string16& name, const base::string16& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction>
transaction_pending_receiver, transaction_receiver,
int64_t transaction_id) override; int64_t transaction_id) override;
void DeleteDatabase( void DeleteDatabase(
blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info, blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info,
...@@ -139,7 +139,7 @@ class CONTENT_EXPORT IndexedDBDispatcherHost ...@@ -139,7 +139,7 @@ class CONTENT_EXPORT IndexedDBDispatcherHost
mojo::BindingSet<blink::mojom::IDBFactory, BindingState> bindings_; mojo::BindingSet<blink::mojom::IDBFactory, BindingState> bindings_;
mojo::StrongAssociatedBindingSet<blink::mojom::IDBDatabase> mojo::StrongAssociatedBindingSet<blink::mojom::IDBDatabase>
database_bindings_; database_bindings_;
mojo::StrongAssociatedBindingSet<blink::mojom::IDBCursor> cursor_bindings_; mojo::UniqueAssociatedReceiverSet<blink::mojom::IDBCursor> cursor_receivers_;
mojo::UniqueAssociatedReceiverSet<blink::mojom::IDBTransaction> mojo::UniqueAssociatedReceiverSet<blink::mojom::IDBTransaction>
transaction_receivers_; transaction_receivers_;
......
...@@ -321,7 +321,7 @@ union IDBDatabaseGetAllResult { ...@@ -321,7 +321,7 @@ union IDBDatabaseGetAllResult {
}; };
struct IDBDatabaseOpenCursorValue { struct IDBDatabaseOpenCursorValue {
associated IDBCursor cursor; pending_associated_remote<IDBCursor> pending_cursor;
IDBKey key; IDBKey key;
IDBKey primary_key; IDBKey primary_key;
IDBValue? value; IDBValue? value;
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <utility> #include <utility>
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h"
#include "third_party/blink/public/platform/interface_provider.h" #include "third_party/blink/public/platform/interface_provider.h"
...@@ -134,7 +135,7 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks { ...@@ -134,7 +135,7 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks {
void SuccessStringList(const Vector<String>&) override { NOTREACHED(); } void SuccessStringList(const Vector<String>&) override { NOTREACHED(); }
void SuccessCursor( void SuccessCursor(
mojom::blink::IDBCursorAssociatedPtrInfo cursor_info, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor,
std::unique_ptr<IDBKey> key, std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key, std::unique_ptr<IDBKey> primary_key,
base::Optional<std::unique_ptr<IDBValue>> optional_value) override { base::Optional<std::unique_ptr<IDBValue>> optional_value) override {
......
...@@ -83,12 +83,11 @@ class BackendDatabaseWithMockedClose ...@@ -83,12 +83,11 @@ class BackendDatabaseWithMockedClose
void RenameObjectStore(int64_t transaction_id, void RenameObjectStore(int64_t transaction_id,
int64_t object_store_id, int64_t object_store_id,
const WTF::String& new_name) override {} const WTF::String& new_name) override {}
void CreateTransaction( void CreateTransaction(mojo::PendingAssociatedReceiver<
mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> mojom::blink::IDBTransaction> transaction_receiver,
transaction_pending_receiver, int64_t transaction_id,
int64_t transaction_id, const WTF::Vector<int64_t>& object_store_ids,
const WTF::Vector<int64_t>& object_store_ids, mojom::blink::IDBTransactionMode mode) override {}
mojom::blink::IDBTransactionMode mode) override {}
MOCK_METHOD0(Close, void()); MOCK_METHOD0(Close, void());
void VersionChangeIgnored() override {} void VersionChangeIgnored() override {}
void AddObserver(int64_t transaction_id, void AddObserver(int64_t transaction_id,
......
...@@ -24,11 +24,11 @@ void MockWebIDBCallbacks::SuccessCursorContinue( ...@@ -24,11 +24,11 @@ void MockWebIDBCallbacks::SuccessCursorContinue(
} }
void MockWebIDBCallbacks::SuccessCursor( void MockWebIDBCallbacks::SuccessCursor(
mojom::blink::IDBCursorAssociatedPtrInfo cursor_info, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor,
std::unique_ptr<IDBKey> key, std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key, std::unique_ptr<IDBKey> primary_key,
base::Optional<std::unique_ptr<IDBValue>> optional_value) { base::Optional<std::unique_ptr<IDBValue>> optional_value) {
DoSuccessCursor(cursor_info, key, primary_key, optional_value); DoSuccessCursor(pending_cursor, key, primary_key, optional_value);
} }
void MockWebIDBCallbacks::SuccessKey(std::unique_ptr<IDBKey> key) { void MockWebIDBCallbacks::SuccessKey(std::unique_ptr<IDBKey> key) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h"
#include "third_party/blink/public/platform/web_blob_info.h" #include "third_party/blink/public/platform/web_blob_info.h"
...@@ -42,13 +43,14 @@ class MockWebIDBCallbacks : public WebIDBCallbacks { ...@@ -42,13 +43,14 @@ class MockWebIDBCallbacks : public WebIDBCallbacks {
MOCK_METHOD1(SuccessStringList, void(const Vector<String>&)); MOCK_METHOD1(SuccessStringList, void(const Vector<String>&));
void SuccessCursor( void SuccessCursor(
mojom::blink::IDBCursorAssociatedPtrInfo cursor_info, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor,
std::unique_ptr<IDBKey> key, std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key, std::unique_ptr<IDBKey> primary_key,
base::Optional<std::unique_ptr<IDBValue>> optional_value) override; base::Optional<std::unique_ptr<IDBValue>> optional_value) override;
MOCK_METHOD4( MOCK_METHOD4(
DoSuccessCursor, DoSuccessCursor,
void(const mojom::blink::IDBCursorAssociatedPtrInfo& cursor_info, void(const mojo::PendingAssociatedRemote<mojom::blink::IDBCursor>&
pending_cursor,
const std::unique_ptr<IDBKey>& key, const std::unique_ptr<IDBKey>& key,
const std::unique_ptr<IDBKey>& primary_key, const std::unique_ptr<IDBKey>& primary_key,
const base::Optional<std::unique_ptr<IDBValue>>& optional_value)); const base::Optional<std::unique_ptr<IDBValue>>& optional_value));
......
...@@ -25,7 +25,7 @@ class MockWebIDBDatabase : public testing::StrictMock<WebIDBDatabase> { ...@@ -25,7 +25,7 @@ class MockWebIDBDatabase : public testing::StrictMock<WebIDBDatabase> {
const String& new_name)); const String& new_name));
MOCK_METHOD4(CreateTransaction, MOCK_METHOD4(CreateTransaction,
void(mojo::PendingAssociatedReceiver< void(mojo::PendingAssociatedReceiver<
mojom::blink::IDBTransaction> pending_receiver, mojom::blink::IDBTransaction> receiver,
int64_t id, int64_t id,
const Vector<int64_t>& scope, const Vector<int64_t>& scope,
mojom::IDBTransactionMode)); mojom::IDBTransactionMode));
......
...@@ -32,7 +32,7 @@ class MockWebIDBFactory : public testing::StrictMock<blink::WebIDBFactory> { ...@@ -32,7 +32,7 @@ class MockWebIDBFactory : public testing::StrictMock<blink::WebIDBFactory> {
void(const WTF::String& name, void(const WTF::String& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction>
transaction_pending_receiver, transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
std::unique_ptr<WebIDBCallbacks>, std::unique_ptr<WebIDBCallbacks>,
std::unique_ptr<WebIDBDatabaseCallbacks>)); std::unique_ptr<WebIDBDatabaseCallbacks>));
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <memory> #include <memory>
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
...@@ -46,7 +47,7 @@ class WebIDBCallbacks : public mojom::blink::IDBCallbacks { ...@@ -46,7 +47,7 @@ class WebIDBCallbacks : public mojom::blink::IDBCallbacks {
virtual void SetState(base::WeakPtr<WebIDBCursorImpl> cursor, virtual void SetState(base::WeakPtr<WebIDBCursorImpl> cursor,
int64_t transaction_id) = 0; int64_t transaction_id) = 0;
virtual void SuccessCursor( virtual void SuccessCursor(
mojom::blink::IDBCursorAssociatedPtrInfo cursor_info, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor,
std::unique_ptr<IDBKey> key, std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key, std::unique_ptr<IDBKey> primary_key,
base::Optional<std::unique_ptr<IDBValue>> optional_value) = 0; base::Optional<std::unique_ptr<IDBValue>> optional_value) = 0;
......
...@@ -146,7 +146,7 @@ void WebIDBCallbacksImpl::SuccessStringList(const Vector<String>& string_list) { ...@@ -146,7 +146,7 @@ void WebIDBCallbacksImpl::SuccessStringList(const Vector<String>& string_list) {
} }
void WebIDBCallbacksImpl::SuccessCursor( void WebIDBCallbacksImpl::SuccessCursor(
mojom::blink::IDBCursorAssociatedPtrInfo cursor_info, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor,
std::unique_ptr<IDBKey> key, std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key, std::unique_ptr<IDBKey> primary_key,
base::Optional<std::unique_ptr<IDBValue>> optional_value) { base::Optional<std::unique_ptr<IDBValue>> optional_value) {
...@@ -154,7 +154,7 @@ void WebIDBCallbacksImpl::SuccessCursor( ...@@ -154,7 +154,7 @@ void WebIDBCallbacksImpl::SuccessCursor(
return; return;
std::unique_ptr<WebIDBCursorImpl> cursor = std::make_unique<WebIDBCursorImpl>( std::unique_ptr<WebIDBCursorImpl> cursor = std::make_unique<WebIDBCursorImpl>(
std::move(cursor_info), transaction_id_, task_runner_); std::move(pending_cursor), transaction_id_, task_runner_);
std::unique_ptr<IDBValue> value; std::unique_ptr<IDBValue> value;
if (optional_value.has_value()) { if (optional_value.has_value()) {
value = std::move(optional_value.value()); value = std::move(optional_value.value());
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <memory> #include <memory>
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h"
#include "third_party/blink/renderer/core/probe/async_task_id.h" #include "third_party/blink/renderer/core/probe/async_task_id.h"
#include "third_party/blink/renderer/modules/indexeddb/web_idb_callbacks.h" #include "third_party/blink/renderer/modules/indexeddb/web_idb_callbacks.h"
...@@ -67,7 +68,7 @@ class WebIDBCallbacksImpl final : public WebIDBCallbacks { ...@@ -67,7 +68,7 @@ class WebIDBCallbacksImpl final : public WebIDBCallbacks {
Vector<mojom::blink::IDBNameAndVersionPtr>) override; Vector<mojom::blink::IDBNameAndVersionPtr>) override;
void SuccessStringList(const Vector<String>&) override; void SuccessStringList(const Vector<String>&) override;
void SuccessCursor( void SuccessCursor(
mojom::blink::IDBCursorAssociatedPtrInfo cursor_info, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor,
std::unique_ptr<IDBKey> key, std::unique_ptr<IDBKey> key,
std::unique_ptr<IDBKey> primary_key, std::unique_ptr<IDBKey> primary_key,
base::Optional<std::unique_ptr<IDBValue>> optional_value) override; base::Optional<std::unique_ptr<IDBValue>> optional_value) override;
......
...@@ -14,12 +14,11 @@ ...@@ -14,12 +14,11 @@
#include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/functional.h"
using blink::mojom::blink::IDBCallbacksAssociatedPtrInfo; using blink::mojom::blink::IDBCallbacksAssociatedPtrInfo;
using blink::mojom::blink::IDBCursorAssociatedPtrInfo;
namespace blink { namespace blink {
WebIDBCursorImpl::WebIDBCursorImpl( WebIDBCursorImpl::WebIDBCursorImpl(
mojom::blink::IDBCursorAssociatedPtrInfo cursor_info, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor,
int64_t transaction_id, int64_t transaction_id,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) scoped_refptr<base::SingleThreadTaskRunner> task_runner)
: transaction_id_(transaction_id), : transaction_id_(transaction_id),
...@@ -28,7 +27,7 @@ WebIDBCursorImpl::WebIDBCursorImpl( ...@@ -28,7 +27,7 @@ WebIDBCursorImpl::WebIDBCursorImpl(
pending_onsuccess_callbacks_(0), pending_onsuccess_callbacks_(0),
prefetch_amount_(kMinPrefetchAmount), prefetch_amount_(kMinPrefetchAmount),
task_runner_(task_runner) { task_runner_(task_runner) {
cursor_.Bind(std::move(cursor_info), std::move(task_runner)); cursor_.Bind(std::move(pending_cursor), std::move(task_runner));
IndexedDBDispatcher::RegisterCursor(this); IndexedDBDispatcher::RegisterCursor(this);
} }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <stdint.h> #include <stdint.h>
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-blink.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_value.h" #include "third_party/blink/renderer/modules/indexeddb/idb_value.h"
#include "third_party/blink/renderer/modules/indexeddb/web_idb_callbacks.h" #include "third_party/blink/renderer/modules/indexeddb/web_idb_callbacks.h"
...@@ -18,9 +20,10 @@ namespace blink { ...@@ -18,9 +20,10 @@ namespace blink {
class MODULES_EXPORT WebIDBCursorImpl : public WebIDBCursor { class MODULES_EXPORT WebIDBCursorImpl : public WebIDBCursor {
public: public:
WebIDBCursorImpl(mojom::blink::IDBCursorAssociatedPtrInfo cursor, WebIDBCursorImpl(
int64_t transaction_id, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor,
scoped_refptr<base::SingleThreadTaskRunner> task_runner); int64_t transaction_id,
scoped_refptr<base::SingleThreadTaskRunner> task_runner);
~WebIDBCursorImpl() override; ~WebIDBCursorImpl() override;
void Advance(uint32_t count, WebIDBCallbacks* callback) override; void Advance(uint32_t count, WebIDBCallbacks* callback) override;
...@@ -65,7 +68,7 @@ class MODULES_EXPORT WebIDBCursorImpl : public WebIDBCursor { ...@@ -65,7 +68,7 @@ class MODULES_EXPORT WebIDBCursorImpl : public WebIDBCursor {
int64_t transaction_id_; int64_t transaction_id_;
mojom::blink::IDBCursorAssociatedPtr cursor_; mojo::AssociatedRemote<mojom::blink::IDBCursor> cursor_;
// Prefetch cache. Keys and values are stored in reverse order so that a // Prefetch cache. Keys and values are stored in reverse order so that a
// cache'd continue can pop a value off of the back and prevent new memory // cache'd continue can pop a value off of the back and prevent new memory
......
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/associated_binding.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h" #include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h" #include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h"
...@@ -25,9 +27,10 @@ namespace { ...@@ -25,9 +27,10 @@ namespace {
class MockCursorImpl : public mojom::blink::IDBCursor { class MockCursorImpl : public mojom::blink::IDBCursor {
public: public:
explicit MockCursorImpl(mojom::blink::IDBCursorAssociatedRequest request) explicit MockCursorImpl(
: binding_(this, std::move(request)) { mojo::PendingAssociatedReceiver<mojom::blink::IDBCursor> pending_receiver)
binding_.set_connection_error_handler(base::BindOnce( : receiver_(this, std::move(pending_receiver)) {
receiver_.set_disconnect_handler(base::BindOnce(
&MockCursorImpl::CursorDestroyed, base::Unretained(this))); &MockCursorImpl::CursorDestroyed, base::Unretained(this)));
} }
...@@ -77,7 +80,7 @@ class MockCursorImpl : public mojom::blink::IDBCursor { ...@@ -77,7 +80,7 @@ class MockCursorImpl : public mojom::blink::IDBCursor {
int continue_calls_ = 0; int continue_calls_ = 0;
bool destroyed_ = false; bool destroyed_ = false;
mojo::AssociatedBinding<IDBCursor> binding_; mojo::AssociatedReceiver<IDBCursor> receiver_;
}; };
class MockContinueCallbacks : public testing::StrictMock<MockWebIDBCallbacks> { class MockContinueCallbacks : public testing::StrictMock<MockWebIDBCallbacks> {
...@@ -110,11 +113,11 @@ class MockContinueCallbacks : public testing::StrictMock<MockWebIDBCallbacks> { ...@@ -110,11 +113,11 @@ class MockContinueCallbacks : public testing::StrictMock<MockWebIDBCallbacks> {
class WebIDBCursorImplTest : public testing::Test { class WebIDBCursorImplTest : public testing::Test {
public: public:
WebIDBCursorImplTest() : null_key_(IDBKey::CreateNone()) { WebIDBCursorImplTest() : null_key_(IDBKey::CreateNone()) {
mojom::blink::IDBCursorAssociatedPtr ptr; mojo::AssociatedRemote<mojom::blink::IDBCursor> remote;
mock_cursor_ = std::make_unique<MockCursorImpl>( mock_cursor_ = std::make_unique<MockCursorImpl>(
mojo::MakeRequestAssociatedWithDedicatedPipe(&ptr)); remote.BindNewEndpointAndPassDedicatedReceiverForTesting());
cursor_ = std::make_unique<WebIDBCursorImpl>( cursor_ = std::make_unique<WebIDBCursorImpl>(
ptr.PassInterface(), 1, remote.Unbind(), 1,
blink::scheduler::GetSingleThreadTaskRunnerForTesting()); blink::scheduler::GetSingleThreadTaskRunnerForTesting());
} }
......
...@@ -49,7 +49,7 @@ class MODULES_EXPORT WebIDBDatabase { ...@@ -49,7 +49,7 @@ class MODULES_EXPORT WebIDBDatabase {
const String& name) = 0; const String& name) = 0;
virtual void CreateTransaction( virtual void CreateTransaction(
mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction>
pending_receiver, transaction_receiver,
int64_t id, int64_t id,
const Vector<int64_t>& scope, const Vector<int64_t>& scope,
mojom::IDBTransactionMode) = 0; mojom::IDBTransactionMode) = 0;
......
...@@ -33,11 +33,11 @@ void WebIDBDatabaseImpl::RenameObjectStore(int64_t transaction_id, ...@@ -33,11 +33,11 @@ void WebIDBDatabaseImpl::RenameObjectStore(int64_t transaction_id,
void WebIDBDatabaseImpl::CreateTransaction( void WebIDBDatabaseImpl::CreateTransaction(
mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction>
pending_receiver, transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
const Vector<int64_t>& object_store_ids, const Vector<int64_t>& object_store_ids,
mojom::IDBTransactionMode mode) { mojom::IDBTransactionMode mode) {
database_->CreateTransaction(std::move(pending_receiver), transaction_id, database_->CreateTransaction(std::move(transaction_receiver), transaction_id,
object_store_ids, mode); object_store_ids, mode);
} }
...@@ -210,7 +210,7 @@ void WebIDBDatabaseImpl::OpenCursorCallback( ...@@ -210,7 +210,7 @@ void WebIDBDatabaseImpl::OpenCursorCallback(
} }
CHECK(result->is_value()); CHECK(result->is_value());
callbacks->SuccessCursor(std::move(result->get_value()->cursor), callbacks->SuccessCursor(std::move(result->get_value()->pending_cursor),
std::move(result->get_value()->key), std::move(result->get_value()->key),
std::move(result->get_value()->primary_key), std::move(result->get_value()->primary_key),
std::move(result->get_value()->value)); std::move(result->get_value()->value));
......
...@@ -29,7 +29,7 @@ class MODULES_EXPORT WebIDBDatabaseImpl : public WebIDBDatabase { ...@@ -29,7 +29,7 @@ class MODULES_EXPORT WebIDBDatabaseImpl : public WebIDBDatabase {
int64_t object_store_id, int64_t object_store_id,
const String& new_name) override; const String& new_name) override;
void CreateTransaction(mojo::PendingAssociatedReceiver< void CreateTransaction(mojo::PendingAssociatedReceiver<
mojom::blink::IDBTransaction> pending_receiver, mojom::blink::IDBTransaction> transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
const Vector<int64_t>& scope, const Vector<int64_t>& scope,
mojom::IDBTransactionMode mode) override; mojom::IDBTransactionMode mode) override;
......
...@@ -51,7 +51,7 @@ class MODULES_EXPORT WebIDBFactory { ...@@ -51,7 +51,7 @@ class MODULES_EXPORT WebIDBFactory {
const WTF::String& name, const WTF::String& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction>
pending_receiver, transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
std::unique_ptr<WebIDBCallbacks>, std::unique_ptr<WebIDBCallbacks>,
std::unique_ptr<WebIDBDatabaseCallbacks>) = 0; std::unique_ptr<WebIDBDatabaseCallbacks>) = 0;
......
...@@ -37,7 +37,7 @@ void WebIDBFactoryImpl::Open( ...@@ -37,7 +37,7 @@ void WebIDBFactoryImpl::Open(
const String& name, const String& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction>
pending_receiver, transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
std::unique_ptr<WebIDBCallbacks> callbacks, std::unique_ptr<WebIDBCallbacks> callbacks,
std::unique_ptr<WebIDBDatabaseCallbacks> database_callbacks) { std::unique_ptr<WebIDBDatabaseCallbacks> database_callbacks) {
...@@ -48,7 +48,8 @@ void WebIDBFactoryImpl::Open( ...@@ -48,7 +48,8 @@ void WebIDBFactoryImpl::Open(
DCHECK(!name.IsNull()); DCHECK(!name.IsNull());
factory_->Open(GetCallbacksProxy(std::move(callbacks)), factory_->Open(GetCallbacksProxy(std::move(callbacks)),
GetDatabaseCallbacksProxy(std::move(database_callbacks_impl)), GetDatabaseCallbacksProxy(std::move(database_callbacks_impl)),
name, version, std::move(pending_receiver), transaction_id); name, version, std::move(transaction_receiver),
transaction_id);
} }
void WebIDBFactoryImpl::DeleteDatabase( void WebIDBFactoryImpl::DeleteDatabase(
......
...@@ -33,7 +33,7 @@ class WebIDBFactoryImpl : public WebIDBFactory { ...@@ -33,7 +33,7 @@ class WebIDBFactoryImpl : public WebIDBFactory {
const WTF::String& name, const WTF::String& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction> mojo::PendingAssociatedReceiver<mojom::blink::IDBTransaction>
pending_receiver, transaction_receiver,
int64_t transaction_id, int64_t transaction_id,
std::unique_ptr<WebIDBCallbacks> callbacks, std::unique_ptr<WebIDBCallbacks> callbacks,
std::unique_ptr<WebIDBDatabaseCallbacks> database_callbacks) override; std::unique_ptr<WebIDBDatabaseCallbacks> database_callbacks) override;
......
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