Commit b1ef8e18 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Clean up old Mojo type for mojom::EmbeddedSearch

This CL cleans up old mojo types for mojom::EmbeddedSearch
using PendingAssociatedReceiver, AssociatedReceiver, and
AssociatedRemote.

Bug: 955171
Change-Id: Ia318dd332a4d77f2deb287b47d7338159ad43047
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1897402Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#715551}
parent 2480de7e
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h" #include "content/public/common/child_process_host.h"
#include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h" #include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
...@@ -40,10 +41,10 @@ class EmbeddedSearchClientFactoryImpl ...@@ -40,10 +41,10 @@ class EmbeddedSearchClientFactoryImpl
// |web_contents| and |binding| must outlive this object. // |web_contents| and |binding| must outlive this object.
EmbeddedSearchClientFactoryImpl( EmbeddedSearchClientFactoryImpl(
content::WebContents* web_contents, content::WebContents* web_contents,
mojo::AssociatedBinding<chrome::mojom::EmbeddedSearch>* binding) mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearch>* receiver)
: client_binding_(binding), factory_bindings_(web_contents, this) { : client_receiver_(receiver), factory_bindings_(web_contents, this) {
DCHECK(web_contents); DCHECK(web_contents);
DCHECK(binding); DCHECK(receiver);
// Before we are connected to a frame we throw away all messages. // Before we are connected to a frame we throw away all messages.
ignore_result(embedded_search_client_ ignore_result(embedded_search_client_
.BindNewEndpointAndPassDedicatedReceiverForTesting()); .BindNewEndpointAndPassDedicatedReceiverForTesting());
...@@ -55,7 +56,7 @@ class EmbeddedSearchClientFactoryImpl ...@@ -55,7 +56,7 @@ class EmbeddedSearchClientFactoryImpl
private: private:
void Connect( void Connect(
chrome::mojom::EmbeddedSearchAssociatedRequest request, mojo::PendingAssociatedReceiver<chrome::mojom::EmbeddedSearch> receiver,
mojo::PendingAssociatedRemote<chrome::mojom::EmbeddedSearchClient> client) mojo::PendingAssociatedRemote<chrome::mojom::EmbeddedSearchClient> client)
override; override;
...@@ -65,9 +66,9 @@ class EmbeddedSearchClientFactoryImpl ...@@ -65,9 +66,9 @@ class EmbeddedSearchClientFactoryImpl
mojo::AssociatedRemote<chrome::mojom::EmbeddedSearchClient> mojo::AssociatedRemote<chrome::mojom::EmbeddedSearchClient>
embedded_search_client_; embedded_search_client_;
// Used to bind incoming interface requests to the implementation, which lives // Used to bind incoming pending receivers to the implementation, which lives
// in SearchIPCRouter. // in SearchIPCRouter.
mojo::AssociatedBinding<chrome::mojom::EmbeddedSearch>* client_binding_; mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearch>* client_receiver_;
// Binding used to listen to connection requests. // Binding used to listen to connection requests.
content::WebContentsFrameBindingSet<chrome::mojom::EmbeddedSearchConnector> content::WebContentsFrameBindingSet<chrome::mojom::EmbeddedSearchConnector>
...@@ -77,14 +78,14 @@ class EmbeddedSearchClientFactoryImpl ...@@ -77,14 +78,14 @@ class EmbeddedSearchClientFactoryImpl
}; };
void EmbeddedSearchClientFactoryImpl::Connect( void EmbeddedSearchClientFactoryImpl::Connect(
chrome::mojom::EmbeddedSearchAssociatedRequest request, mojo::PendingAssociatedReceiver<chrome::mojom::EmbeddedSearch> receiver,
mojo::PendingAssociatedRemote<chrome::mojom::EmbeddedSearchClient> client) { mojo::PendingAssociatedRemote<chrome::mojom::EmbeddedSearchClient> client) {
content::RenderFrameHost* frame = factory_bindings_.GetCurrentTargetFrame(); content::RenderFrameHost* frame = factory_bindings_.GetCurrentTargetFrame();
const bool is_main_frame = frame->GetParent() == nullptr; const bool is_main_frame = frame->GetParent() == nullptr;
if (!IsInInstantProcess(frame) || !is_main_frame) { if (!IsInInstantProcess(frame) || !is_main_frame) {
return; return;
} }
client_binding_->Bind(std::move(request)); client_receiver_->Bind(std::move(receiver));
embedded_search_client_.reset(); embedded_search_client_.reset();
embedded_search_client_.Bind(std::move(client)); embedded_search_client_.Bind(std::move(client));
} }
...@@ -99,9 +100,8 @@ SearchIPCRouter::SearchIPCRouter(content::WebContents* web_contents, ...@@ -99,9 +100,8 @@ SearchIPCRouter::SearchIPCRouter(content::WebContents* web_contents,
policy_(std::move(policy)), policy_(std::move(policy)),
commit_counter_(0), commit_counter_(0),
is_active_tab_(false), is_active_tab_(false),
binding_(this),
embedded_search_client_factory_( embedded_search_client_factory_(
new EmbeddedSearchClientFactoryImpl(web_contents, &binding_)) { new EmbeddedSearchClientFactoryImpl(web_contents, &receiver_)) {
DCHECK(web_contents); DCHECK(web_contents);
DCHECK(delegate); DCHECK(delegate);
DCHECK(policy_.get()); DCHECK(policy_.get());
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "components/omnibox/common/omnibox_focus_state.h" #include "components/omnibox/common/omnibox_focus_state.h"
#include "content/public/browser/web_contents_binding_set.h" #include "content/public/browser/web_contents_binding_set.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#error "Instant is only used on desktop"; #error "Instant is only used on desktop";
...@@ -372,10 +373,10 @@ class SearchIPCRouter : public content::WebContentsObserver, ...@@ -372,10 +373,10 @@ class SearchIPCRouter : public content::WebContentsObserver,
// Set to true, when the tab corresponding to |this| instance is active. // Set to true, when the tab corresponding to |this| instance is active.
bool is_active_tab_; bool is_active_tab_;
// Binding for the connected main frame. We only allow one frame to connect at // Receiver for the connected main frame. We only allow one frame to connect
// the moment, but this could be extended to a map of connected frames, if // at the moment, but this could be extended to a map of connected frames, if
// desired. // desired.
mojo::AssociatedBinding<chrome::mojom::EmbeddedSearch> binding_; mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearch> receiver_{this};
std::unique_ptr<EmbeddedSearchClientFactory> embedded_search_client_factory_; std::unique_ptr<EmbeddedSearchClientFactory> embedded_search_client_factory_;
......
...@@ -28,7 +28,7 @@ interface EmbeddedSearchConnector { ...@@ -28,7 +28,7 @@ interface EmbeddedSearchConnector {
// client will use to query the embedded search interface. |client| is the // client will use to query the embedded search interface. |client| is the
// connection used by the embedded search interface implementation to push // connection used by the embedded search interface implementation to push
// browser state updates to the client. // browser state updates to the client.
Connect(associated EmbeddedSearch & embedded_search, Connect(pending_associated_receiver<EmbeddedSearch> embedded_search,
pending_associated_remote<EmbeddedSearchClient> client); pending_associated_remote<EmbeddedSearchClient> client);
}; };
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "components/url_formatter/url_fixer.h" #include "components/url_formatter/url_fixer.h"
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h" #include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
...@@ -214,11 +213,10 @@ SearchBox::SearchBox(content::RenderFrame* render_frame) ...@@ -214,11 +213,10 @@ SearchBox::SearchBox(content::RenderFrame* render_frame)
receiver_.Bind(embedded_search_client.InitWithNewEndpointAndPassReceiver(), receiver_.Bind(embedded_search_client.InitWithNewEndpointAndPassReceiver(),
render_frame->GetTaskRunner( render_frame->GetTaskRunner(
blink::TaskType::kInternalNavigationAssociated)); blink::TaskType::kInternalNavigationAssociated));
connector->Connect( connector->Connect(embedded_search_service_.BindNewEndpointAndPassReceiver(
mojo::MakeRequest(&embedded_search_service_, render_frame->GetTaskRunner(
render_frame->GetTaskRunner( blink::TaskType::kInternalNavigationAssociated)),
blink::TaskType::kInternalNavigationAssociated)), std::move(embedded_search_client));
std::move(embedded_search_client));
} }
SearchBox::~SearchBox() = default; SearchBox::~SearchBox() = default;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "content/public/renderer/render_frame_observer.h" #include "content/public/renderer/render_frame_observer.h"
#include "content/public/renderer/render_frame_observer_tracker.h" #include "content/public/renderer/render_frame_observer_tracker.h"
#include "mojo/public/cpp/bindings/associated_receiver.h" #include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "url/gurl.h" #include "url/gurl.h"
// The renderer-side implementation of the embeddedSearch API (see // The renderer-side implementation of the embeddedSearch API (see
...@@ -246,7 +247,8 @@ class SearchBox : public content::RenderFrameObserver, ...@@ -246,7 +247,8 @@ class SearchBox : public content::RenderFrameObserver,
GURL GetURLForMostVisitedItem(InstantRestrictedID item_id) const; GURL GetURLForMostVisitedItem(InstantRestrictedID item_id) const;
// The connection to the EmbeddedSearch service in the browser process. // The connection to the EmbeddedSearch service in the browser process.
chrome::mojom::EmbeddedSearchAssociatedPtr embedded_search_service_; mojo::AssociatedRemote<chrome::mojom::EmbeddedSearch>
embedded_search_service_;
mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearchClient> receiver_{this}; mojo::AssociatedReceiver<chrome::mojom::EmbeddedSearchClient> receiver_{this};
// Whether it's legal to execute JavaScript in |render_frame()|. // Whether it's legal to execute JavaScript in |render_frame()|.
......
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