Commit 8ab180f7 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert VisitedLinkNotificationSink to new Mojo types

This CL converts VisitedLinkNotificationSinkPtr and
VisitedLinkNotificationSinkRequest to new Mojo types
using Remote, ReceiverSet and PendingReceiver.

Bug: 955171
Change-Id: I3ac5ddc1c7e92072ab1848d2478225cc50dfc29e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816059Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#699676}
parent 79260ad0
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "content/public/browser/notification_types.h" #include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host.h" #include "content/public/browser/render_widget_host.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/interface_provider.h" #include "services/service_manager/public/cpp/interface_provider.h"
using base::Time; using base::Time;
...@@ -45,7 +46,7 @@ class VisitedLinkUpdater { ...@@ -45,7 +46,7 @@ class VisitedLinkUpdater {
invalidate_hashes_(false), invalidate_hashes_(false),
render_process_id_(render_process_id) { render_process_id_(render_process_id) {
BindInterface(content::RenderProcessHost::FromID(render_process_id), BindInterface(content::RenderProcessHost::FromID(render_process_id),
&sink_); sink_.BindNewPipeAndPassReceiver());
} }
// Informs the renderer about a new visited link table. // Informs the renderer about a new visited link table.
...@@ -112,7 +113,7 @@ class VisitedLinkUpdater { ...@@ -112,7 +113,7 @@ class VisitedLinkUpdater {
bool reset_needed_; bool reset_needed_;
bool invalidate_hashes_; bool invalidate_hashes_;
int render_process_id_; int render_process_id_;
mojom::VisitedLinkNotificationSinkPtr sink_; mojo::Remote<mojom::VisitedLinkNotificationSink> sink_;
VisitedLinkCommon::Fingerprints pending_; VisitedLinkCommon::Fingerprints pending_;
}; };
......
...@@ -15,13 +15,13 @@ using blink::WebView; ...@@ -15,13 +15,13 @@ using blink::WebView;
namespace visitedlink { namespace visitedlink {
VisitedLinkSlave::VisitedLinkSlave() : binding_(this) {} VisitedLinkSlave::VisitedLinkSlave() = default;
VisitedLinkSlave::~VisitedLinkSlave() { VisitedLinkSlave::~VisitedLinkSlave() {
FreeTable(); FreeTable();
} }
base::Callback<void(mojom::VisitedLinkNotificationSinkRequest)> base::Callback<void(mojo::PendingReceiver<mojom::VisitedLinkNotificationSink>)>
VisitedLinkSlave::GetBindCallback() { VisitedLinkSlave::GetBindCallback() {
return base::Bind(&VisitedLinkSlave::Bind, weak_factory_.GetWeakPtr()); return base::Bind(&VisitedLinkSlave::Bind, weak_factory_.GetWeakPtr());
} }
...@@ -80,8 +80,9 @@ void VisitedLinkSlave::FreeTable() { ...@@ -80,8 +80,9 @@ void VisitedLinkSlave::FreeTable() {
table_length_ = 0; table_length_ = 0;
} }
void VisitedLinkSlave::Bind(mojom::VisitedLinkNotificationSinkRequest request) { void VisitedLinkSlave::Bind(
binding_.Bind(std::move(request)); mojo::PendingReceiver<mojom::VisitedLinkNotificationSink> receiver) {
receiver_.Bind(std::move(receiver));
} }
} // namespace visitedlink } // namespace visitedlink
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "components/visitedlink/common/visitedlink.mojom.h" #include "components/visitedlink/common/visitedlink.mojom.h"
#include "components/visitedlink/common/visitedlink_common.h" #include "components/visitedlink/common/visitedlink_common.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
namespace visitedlink { namespace visitedlink {
...@@ -24,7 +25,8 @@ class VisitedLinkSlave : public VisitedLinkCommon, ...@@ -24,7 +25,8 @@ class VisitedLinkSlave : public VisitedLinkCommon,
VisitedLinkSlave(); VisitedLinkSlave();
~VisitedLinkSlave() override; ~VisitedLinkSlave() override;
base::Callback<void(mojom::VisitedLinkNotificationSinkRequest)> base::Callback<
void(mojo::PendingReceiver<mojom::VisitedLinkNotificationSink>)>
GetBindCallback(); GetBindCallback();
// mojom::VisitedLinkNotificationSink overrides. // mojom::VisitedLinkNotificationSink overrides.
...@@ -37,11 +39,11 @@ class VisitedLinkSlave : public VisitedLinkCommon, ...@@ -37,11 +39,11 @@ class VisitedLinkSlave : public VisitedLinkCommon,
private: private:
void FreeTable(); void FreeTable();
void Bind(mojom::VisitedLinkNotificationSinkRequest request); void Bind(mojo::PendingReceiver<mojom::VisitedLinkNotificationSink> receiver);
base::ReadOnlySharedMemoryMapping table_mapping_; base::ReadOnlySharedMemoryMapping table_mapping_;
mojo::Binding<mojom::VisitedLinkNotificationSink> binding_; mojo::Receiver<mojom::VisitedLinkNotificationSink> receiver_{this};
base::WeakPtrFactory<VisitedLinkSlave> weak_factory_{this}; base::WeakPtrFactory<VisitedLinkSlave> weak_factory_{this};
......
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
#include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_context.h"
#include "content/public/test/test_renderer_host.h" #include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -531,8 +532,9 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink { ...@@ -531,8 +532,9 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
new_table_count_(0) {} new_table_count_(0) {}
void Bind(mojo::ScopedMessagePipeHandle handle) { void Bind(mojo::ScopedMessagePipeHandle handle) {
binding_.AddBinding( receiver_.Add(this,
this, mojom::VisitedLinkNotificationSinkRequest(std::move(handle))); mojo::PendingReceiver<mojom::VisitedLinkNotificationSink>(
std::move(handle)));
} }
void WaitForUpdate() { void WaitForUpdate() {
...@@ -541,10 +543,10 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink { ...@@ -541,10 +543,10 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
run_loop.Run(); run_loop.Run();
} }
void WaitForNoUpdate() { binding_.FlushForTesting(); } void WaitForNoUpdate() { receiver_.FlushForTesting(); }
mojo::BindingSet<mojom::VisitedLinkNotificationSink>& binding() { mojo::ReceiverSet<mojom::VisitedLinkNotificationSink>& binding() {
return binding_; return receiver_;
} }
void NotifyUpdate() { void NotifyUpdate() {
...@@ -588,7 +590,7 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink { ...@@ -588,7 +590,7 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
int new_table_count_; int new_table_count_;
base::Closure quit_closure_; base::Closure quit_closure_;
mojo::BindingSet<mojom::VisitedLinkNotificationSink> binding_; mojo::ReceiverSet<mojom::VisitedLinkNotificationSink> receiver_;
DISALLOW_COPY_AND_ASSIGN(VisitCountingContext); DISALLOW_COPY_AND_ASSIGN(VisitCountingContext);
}; };
......
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