Commit 9acc6da4 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

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

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

Bug: 955171, 978694
Change-Id: I7bb92e5f5dc5894e33b3fa63edbf893a52c2af61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1768589
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@{#692018}
parent 3d26f30c
...@@ -21,18 +21,19 @@ namespace content { ...@@ -21,18 +21,19 @@ namespace content {
IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks( IndexedDBDatabaseCallbacks::IndexedDBDatabaseCallbacks(
scoped_refptr<IndexedDBContextImpl> context, scoped_refptr<IndexedDBContextImpl> context,
IDBDatabaseCallbacksAssociatedPtrInfo callbacks_info, mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks>
pending_callbacks,
base::SequencedTaskRunner* idb_runner) base::SequencedTaskRunner* idb_runner)
: indexed_db_context_(std::move(context)) { : indexed_db_context_(std::move(context)) {
DCHECK(idb_runner->RunsTasksInCurrentSequence()); DCHECK(idb_runner->RunsTasksInCurrentSequence());
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!callbacks_info.is_valid()) if (!pending_callbacks.is_valid())
return; return;
callbacks_.Bind(std::move(callbacks_info)); callbacks_.Bind(std::move(pending_callbacks));
// |callbacks_| is owned by |this|, so if |this| is destroyed, then // |callbacks_| is owned by |this|, so if |this| is destroyed, then
// |callbacks_| will also be destroyed. While |callbacks_| is otherwise // |callbacks_| will also be destroyed. While |callbacks_| is otherwise
// alive, |this| will always be valid. // alive, |this| will always be valid.
callbacks_.set_connection_error_handler(base::BindOnce( callbacks_.set_disconnect_handler(base::BindOnce(
&IndexedDBDatabaseCallbacks::OnConnectionError, base::Unretained(this))); &IndexedDBDatabaseCallbacks::OnConnectionError, base::Unretained(this)));
} }
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.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.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h"
namespace content { namespace content {
...@@ -27,7 +29,8 @@ class CONTENT_EXPORT IndexedDBDatabaseCallbacks ...@@ -27,7 +29,8 @@ class CONTENT_EXPORT IndexedDBDatabaseCallbacks
public: public:
IndexedDBDatabaseCallbacks( IndexedDBDatabaseCallbacks(
scoped_refptr<IndexedDBContextImpl> context, scoped_refptr<IndexedDBContextImpl> context,
blink::mojom::IDBDatabaseCallbacksAssociatedPtrInfo callbacks_info, mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks>
pending_callbacks,
base::SequencedTaskRunner* idb_runner); base::SequencedTaskRunner* idb_runner);
virtual void OnForcedClose(); virtual void OnForcedClose();
...@@ -48,7 +51,7 @@ class CONTENT_EXPORT IndexedDBDatabaseCallbacks ...@@ -48,7 +51,7 @@ class CONTENT_EXPORT IndexedDBDatabaseCallbacks
bool complete_ = false; bool complete_ = false;
scoped_refptr<IndexedDBContextImpl> indexed_db_context_; scoped_refptr<IndexedDBContextImpl> indexed_db_context_;
blink::mojom::IDBDatabaseCallbacksAssociatedPtr callbacks_; mojo::AssociatedRemote<blink::mojom::IDBDatabaseCallbacks> callbacks_;
SEQUENCE_CHECKER(sequence_checker_); SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseCallbacks); DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabaseCallbacks);
......
...@@ -102,14 +102,13 @@ IndexedDBDispatcherHost::CreateCursorBinding( ...@@ -102,14 +102,13 @@ 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();
mojo::PendingAssociatedRemote<blink::mojom::IDBCursor> pending_remote; mojo::PendingAssociatedRemote<blink::mojom::IDBCursor> remote;
mojo::ReceiverId receiver_id = cursor_receivers_.Add( mojo::ReceiverId receiver_id = cursor_receivers_.Add(
std::move(cursor_impl), std::move(cursor_impl), remote.InitWithNewEndpointAndPassReceiver());
pending_remote.InitWithNewEndpointAndPassReceiver());
cursor_impl_ptr->OnRemoveBinding( cursor_impl_ptr->OnRemoveBinding(
base::BindOnce(&IndexedDBDispatcherHost::RemoveCursorBinding, base::BindOnce(&IndexedDBDispatcherHost::RemoveCursorBinding,
weak_factory_.GetWeakPtr(), receiver_id)); weak_factory_.GetWeakPtr(), receiver_id));
return pending_remote; return remote;
} }
void IndexedDBDispatcherHost::RemoveCursorBinding( void IndexedDBDispatcherHost::RemoveCursorBinding(
...@@ -166,7 +165,8 @@ void IndexedDBDispatcherHost::GetDatabaseNames( ...@@ -166,7 +165,8 @@ void IndexedDBDispatcherHost::GetDatabaseNames(
void IndexedDBDispatcherHost::Open( void IndexedDBDispatcherHost::Open(
blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info, blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info,
blink::mojom::IDBDatabaseCallbacksAssociatedPtrInfo database_callbacks_info, mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks>
pending_database_callbacks,
const base::string16& name, const base::string16& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction>
...@@ -180,7 +180,7 @@ void IndexedDBDispatcherHost::Open( ...@@ -180,7 +180,7 @@ void IndexedDBDispatcherHost::Open(
std::move(callbacks_info), IDBTaskRunner())); std::move(callbacks_info), IDBTaskRunner()));
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks( scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks(
new IndexedDBDatabaseCallbacks(indexed_db_context_, new IndexedDBDatabaseCallbacks(indexed_db_context_,
std::move(database_callbacks_info), std::move(pending_database_callbacks),
IDBTaskRunner())); IDBTaskRunner()));
base::FilePath indexed_db_path = indexed_db_context_->data_path(); base::FilePath indexed_db_path = indexed_db_context_->data_path();
......
...@@ -105,8 +105,8 @@ class CONTENT_EXPORT IndexedDBDispatcherHost ...@@ -105,8 +105,8 @@ class CONTENT_EXPORT IndexedDBDispatcherHost
void GetDatabaseNames( void GetDatabaseNames(
blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info) override; blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info) override;
void Open(blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info, void Open(blink::mojom::IDBCallbacksAssociatedPtrInfo callbacks_info,
blink::mojom::IDBDatabaseCallbacksAssociatedPtrInfo mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks>
database_callbacks_info, pending_database_callbacks,
const base::string16& name, const base::string16& name,
int64_t version, int64_t version,
mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction> mojo::PendingAssociatedReceiver<blink::mojom::IDBTransaction>
......
...@@ -50,8 +50,6 @@ using blink::mojom::IDBCallbacksAssociatedPtrInfo; ...@@ -50,8 +50,6 @@ using blink::mojom::IDBCallbacksAssociatedPtrInfo;
using blink::mojom::IDBDatabaseAssociatedPtr; using blink::mojom::IDBDatabaseAssociatedPtr;
using blink::mojom::IDBDatabaseAssociatedPtrInfo; using blink::mojom::IDBDatabaseAssociatedPtrInfo;
using blink::mojom::IDBDatabaseAssociatedRequest; using blink::mojom::IDBDatabaseAssociatedRequest;
using blink::mojom::IDBDatabaseCallbacks;
using blink::mojom::IDBDatabaseCallbacksAssociatedPtrInfo;
using blink::mojom::IDBFactory; using blink::mojom::IDBFactory;
using blink::mojom::IDBFactoryPtr; using blink::mojom::IDBFactoryPtr;
using blink::mojom::IDBValue; using blink::mojom::IDBValue;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "content/public/browser/storage_usage_info.h" #include "content/public/browser/storage_usage_info.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "storage/browser/test/mock_quota_manager_proxy.h" #include "storage/browser/test/mock_quota_manager_proxy.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/indexeddb/web_idb_types.h" #include "third_party/blink/public/common/indexeddb/web_idb_types.h"
...@@ -705,8 +706,8 @@ TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) { ...@@ -705,8 +706,8 @@ TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) {
auto callbacks = base::MakeRefCounted<LookingForQuotaErrorMockCallbacks>(); auto callbacks = base::MakeRefCounted<LookingForQuotaErrorMockCallbacks>();
auto dummy_database_callbacks = auto dummy_database_callbacks =
base::MakeRefCounted<IndexedDBDatabaseCallbacks>(nullptr, nullptr, base::MakeRefCounted<IndexedDBDatabaseCallbacks>(
context()->TaskRunner()); nullptr, mojo::NullAssociatedRemote(), context()->TaskRunner());
const Origin origin = Origin::Create(GURL("http://localhost:81")); const Origin origin = Origin::Create(GURL("http://localhost:81"));
const base::string16 name(ASCIIToUTF16("name")); const base::string16 name(ASCIIToUTF16("name"));
auto create_transaction_callback = auto create_transaction_callback =
......
...@@ -5,13 +5,14 @@ ...@@ -5,13 +5,14 @@
#include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" #include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h" #include "content/browser/indexed_db/indexed_db_context_impl.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace content { namespace content {
MockIndexedDBDatabaseCallbacks::MockIndexedDBDatabaseCallbacks() MockIndexedDBDatabaseCallbacks::MockIndexedDBDatabaseCallbacks()
: IndexedDBDatabaseCallbacks(scoped_refptr<IndexedDBContextImpl>(nullptr), : IndexedDBDatabaseCallbacks(scoped_refptr<IndexedDBContextImpl>(nullptr),
nullptr, mojo::NullAssociatedRemote(),
base::SequencedTaskRunnerHandle::Get().get()), base::SequencedTaskRunnerHandle::Get().get()),
abort_called_(false), abort_called_(false),
forced_close_called_(false) {} forced_close_called_(false) {}
......
...@@ -6,15 +6,14 @@ ...@@ -6,15 +6,14 @@
namespace content { namespace content {
MockMojoIndexedDBDatabaseCallbacks::MockMojoIndexedDBDatabaseCallbacks() MockMojoIndexedDBDatabaseCallbacks::MockMojoIndexedDBDatabaseCallbacks() =
: binding_(this) {} default;
MockMojoIndexedDBDatabaseCallbacks::~MockMojoIndexedDBDatabaseCallbacks() {} MockMojoIndexedDBDatabaseCallbacks::~MockMojoIndexedDBDatabaseCallbacks() =
default;
blink::mojom::IDBDatabaseCallbacksAssociatedPtrInfo mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks>
MockMojoIndexedDBDatabaseCallbacks::CreateInterfacePtrAndBind() { MockMojoIndexedDBDatabaseCallbacks::CreateInterfacePtrAndBind() {
blink::mojom::IDBDatabaseCallbacksAssociatedPtrInfo ptr_info; return receiver_.BindNewEndpointAndPassRemote();
binding_.Bind(::mojo::MakeRequest(&ptr_info));
return ptr_info;
} }
} // namespace content } // namespace content
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include <stdint.h> #include <stdint.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/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.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom.h"
...@@ -20,7 +21,7 @@ class MockMojoIndexedDBDatabaseCallbacks ...@@ -20,7 +21,7 @@ class MockMojoIndexedDBDatabaseCallbacks
MockMojoIndexedDBDatabaseCallbacks(); MockMojoIndexedDBDatabaseCallbacks();
~MockMojoIndexedDBDatabaseCallbacks() override; ~MockMojoIndexedDBDatabaseCallbacks() override;
blink::mojom::IDBDatabaseCallbacksAssociatedPtrInfo mojo::PendingAssociatedRemote<blink::mojom::IDBDatabaseCallbacks>
CreateInterfacePtrAndBind(); CreateInterfacePtrAndBind();
MOCK_METHOD0(ForcedClose, void()); MOCK_METHOD0(ForcedClose, void());
...@@ -38,7 +39,7 @@ class MockMojoIndexedDBDatabaseCallbacks ...@@ -38,7 +39,7 @@ class MockMojoIndexedDBDatabaseCallbacks
} }
private: private:
mojo::AssociatedBinding<blink::mojom::IDBDatabaseCallbacks> binding_; mojo::AssociatedReceiver<blink::mojom::IDBDatabaseCallbacks> receiver_{this};
DISALLOW_COPY_AND_ASSIGN(MockMojoIndexedDBDatabaseCallbacks); DISALLOW_COPY_AND_ASSIGN(MockMojoIndexedDBDatabaseCallbacks);
}; };
......
...@@ -321,7 +321,7 @@ union IDBDatabaseGetAllResult { ...@@ -321,7 +321,7 @@ union IDBDatabaseGetAllResult {
}; };
struct IDBDatabaseOpenCursorValue { struct IDBDatabaseOpenCursorValue {
pending_associated_remote<IDBCursor> pending_cursor; pending_associated_remote<IDBCursor> cursor;
IDBKey key; IDBKey key;
IDBKey primary_key; IDBKey primary_key;
IDBValue? value; IDBValue? value;
...@@ -417,7 +417,7 @@ interface IDBFactory { ...@@ -417,7 +417,7 @@ interface IDBFactory {
GetDatabaseInfo(associated IDBCallbacks callbacks); GetDatabaseInfo(associated IDBCallbacks callbacks);
GetDatabaseNames(associated IDBCallbacks callbacks); GetDatabaseNames(associated IDBCallbacks callbacks);
Open(associated IDBCallbacks callbacks, Open(associated IDBCallbacks callbacks,
associated IDBDatabaseCallbacks database_callbacks, pending_associated_remote<IDBDatabaseCallbacks> pending_database_callbacks,
mojo_base.mojom.String16 name, mojo_base.mojom.String16 name,
int64 version, int64 version,
pending_associated_receiver<IDBTransaction> version_change_transaction_receiver, pending_associated_receiver<IDBTransaction> version_change_transaction_receiver,
......
...@@ -135,7 +135,7 @@ class WebIDBGetDBNamesCallbacksImpl : public WebIDBCallbacks { ...@@ -135,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(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor_info,
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 {
......
...@@ -24,11 +24,11 @@ void MockWebIDBCallbacks::SuccessCursorContinue( ...@@ -24,11 +24,11 @@ void MockWebIDBCallbacks::SuccessCursorContinue(
} }
void MockWebIDBCallbacks::SuccessCursor( void MockWebIDBCallbacks::SuccessCursor(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor_info,
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(pending_cursor, key, primary_key, optional_value); DoSuccessCursor(cursor_info, key, primary_key, optional_value);
} }
void MockWebIDBCallbacks::SuccessKey(std::unique_ptr<IDBKey> key) { void MockWebIDBCallbacks::SuccessKey(std::unique_ptr<IDBKey> key) {
......
...@@ -43,14 +43,14 @@ class MockWebIDBCallbacks : public WebIDBCallbacks { ...@@ -43,14 +43,14 @@ class MockWebIDBCallbacks : public WebIDBCallbacks {
MOCK_METHOD1(SuccessStringList, void(const Vector<String>&)); MOCK_METHOD1(SuccessStringList, void(const Vector<String>&));
void SuccessCursor( void SuccessCursor(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor_info,
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 mojo::PendingAssociatedRemote<mojom::blink::IDBCursor>& void(const mojo::PendingAssociatedRemote<mojom::blink::IDBCursor>&
pending_cursor, cursor_info,
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));
......
...@@ -47,7 +47,7 @@ class WebIDBCallbacks : public mojom::blink::IDBCallbacks { ...@@ -47,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(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor_info,
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(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor_info,
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(pending_cursor), transaction_id_, task_runner_); std::move(cursor_info), 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());
......
...@@ -68,7 +68,7 @@ class WebIDBCallbacksImpl final : public WebIDBCallbacks { ...@@ -68,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(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor_info,
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;
......
...@@ -18,7 +18,7 @@ using blink::mojom::blink::IDBCallbacksAssociatedPtrInfo; ...@@ -18,7 +18,7 @@ using blink::mojom::blink::IDBCallbacksAssociatedPtrInfo;
namespace blink { namespace blink {
WebIDBCursorImpl::WebIDBCursorImpl( WebIDBCursorImpl::WebIDBCursorImpl(
mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> pending_cursor, mojo::PendingAssociatedRemote<mojom::blink::IDBCursor> cursor_info,
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),
...@@ -27,7 +27,7 @@ WebIDBCursorImpl::WebIDBCursorImpl( ...@@ -27,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(pending_cursor), std::move(task_runner)); cursor_.Bind(std::move(cursor_info), std::move(task_runner));
IndexedDBDispatcher::RegisterCursor(this); IndexedDBDispatcher::RegisterCursor(this);
} }
......
...@@ -28,8 +28,8 @@ namespace { ...@@ -28,8 +28,8 @@ namespace {
class MockCursorImpl : public mojom::blink::IDBCursor { class MockCursorImpl : public mojom::blink::IDBCursor {
public: public:
explicit MockCursorImpl( explicit MockCursorImpl(
mojo::PendingAssociatedReceiver<mojom::blink::IDBCursor> pending_receiver) mojo::PendingAssociatedReceiver<mojom::blink::IDBCursor> receiver)
: receiver_(this, std::move(pending_receiver)) { : receiver_(this, std::move(receiver)) {
receiver_.set_disconnect_handler(base::BindOnce( receiver_.set_disconnect_handler(base::BindOnce(
&MockCursorImpl::CursorDestroyed, base::Unretained(this))); &MockCursorImpl::CursorDestroyed, base::Unretained(this)));
} }
......
...@@ -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()->pending_cursor), callbacks->SuccessCursor(std::move(result->get_value()->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));
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "third_party/blink/renderer/modules/indexeddb/web_idb_factory_impl.h" #include "third_party/blink/renderer/modules/indexeddb/web_idb_factory_impl.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "mojo/public/cpp/bindings/strong_associated_binding.h" #include "mojo/public/cpp/bindings/self_owned_associated_receiver.h"
#include "third_party/blink/renderer/modules/indexeddb/indexed_db_database_callbacks_impl.h" #include "third_party/blink/renderer/modules/indexeddb/indexed_db_database_callbacks_impl.h"
#include "third_party/blink/renderer/modules/indexeddb/web_idb_callbacks_impl.h" #include "third_party/blink/renderer/modules/indexeddb/web_idb_callbacks_impl.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
...@@ -72,14 +72,16 @@ WebIDBFactoryImpl::GetCallbacksProxy( ...@@ -72,14 +72,16 @@ WebIDBFactoryImpl::GetCallbacksProxy(
return ptr_info; return ptr_info;
} }
mojom::blink::IDBDatabaseCallbacksAssociatedPtrInfo mojo::PendingAssociatedRemote<mojom::blink::IDBDatabaseCallbacks>
WebIDBFactoryImpl::GetDatabaseCallbacksProxy( WebIDBFactoryImpl::GetDatabaseCallbacksProxy(
std::unique_ptr<IndexedDBDatabaseCallbacksImpl> callbacks) { std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks_impl) {
mojom::blink::IDBDatabaseCallbacksAssociatedPtrInfo ptr_info; mojo::PendingAssociatedRemote<mojom::blink::IDBDatabaseCallbacks>
auto request = mojo::MakeRequest(&ptr_info); pending_database_callbacks;
mojo::MakeStrongAssociatedBinding(std::move(callbacks), std::move(request), mojo::MakeSelfOwnedAssociatedReceiver(
task_runner_); std::move(database_callbacks_impl),
return ptr_info; pending_database_callbacks.InitWithNewEndpointAndPassReceiver(),
task_runner_);
return pending_database_callbacks;
} }
} // namespace blink } // namespace blink
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_INDEXEDDB_WEB_IDB_FACTORY_IMPL_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_INDEXEDDB_WEB_IDB_FACTORY_IMPL_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 "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_key_range.h" #include "third_party/blink/renderer/modules/indexeddb/idb_key_range.h"
#include "third_party/blink/renderer/modules/indexeddb/indexed_db_database_callbacks_impl.h" #include "third_party/blink/renderer/modules/indexeddb/indexed_db_database_callbacks_impl.h"
...@@ -44,8 +45,9 @@ class WebIDBFactoryImpl : public WebIDBFactory { ...@@ -44,8 +45,9 @@ class WebIDBFactoryImpl : public WebIDBFactory {
private: private:
mojom::blink::IDBCallbacksAssociatedPtrInfo GetCallbacksProxy( mojom::blink::IDBCallbacksAssociatedPtrInfo GetCallbacksProxy(
std::unique_ptr<WebIDBCallbacks> callbacks); std::unique_ptr<WebIDBCallbacks> callbacks);
mojom::blink::IDBDatabaseCallbacksAssociatedPtrInfo GetDatabaseCallbacksProxy( mojo::PendingAssociatedRemote<mojom::blink::IDBDatabaseCallbacks>
std::unique_ptr<IndexedDBDatabaseCallbacksImpl> callbacks); GetDatabaseCallbacksProxy(
std::unique_ptr<IndexedDBDatabaseCallbacksImpl> database_callbacks_impl);
mojom::blink::IDBFactoryPtr factory_; mojom::blink::IDBFactoryPtr factory_;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_; scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
......
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