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 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_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"
using base::Time;
......@@ -45,7 +46,7 @@ class VisitedLinkUpdater {
invalidate_hashes_(false),
render_process_id_(render_process_id) {
BindInterface(content::RenderProcessHost::FromID(render_process_id),
&sink_);
sink_.BindNewPipeAndPassReceiver());
}
// Informs the renderer about a new visited link table.
......@@ -112,7 +113,7 @@ class VisitedLinkUpdater {
bool reset_needed_;
bool invalidate_hashes_;
int render_process_id_;
mojom::VisitedLinkNotificationSinkPtr sink_;
mojo::Remote<mojom::VisitedLinkNotificationSink> sink_;
VisitedLinkCommon::Fingerprints pending_;
};
......
......@@ -15,13 +15,13 @@ using blink::WebView;
namespace visitedlink {
VisitedLinkSlave::VisitedLinkSlave() : binding_(this) {}
VisitedLinkSlave::VisitedLinkSlave() = default;
VisitedLinkSlave::~VisitedLinkSlave() {
FreeTable();
}
base::Callback<void(mojom::VisitedLinkNotificationSinkRequest)>
base::Callback<void(mojo::PendingReceiver<mojom::VisitedLinkNotificationSink>)>
VisitedLinkSlave::GetBindCallback() {
return base::Bind(&VisitedLinkSlave::Bind, weak_factory_.GetWeakPtr());
}
......@@ -80,8 +80,9 @@ void VisitedLinkSlave::FreeTable() {
table_length_ = 0;
}
void VisitedLinkSlave::Bind(mojom::VisitedLinkNotificationSinkRequest request) {
binding_.Bind(std::move(request));
void VisitedLinkSlave::Bind(
mojo::PendingReceiver<mojom::VisitedLinkNotificationSink> receiver) {
receiver_.Bind(std::move(receiver));
}
} // namespace visitedlink
......@@ -12,7 +12,8 @@
#include "base/memory/weak_ptr.h"
#include "components/visitedlink/common/visitedlink.mojom.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 {
......@@ -24,7 +25,8 @@ class VisitedLinkSlave : public VisitedLinkCommon,
VisitedLinkSlave();
~VisitedLinkSlave() override;
base::Callback<void(mojom::VisitedLinkNotificationSinkRequest)>
base::Callback<
void(mojo::PendingReceiver<mojom::VisitedLinkNotificationSink>)>
GetBindCallback();
// mojom::VisitedLinkNotificationSink overrides.
......@@ -37,11 +39,11 @@ class VisitedLinkSlave : public VisitedLinkCommon,
private:
void FreeTable();
void Bind(mojom::VisitedLinkNotificationSinkRequest request);
void Bind(mojo::PendingReceiver<mojom::VisitedLinkNotificationSink> receiver);
base::ReadOnlySharedMemoryMapping table_mapping_;
mojo::Binding<mojom::VisitedLinkNotificationSink> binding_;
mojo::Receiver<mojom::VisitedLinkNotificationSink> receiver_{this};
base::WeakPtrFactory<VisitedLinkSlave> weak_factory_{this};
......
......@@ -34,7 +34,8 @@
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_renderer_host.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 "url/gurl.h"
......@@ -531,8 +532,9 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
new_table_count_(0) {}
void Bind(mojo::ScopedMessagePipeHandle handle) {
binding_.AddBinding(
this, mojom::VisitedLinkNotificationSinkRequest(std::move(handle)));
receiver_.Add(this,
mojo::PendingReceiver<mojom::VisitedLinkNotificationSink>(
std::move(handle)));
}
void WaitForUpdate() {
......@@ -541,10 +543,10 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
run_loop.Run();
}
void WaitForNoUpdate() { binding_.FlushForTesting(); }
void WaitForNoUpdate() { receiver_.FlushForTesting(); }
mojo::BindingSet<mojom::VisitedLinkNotificationSink>& binding() {
return binding_;
mojo::ReceiverSet<mojom::VisitedLinkNotificationSink>& binding() {
return receiver_;
}
void NotifyUpdate() {
......@@ -588,7 +590,7 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
int new_table_count_;
base::Closure quit_closure_;
mojo::BindingSet<mojom::VisitedLinkNotificationSink> binding_;
mojo::ReceiverSet<mojom::VisitedLinkNotificationSink> receiver_;
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