0

Make use of CreateInterfacePtrAndBind() where appropriate

BUG=579645
TEST=none

Review URL: https://codereview.chromium.org/1635603002

Cr-Commit-Position: refs/heads/master@{#371598}
This commit is contained in:
sky
2016-01-26 13:13:39 -08:00
committed by Commit bot
parent 1d248c223d
commit d837812ff8
29 changed files with 47 additions and 111 deletions

@ -18,9 +18,8 @@ ArcAuthService::~ArcAuthService() {
}
void ArcAuthService::OnAuthInstanceReady() {
arc::AuthHostPtr host;
binding_.Bind(GetProxy(&host));
arc_bridge_service()->auth_instance()->Init(std::move(host));
arc_bridge_service()->auth_instance()->Init(
binding_.CreateInterfacePtrAndBind());
}
void ArcAuthService::GetAuthCode(const GetAuthCodeCallback& callback) {

@ -25,9 +25,8 @@ ArcIntentHelperBridge::~ArcIntentHelperBridge() {
}
void ArcIntentHelperBridge::OnIntentHelperInstanceReady() {
IntentHelperHostPtr host;
binding_.Bind(mojo::GetProxy(&host));
arc_bridge_service()->intent_helper_instance()->Init(std::move(host));
arc_bridge_service()->intent_helper_instance()->Init(
binding_.CreateInterfacePtrAndBind());
settings_bridge_.reset(new SettingsBridge(this));
}

@ -281,9 +281,7 @@ void ArcAppListPrefs::OnAppInstanceReady() {
return;
}
arc::AppHostPtr host;
binding_.Bind(mojo::GetProxy(&host));
app_instance->Init(std::move(host));
app_instance->Init(binding_.CreateInterfacePtrAndBind());
app_instance->RefreshAppList();
}

@ -101,9 +101,7 @@ void ArcBridgeServiceImpl::OnConnectionEstablished(
instance_ptr_.set_connection_error_handler(base::Bind(
&ArcBridgeServiceImpl::OnChannelClosed, weak_factory_.GetWeakPtr()));
ArcBridgeHostPtr host;
binding_.Bind(GetProxy(&host));
instance_ptr_->Init(std::move(host));
instance_ptr_->Init(binding_.CreateInterfacePtrAndBind());
SetState(State::READY);
}

@ -46,9 +46,7 @@ void ArcClipboardBridge::OnClipboardInstanceReady() {
return;
}
ClipboardHostPtr host;
binding_.Bind(mojo::GetProxy(&host));
clipboard_instance->Init(std::move(host));
clipboard_instance->Init(binding_.CreateInterfacePtrAndBind());
}
void ArcClipboardBridge::SetTextContent(const mojo::String& text) {

@ -80,9 +80,7 @@ ArcImeIpcHostImpl::~ArcImeIpcHostImpl() {
}
void ArcImeIpcHostImpl::OnImeInstanceReady() {
arc::ImeHostPtr host;
binding_.Bind(mojo::GetProxy(&host));
bridge_service_->ime_instance()->Init(std::move(host));
bridge_service_->ime_instance()->Init(binding_.CreateInterfacePtrAndBind());
}
void ArcImeIpcHostImpl::SendSetCompositionText(

@ -35,9 +35,7 @@ void ArcPowerBridge::OnPowerInstanceReady() {
return;
}
PowerHostPtr host;
binding_.Bind(mojo::GetProxy(&host));
power_instance->Init(std::move(host));
power_instance->Init(binding_.CreateInterfacePtrAndBind());
}
void ArcPowerBridge::OnAcquireDisplayWakeLock(

@ -32,9 +32,8 @@ void ArcVideoBridge::OnStateChanged(arc::ArcBridgeService::State state) {
}
void ArcVideoBridge::OnVideoInstanceReady() {
arc::VideoHostPtr host;
binding_.Bind(mojo::GetProxy(&host));
arc_bridge_service()->video_instance()->Init(std::move(host));
arc_bridge_service()->video_instance()->Init(
binding_.CreateInterfacePtrAndBind());
}
} // namespace arc

@ -23,9 +23,7 @@ void DevToolsAgentHost::SetDelegate(Delegate* delegate) {
if (binding_.is_bound())
return;
DevToolsAgentClientPtr client;
binding_.Bind(&client);
agent_->SetClient(std::move(client));
agent_->SetClient(binding_.CreateInterfacePtrAndBind());
} else {
if (!binding_.is_bound())
return;

@ -28,11 +28,9 @@ void FilesTestBase::OnFileSystemShutdown() {
}
void FilesTestBase::GetTemporaryRoot(DirectoryPtr* directory) {
filesystem::FileSystemClientPtr client;
binding_.Bind(GetProxy(&client));
FileError error = FileError::FAILED;
files()->OpenFileSystem("temp", GetProxy(directory), std::move(client),
files()->OpenFileSystem("temp", GetProxy(directory),
binding_.CreateInterfacePtrAndBind(),
mojo::Capture(&error));
ASSERT_TRUE(files().WaitForIncomingResponse());
ASSERT_EQ(FileError::OK, error);

@ -327,11 +327,8 @@ void FilesystemJsonPrefStore::PerformWrite() {
}
void FilesystemJsonPrefStore::OpenFilesystem(base::Closure callback) {
filesystem::FileSystemClientPtr client;
binding_.Bind(GetProxy(&client));
filesystem_->OpenFileSystem(
"origin", GetProxy(&directory_), std::move(client),
"origin", GetProxy(&directory_), binding_.CreateInterfacePtrAndBind(),
base::Bind(&FilesystemJsonPrefStore::OnOpenFilesystem, AsWeakPtr(),
callback));
}

@ -251,9 +251,7 @@ class WindowAndFrame : public mus::WindowTreeDelegate {
}
mojom::FrameClientPtr GetFrameClientPtr() {
mojom::FrameClientPtr client_ptr;
frame_client_binding_.Bind(GetProxy(&client_ptr));
return client_ptr;
return frame_client_binding_.CreateInterfacePtrAndBind();
}
void Bind(mojo::InterfaceRequest<mojom::FrameClient> request) {

@ -61,9 +61,7 @@ class FrameDevToolsAgent::FrameDevToolsAgentClient
if (binding_.is_bound())
binding_.Close();
DevToolsAgentClientPtr client;
binding_.Bind(&client);
owner_->forward_agent_->SetClient(std::move(client));
owner_->forward_agent_->SetClient(binding_.CreateInterfacePtrAndBind());
}
private:
@ -126,9 +124,7 @@ void FrameDevToolsAgent::RegisterAgentIfNecessary() {
DevToolsRegistryPtr devtools_registry;
app_->ConnectToService("mojo:devtools_service", &devtools_registry);
DevToolsAgentPtr agent;
binding_.Bind(&agent);
devtools_registry->RegisterAgent(id_, std::move(agent));
devtools_registry->RegisterAgent(id_, binding_.CreateInterfacePtrAndBind());
}
void FrameDevToolsAgent::HandlePageNavigateRequest(

@ -24,14 +24,10 @@ WebView::WebView(mojom::WebViewClient* client) : binding_(client) {}
WebView::~WebView() {}
void WebView::Init(mojo::ApplicationImpl* app, mus::Window* window) {
mojom::WebViewClientPtr client;
mojo::InterfaceRequest<mojom::WebViewClient> client_request =
GetProxy(&client);
binding_.Bind(std::move(client_request));
mojom::WebViewFactoryPtr factory;
app->ConnectToService("mojo:web_view", &factory);
factory->CreateWebView(std::move(client), GetProxy(&web_view_));
factory->CreateWebView(binding_.CreateInterfacePtrAndBind(),
GetProxy(&web_view_));
mus::mojom::WindowTreeClientPtr window_tree_client;
web_view_->GetWindowTreeClient(GetProxy(&window_tree_client));

@ -124,9 +124,7 @@ ServicePortServicePtr& ServicePortProvider::GetServicePortServicePtr() {
base::Passed(&request)));
// Setup channel for browser to post events back to this class.
ServicePortServiceClientPtr client_ptr;
binding_.Bind(GetProxy(&client_ptr));
service_port_service_->SetClient(std::move(client_ptr));
service_port_service_->SetClient(binding_.CreateInterfacePtrAndBind());
}
return service_port_service_;
}

@ -421,9 +421,7 @@ void PresentationDispatcher::ConnectToPresentationServiceIfNeeded() {
render_frame()->GetServiceRegistry()->ConnectToRemoteService(
mojo::GetProxy(&presentation_service_));
presentation::PresentationServiceClientPtr client_ptr;
binding_.Bind(GetProxy(&client_ptr));
presentation_service_->SetClient(std::move(client_ptr));
presentation_service_->SetClient(binding_.CreateInterfacePtrAndBind());
}
void PresentationDispatcher::UpdateListeningState(AvailabilityStatus* status) {

@ -29,13 +29,10 @@ WiFiDisplaySession::WiFiDisplaySession(
&WiFiDisplaySession::OnConnectionError,
weak_factory_.GetWeakPtr()));
WiFiDisplaySessionServiceClientPtr client_ptr;
binding_.Bind(GetProxy(&client_ptr));
service_->SetClient(binding_.CreateInterfacePtrAndBind());
binding_.set_connection_error_handler(base::Bind(
&WiFiDisplaySession::OnConnectionError,
weak_factory_.GetWeakPtr()));
DCHECK(client_ptr);
service_->SetClient(std::move(client_ptr));
}
WiFiDisplaySession::~WiFiDisplaySession() {

@ -112,10 +112,9 @@ BrowserWindow::BrowserWindow(mojo::ApplicationImpl* app,
find_active_(0),
find_count_(0),
web_view_(this) {
mus::mojom::WindowTreeHostClientPtr host_client;
host_client_binding_.Bind(GetProxy(&host_client));
mus::CreateWindowTreeHost(host_factory, std::move(host_client), this, &host_,
nullptr, nullptr);
mus::CreateWindowTreeHost(host_factory,
host_client_binding_.CreateInterfacePtrAndBind(),
this, &host_, nullptr, nullptr);
}
void BrowserWindow::LoadURL(const GURL& url) {

@ -84,11 +84,9 @@ void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) {
make_scoped_ptr(new mojo::InterfaceRequest<mus::mojom::WindowManager>(
mojo::GetProxy(&window_manager))));
user_window_controller_.reset(new UserWindowControllerImpl());
mus::mojom::WindowTreeHostClientPtr host_client;
host_client_binding_.Bind(GetProxy(&host_client));
mus::CreateSingleWindowTreeHost(app, std::move(host_client), this,
&window_tree_host_, std::move(window_manager),
window_manager_.get());
mus::CreateSingleWindowTreeHost(
app, host_client_binding_.CreateInterfacePtrAndBind(), this,
&window_tree_host_, std::move(window_manager), window_manager_.get());
}
bool WindowManagerApplication::ConfigureIncomingConnection(

@ -101,14 +101,11 @@ class MediaAppTest : public mojo::test::ApplicationTestBase {
interfaces::DemuxerStreamPtr video_stream;
new MojoDemuxerStreamImpl(&video_demuxer_stream_, GetProxy(&video_stream));
interfaces::RendererClientPtr client_ptr;
renderer_client_binding_.Bind(GetProxy(&client_ptr));
EXPECT_CALL(*this, OnRendererInitialized(expected_result))
.Times(Exactly(1))
.WillOnce(InvokeWithoutArgs(run_loop_.get(), &base::RunLoop::Quit));
renderer_->Initialize(std::move(client_ptr), nullptr,
std::move(video_stream),
renderer_->Initialize(renderer_client_binding_.CreateInterfacePtrAndBind(),
nullptr, std::move(video_stream),
base::Bind(&MediaAppTest::OnRendererInitialized,
base::Unretained(this)));
}

@ -76,9 +76,7 @@ MojoCdm::MojoCdm(interfaces::ContentDecryptionModulePtr remote_cdm,
DCHECK(!session_keys_change_cb_.is_null());
DCHECK(!session_expiration_update_cb_.is_null());
interfaces::ContentDecryptionModuleClientPtr client_ptr;
binding_.Bind(GetProxy(&client_ptr));
remote_cdm_->SetClient(std::move(client_ptr));
remote_cdm_->SetClient(binding_.CreateInterfacePtrAndBind());
}
MojoCdm::~MojoCdm() {

@ -68,10 +68,9 @@ void MojoRendererImpl::Initialize(
if (video)
new MojoDemuxerStreamImpl(video, GetProxy(&video_stream));
interfaces::RendererClientPtr client_ptr;
binding_.Bind(GetProxy(&client_ptr));
remote_renderer_->Initialize(
std::move(client_ptr), std::move(audio_stream), std::move(video_stream),
binding_.CreateInterfacePtrAndBind(), std::move(audio_stream),
std::move(video_stream),
BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized,
weak_factory_.GetWeakPtr())));
}

@ -98,13 +98,10 @@ void NetworkServiceDelegate::Initialize(ApplicationImpl* app) {
// apptests are also fairly resistant to being run under gdb on android.
app_->ConnectToService("mojo:filesystem", &files_);
filesystem::FileSystemClientPtr client;
binding_.Bind(GetProxy(&client));
filesystem::FileError error = filesystem::FileError::FAILED;
filesystem::DirectoryPtr directory;
files_->OpenFileSystem("origin", GetProxy(&directory), std::move(client),
Capture(&error));
files_->OpenFileSystem("origin", GetProxy(&directory),
binding_.CreateInterfacePtrAndBind(), Capture(&error));
files_.WaitForIncomingResponse();
io_worker_thread_.reset(new SQLThread(std::move(directory)));

@ -53,10 +53,9 @@ ApplicationInstance::~ApplicationInstance() {
}
void ApplicationInstance::InitializeApplication() {
ShellPtr shell;
binding_.Bind(GetProxy(&shell));
application_->Initialize(binding_.CreateInterfacePtrAndBind(),
identity_.url().spec());
binding_.set_connection_error_handler([this]() { OnConnectionError(); });
application_->Initialize(std::move(shell), identity_.url().spec());
}
void ApplicationInstance::ConnectToClient(

@ -88,11 +88,7 @@ class ApplicationManagerAppTest : public mojo::test::ApplicationTestBase,
mojom::ApplicationManagerPtr application_manager;
application_impl()->ConnectToService("mojo:shell", &application_manager);
mojom::ApplicationManagerListenerPtr listener;
InterfaceRequest<mojom::ApplicationManagerListener> request =
GetProxy(&listener);
application_manager->AddListener(std::move(listener));
binding_.Bind(std::move(request));
application_manager->AddListener(binding_.CreateInterfacePtrAndBind());
binding_.WaitForIncomingMethodCall();
}

@ -198,12 +198,10 @@ ProxyResolverMojo::Job::Job(ProxyResolverMojo* resolver,
results_(results),
callback_(callback),
binding_(this) {
interfaces::ProxyResolverRequestClientPtr client_ptr;
binding_.Bind(mojo::GetProxy(&client_ptr));
resolver_->mojo_proxy_resolver_ptr_->GetProxyForUrl(
mojo::String::From(url_), binding_.CreateInterfacePtrAndBind());
binding_.set_connection_error_handler(base::Bind(
&ProxyResolverMojo::Job::OnConnectionError, base::Unretained(this)));
resolver_->mojo_proxy_resolver_ptr_->GetProxyForUrl(mojo::String::From(url_),
std::move(client_ptr));
}
ProxyResolverMojo::Job::~Job() {
@ -340,11 +338,9 @@ class ProxyResolverFactoryMojo::Job
callback_(callback),
binding_(this),
error_observer_(std::move(error_observer)) {
interfaces::ProxyResolverFactoryRequestClientPtr client_ptr;
binding_.Bind(mojo::GetProxy(&client_ptr));
on_delete_callback_runner_ = factory_->mojo_proxy_factory_->CreateResolver(
mojo::String::From(pac_script->utf16()), mojo::GetProxy(&resolver_ptr_),
std::move(client_ptr));
binding_.CreateInterfacePtrAndBind());
resolver_ptr_.set_connection_error_handler(
base::Bind(&ProxyResolverFactoryMojo::Job::OnConnectionError,
base::Unretained(this)));

@ -139,12 +139,10 @@ void SQLTestBase::SetUp() {
application_impl()->ConnectToService("mojo:filesystem", &files_);
filesystem::FileSystemClientPtr client;
binding_.Bind(GetProxy(&client));
filesystem::FileError error = filesystem::FileError::FAILED;
filesystem::DirectoryPtr directory;
files()->OpenFileSystem("temp", GetProxy(&directory), std::move(client),
files()->OpenFileSystem("temp", GetProxy(&directory),
binding_.CreateInterfacePtrAndBind(),
Capture(&error));
ASSERT_TRUE(files().WaitForIncomingResponse());
ASSERT_EQ(filesystem::FileError::OK, error);

@ -55,12 +55,10 @@ class VFSTest : public mojo::test::ApplicationTestBase,
application_impl()->ConnectToService("mojo:filesystem", &files_);
filesystem::FileSystemClientPtr client;
binding_.Bind(GetProxy(&client));
filesystem::FileError error = filesystem::FileError::FAILED;
filesystem::DirectoryPtr directory;
files_->OpenFileSystem("temp", GetProxy(&directory), std::move(client),
files_->OpenFileSystem("temp", GetProxy(&directory),
binding_.CreateInterfacePtrAndBind(),
mojo::Capture(&error));
ASSERT_TRUE(files_.WaitForIncomingResponse());
ASSERT_EQ(filesystem::FileError::OK, error);

@ -29,9 +29,7 @@ void ArcNotificationManager::OnNotificationsInstanceReady() {
return;
}
NotificationsHostPtr host;
binding_.Bind(mojo::GetProxy(&host));
notifications_instance->Init(std::move(host));
notifications_instance->Init(binding_.CreateInterfacePtrAndBind());
}
void ArcNotificationManager::OnNotificationPosted(ArcNotificationDataPtr data) {