Skip to content

Commit

Permalink
Mojo C++ Bindings: Remove redundant InterfaceRequest APIs
Browse files Browse the repository at this point in the history
Removes InterfaceRequest::Bind as it's redundant given the move
assignment operator and the new ctor over ScopedMessagePipeHandle.

Also removes the MakeRequest overload which takes a
ScopedMessagePipeHandle since

    MakeRequest<Foo>(pipe)

is strictly more verbose than

    FooRequest(pipe)

BUG=721507
R=yzshen@chromium.org
TBR=jam@chromium.org

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: Ic5cc4c8b926a2003c464abd0ddd29c8db347ce17
Reviewed-on: https://chromium-review.googlesource.com/505287
Reviewed-by: Ken Rockot <rockot@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#471552}
  • Loading branch information
krockot authored and Commit Bot committed May 13, 2017
1 parent af8ead2 commit f4d8a94
Show file tree
Hide file tree
Showing 78 changed files with 159 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ void GpuArcVideoServiceHost::OnBootstrapVideoAcceleratorFactory(

callback.Run(std::move(child_handle), token);

mojo::MakeStrongBinding(base::MakeUnique<VideoAcceleratorFactoryService>(),
mojo::MakeRequest<mojom::VideoAcceleratorFactory>(
std::move(server_pipe)));
mojo::MakeStrongBinding(
base::MakeUnique<VideoAcceleratorFactoryService>(),
mojom::VideoAcceleratorFactoryRequest(std::move(server_pipe)));
}

} // namespace arc
4 changes: 1 addition & 3 deletions chrome/browser/importer/external_process_importer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ ExternalProcessImporterClient::ExternalProcessImporterClient(
void ExternalProcessImporterClient::Start() {
AddRef(); // balanced in Cleanup.

chrome::mojom::ProfileImportRequest request(&profile_import_);

BrowserThread::ID thread_id;
CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id));
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&ExternalProcessImporterClient::StartProcessOnIOThread,
this, thread_id, base::Passed(std::move(request))));
this, thread_id, mojo::MakeRequest(&profile_import_)));

// Dictionary of all localized strings that could be needed by the importer
// in the external process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ class FakePasswordAutofillAgent
~FakePasswordAutofillAgent() override {}

void BindRequest(mojo::ScopedMessagePipeHandle handle) {
binding_.Bind(mojo::MakeRequest<autofill::mojom::PasswordAutofillAgent>(
std::move(handle)));
binding_.Bind(
autofill::mojom::PasswordAutofillAgentRequest(std::move(handle)));
}

bool called_set_logging_state() { return called_set_logging_state_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,17 +688,15 @@ base::Process SwReporterProcess::LaunchConnectedReporterProcess() {
if (!reporter_process.IsValid())
return reporter_process;

chrome_cleaner::mojom::ChromePromptRequest chrome_prompt_request;
chrome_prompt_request.Bind(std::move(mojo_pipe));

// ChromePromptImpl tasks will need to run on the IO thread. There is no
// need to synchronize its creation, since the client end will wait for this
// initialization to be done before sending requests.
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)
->PostTask(FROM_HERE,
base::BindOnce(&SwReporterProcess::CreateChromePromptImpl,
base::RetainedRef(this),
std::move(chrome_prompt_request)));
chrome_cleaner::mojom::ChromePromptRequest(
std::move(mojo_pipe))));

mojo::edk::ProcessErrorCallback on_connection_error =
g_testing_delegate_
Expand Down
10 changes: 4 additions & 6 deletions chrome/browser/task_manager/providers/child_process_task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ void ConnectResourceReporterOnIOThread(
ProcessResourceUsage* CreateProcessResourcesSampler(
int unique_child_process_id) {
chrome::mojom::ResourceUsageReporterPtr usage_reporter;
chrome::mojom::ResourceUsageReporterRequest request(&usage_reporter);
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&ConnectResourceReporterOnIOThread,
unique_child_process_id, base::Passed(&request)));

content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&ConnectResourceReporterOnIOThread,
unique_child_process_id,
mojo::MakeRequest(&usage_reporter)));
return new ProcessResourceUsage(std::move(usage_reporter));
}

Expand Down
3 changes: 1 addition & 2 deletions chrome/renderer/autofill/autofill_renderer_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ class AutofillRendererTest : public ChromeRenderViewTest {
}

void BindAutofillDriver(mojo::ScopedMessagePipeHandle handle) {
fake_driver_.BindRequest(
mojo::MakeRequest<mojom::AutofillDriver>(std::move(handle)));
fake_driver_.BindRequest(mojom::AutofillDriverRequest(std::move(handle)));
}

FakeContentAutofillDriver fake_driver_;
Expand Down
3 changes: 1 addition & 2 deletions chrome/renderer/autofill/form_autocomplete_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ class FormAutocompleteTest : public ChromeRenderViewTest {
}

void BindAutofillDriver(mojo::ScopedMessagePipeHandle handle) {
fake_driver_.BindRequest(
mojo::MakeRequest<mojom::AutofillDriver>(std::move(handle)));
fake_driver_.BindRequest(mojom::AutofillDriverRequest(std::move(handle)));
}

FakeContentAutofillDriver fake_driver_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ class PasswordAutofillAgentTest : public ChromeRenderViewTest {

void BindPasswordManagerDriver(mojo::ScopedMessagePipeHandle handle) {
fake_driver_.BindRequest(
mojo::MakeRequest<mojom::PasswordManagerDriver>(std::move(handle)));
mojom::PasswordManagerDriverRequest(std::move(handle)));
}

void BindPasswordManagerClient(mojo::ScopedInterfaceEndpointHandle handle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class PasswordGenerationAgentTest : public ChromeRenderViewTest {

void BindPasswordManagerDriver(mojo::ScopedMessagePipeHandle handle) {
fake_driver_.BindRequest(
mojo::MakeRequest<mojom::PasswordManagerDriver>(std::move(handle)));
mojom::PasswordManagerDriverRequest(std::move(handle)));
}

void BindPasswordManagerClient(mojo::ScopedInterfaceEndpointHandle handle) {
Expand Down
5 changes: 2 additions & 3 deletions chrome/renderer/chrome_render_frame_observer_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ class FakeContentTranslateDriver
~FakeContentTranslateDriver() override {}

void BindHandle(mojo::ScopedMessagePipeHandle handle) {
bindings_.AddBinding(
this, mojo::MakeRequest<translate::mojom::ContentTranslateDriver>(
std::move(handle)));
bindings_.AddBinding(this, translate::mojom::ContentTranslateDriverRequest(
std::move(handle)));
}

// translate::mojom::ContentTranslateDriver implementation.
Expand Down
5 changes: 2 additions & 3 deletions chrome/renderer/translate/translate_helper_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class FakeContentTranslateDriver
~FakeContentTranslateDriver() override {}

void BindHandle(mojo::ScopedMessagePipeHandle handle) {
bindings_.AddBinding(
this, mojo::MakeRequest<translate::mojom::ContentTranslateDriver>(
std::move(handle)));
bindings_.AddBinding(this, translate::mojom::ContentTranslateDriverRequest(
std::move(handle)));
}

// translate::mojom::ContentTranslateDriver implementation.
Expand Down
5 changes: 2 additions & 3 deletions chrome/test/base/mojo_test_connector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ class MojoTestState : public content::TestState {
background_service_manager_->RegisterService(
service_manager::Identity(content::mojom::kPackagedServicesServiceName,
service_manager::mojom::kRootUserID),
std::move(service_),
service_manager::mojom::PIDReceiverRequest(&pid_receiver_));
std::move(service_), mojo::MakeRequest(&pid_receiver_));

DCHECK(pid_receiver_.is_bound());
pid_receiver_->SetPID(pid);
Expand Down Expand Up @@ -216,7 +215,7 @@ service_manager::mojom::ServiceRequest MojoTestConnector::Init() {
}

service_manager::mojom::ServicePtr service;
service_manager::mojom::ServiceRequest request(&service);
auto request = mojo::MakeRequest(&service);

// BackgroundServiceManager must be created after mojo::edk::Init() as it
// attempts to create mojo pipes for the provided catalog on a separate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
~FakeAutofillAgent() override {}

void BindRequest(mojo::ScopedMessagePipeHandle handle) {
bindings_.AddBinding(
this, mojo::MakeRequest<mojom::AutofillAgent>(std::move(handle)));
bindings_.AddBinding(this, mojom::AutofillAgentRequest(std::move(handle)));
}

void SetQuitLoopClosure(base::Closure closure) { quit_closure_ = closure; }
Expand Down
6 changes: 2 additions & 4 deletions components/leveldb/leveldb_mojo_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ void LevelDBMojoProxy::GetChildrenImpl(
filesystem::mojom::FileError* out_error) {
mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync;
filesystem::mojom::DirectoryPtr target;
filesystem::mojom::DirectoryRequest proxy(&target);
bool completed = dir->directory->OpenDirectory(
name, std::move(proxy),
name, mojo::MakeRequest(&target),
filesystem::mojom::kFlagRead | filesystem::mojom::kFlagWrite, out_error);
DCHECK(completed);

Expand Down Expand Up @@ -304,8 +303,7 @@ void LevelDBMojoProxy::LockFileImpl(OpaqueDir* dir,
// Since a lock is associated with a file descriptor, we need to open and
// have a persistent file on the other side of the connection.
filesystem::mojom::FilePtr target;
filesystem::mojom::FileRequest proxy(&target);
bool completed = dir->directory->OpenFile(path, std::move(proxy),
bool completed = dir->directory->OpenFile(path, mojo::MakeRequest(&target),
filesystem::mojom::kFlagOpenAlways |
filesystem::mojom::kFlagRead |
filesystem::mojom::kFlagWrite,
Expand Down
6 changes: 3 additions & 3 deletions components/metrics/single_sample_metrics_factory_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ SingleSampleMetricsFactoryImpl::CreateMetric(const std::string& histogram_name,
uint32_t bucket_count,
int32_t flags) {
mojom::SingleSampleMetricPtr metric;
GetProvider()->AcquireSingleSampleMetric(
histogram_name, min, max, bucket_count, flags,
mojo::MakeRequest<mojom::SingleSampleMetric>(&metric));
GetProvider()->AcquireSingleSampleMetric(histogram_name, min, max,
bucket_count, flags,
mojo::MakeRequest(&metric));
return base::MakeUnique<SingleSampleMetricImpl>(std::move(metric));
}

Expand Down
3 changes: 1 addition & 2 deletions components/nacl/common/nacl_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ service_manager::mojom::ServiceRequest ConnectToServiceManager(
mojo::ScopedMessagePipeHandle parent_handle =
invitation->ExtractMessagePipe(service_request_channel_token);
DCHECK(parent_handle.is_valid());
return mojo::MakeRequest<service_manager::mojom::Service>(
std::move(parent_handle));
return service_manager::mojom::ServiceRequest(std::move(parent_handle));
}

void ConnectBootstrapChannel(IPC::mojom::ChannelBootstrapPtrInfo ptr,
Expand Down
5 changes: 2 additions & 3 deletions components/nacl/renderer/ppb_nacl_private_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,8 @@ void PPBNaClPrivate::LaunchSelLdr(
std::unique_ptr<TrustedPluginChannel> trusted_plugin_channel(
new TrustedPluginChannel(
load_manager,
mojo::MakeRequest<mojom::NaClRendererHost>(
mojo::ScopedMessagePipeHandle(
launch_result.trusted_ipc_channel_handle.mojo_handle)),
mojom::NaClRendererHostRequest(mojo::ScopedMessagePipeHandle(
launch_result.trusted_ipc_channel_handle.mojo_handle)),
is_helper_nexe));
load_manager->set_trusted_plugin_channel(std::move(trusted_plugin_channel));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,8 @@ ContentPasswordManagerDriver::GetAutofillAgent() {
const autofill::mojom::PasswordAutofillAgentPtr&
ContentPasswordManagerDriver::GetPasswordAutofillAgent() {
if (!password_autofill_agent_) {
autofill::mojom::PasswordAutofillAgentRequest request(
&password_autofill_agent_);
// Some test codes may have no initialized remote interfaces.
auto request = mojo::MakeRequest(&password_autofill_agent_);
// Some test environments may have no remote interface support.
if (render_frame_host_->GetRemoteInterfaces()) {
render_frame_host_->GetRemoteInterfaces()->GetInterface(
std::move(request));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class FakePasswordAutofillAgent
~FakePasswordAutofillAgent() override {}

void BindRequest(mojo::ScopedMessagePipeHandle handle) {
binding_.Bind(mojo::MakeRequest<autofill::mojom::PasswordAutofillAgent>(
std::move(handle)));
binding_.Bind(
autofill::mojom::PasswordAutofillAgentRequest(std::move(handle)));
}

bool called_set_logging_state() { return called_set_logging_state_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ class CredentialManagerClientTest : public content::RenderViewTest {
void set_callback_succeeded(bool state) { callback_succeeded_ = state; }

void BindCredentialManager(mojo::ScopedMessagePipeHandle handle) {
fake_cm_.BindRequest(
mojo::MakeRequest<mojom::CredentialManager>(std::move(handle)));
fake_cm_.BindRequest(mojom::CredentialManagerRequest(std::move(handle)));
}

std::unique_ptr<blink::WebPasswordCredential> credential_;
Expand Down
3 changes: 1 addition & 2 deletions components/visitedlink/test/visitedlink_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,7 @@ class VisitCountingContext : public mojom::VisitedLinkNotificationSink {
binding_(this) {}

void Bind(mojo::ScopedMessagePipeHandle handle) {
binding_.Bind(mojo::MakeRequest<mojom::VisitedLinkNotificationSink>(
std::move(handle)));
binding_.Bind(mojom::VisitedLinkNotificationSinkRequest(std::move(handle)));
}

void WaitForUpdate() {
Expand Down
2 changes: 1 addition & 1 deletion content/browser/browser_child_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ service_manager::mojom::ServiceRequest
BrowserChildProcessHostImpl::TakeInProcessServiceRequest() {
DCHECK(broker_client_invitation_);
auto invitation = std::move(broker_client_invitation_);
return mojo::MakeRequest<service_manager::mojom::Service>(
return service_manager::mojom::ServiceRequest(
invitation->ExtractInProcessMessagePipe(
child_connection_->service_token()));
}
Expand Down
2 changes: 1 addition & 1 deletion content/browser/browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void BrowserContext::Initialize(
// Mojo or the global service manager connection.

service_manager::mojom::ServicePtr service;
service_manager::mojom::ServiceRequest service_request(&service);
auto service_request = mojo::MakeRequest(&service);

service_manager::mojom::PIDReceiverPtr pid_receiver;
service_manager::Identity identity(mojom::kBrowserServiceName, new_id);
Expand Down
4 changes: 1 addition & 3 deletions content/browser/frame_host/render_frame_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3141,11 +3141,9 @@ void RenderFrameHostImpl::SetUpMojoIfNeeded() {
frame_host_interface_broker_binding_.CreateInterfacePtrAndBind());

service_manager::mojom::InterfaceProviderPtr remote_interfaces;
service_manager::mojom::InterfaceProviderRequest remote_interfaces_request(
&remote_interfaces);
frame_->GetInterfaceProvider(mojo::MakeRequest(&remote_interfaces));
remote_interfaces_.reset(new service_manager::InterfaceProvider);
remote_interfaces_->Bind(std::move(remote_interfaces));
frame_->GetInterfaceProvider(std::move(remote_interfaces_request));
}

void RenderFrameHostImpl::InvalidateMojoConnection() {
Expand Down
8 changes: 4 additions & 4 deletions content/browser/gpu/gpu_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,10 @@ bool GpuProcessHost::Init() {
process_->child_channel()
->GetAssociatedInterfaceSupport()
->GetRemoteAssociatedInterface(&gpu_main_ptr_);
ui::mojom::GpuServiceRequest request(&gpu_service_ptr_);
gpu_main_ptr_->CreateGpuService(
std::move(request), gpu_host_binding_.CreateInterfacePtrAndBind(),
gpu_preferences, activity_flags_.CloneHandle());
gpu_main_ptr_->CreateGpuService(mojo::MakeRequest(&gpu_service_ptr_),
gpu_host_binding_.CreateInterfacePtrAndBind(),
gpu_preferences,
activity_flags_.CloneHandle());

#if defined(USE_OZONE)
// Ozone needs to send the primary DRM device to GPU process as early as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ TEST(RenderFrameAudioOutputStreamFactoryTest, CreateStream) {
EXPECT_TRUE(id.empty());

provider->Acquire(
mojo::MakeRequest<AudioOutputStream>(&output_stream), params,
mojo::MakeRequest(&output_stream), params,
base::Bind(&MockClient::StreamCreated, base::Unretained(&client)));
base::RunLoop().RunUntilIdle();
ASSERT_NE(event_handler, nullptr);
Expand Down Expand Up @@ -291,8 +291,7 @@ TEST(RenderFrameAudioOutputStreamFactoryTest, ConnectionError_DeletesStream) {
base::RunLoop().RunUntilIdle();

provider->Acquire(
mojo::MakeRequest<AudioOutputStream>(&output_stream),
GetTestAudioParameters(),
mojo::MakeRequest(&output_stream), GetTestAudioParameters(),
base::Bind(&MockClient::StreamCreated, base::Unretained(&client)));
base::RunLoop().RunUntilIdle();
ASSERT_NE(event_handler, nullptr);
Expand Down Expand Up @@ -325,8 +324,7 @@ TEST(RenderFrameAudioOutputStreamFactoryTest, DelegateError_DeletesStream) {
base::RunLoop().RunUntilIdle();

provider->Acquire(
mojo::MakeRequest<AudioOutputStream>(&output_stream),
GetTestAudioParameters(),
mojo::MakeRequest(&output_stream), GetTestAudioParameters(),
base::Bind(&MockClient::StreamCreated, base::Unretained(&client)));
base::RunLoop().RunUntilIdle();
ASSERT_NE(event_handler, nullptr);
Expand Down
3 changes: 1 addition & 2 deletions content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1052,9 +1052,8 @@ void RenderProcessHostImpl::InitializeChannelProxy() {
// ServiceManagerConnection prior to this point. This class of test code
// doesn't care about render processes, so we can initialize a dummy
// connection.
service_manager::mojom::ServiceRequest request(&test_service_);
ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create(
std::move(request), io_task_runner));
mojo::MakeRequest(&test_service_), io_task_runner));
}
connector = ServiceManagerConnection::GetForProcess()->GetConnector();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::
void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::Bind(
const base::WeakPtr<EmbeddedWorkerTestHelper>& helper,
mojo::ScopedMessagePipeHandle request_handle) {
mojom::EmbeddedWorkerInstanceClientRequest request =
mojo::MakeRequest<mojom::EmbeddedWorkerInstanceClient>(
std::move(request_handle));
mojom::EmbeddedWorkerInstanceClientRequest request(std::move(request_handle));
std::vector<std::unique_ptr<MockEmbeddedWorkerInstanceClient>>* clients =
helper->mock_instance_clients();
size_t next_client_index = helper->mock_instance_clients_next_index_;
Expand Down
9 changes: 4 additions & 5 deletions content/child/child_thread_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ class ChannelBootstrapFilter : public ConnectionFilter {

if (interface_name == IPC::mojom::ChannelBootstrap::Name_) {
DCHECK(bootstrap_.is_valid());
mojo::FuseInterface(mojo::MakeRequest<IPC::mojom::ChannelBootstrap>(
std::move(*interface_pipe)),
std::move(bootstrap_));
mojo::FuseInterface(
IPC::mojom::ChannelBootstrapRequest(std::move(*interface_pipe)),
std::move(bootstrap_));
}
}

Expand Down Expand Up @@ -459,8 +459,7 @@ void ChildThreadImpl::Init(const Options& options) {

if (service_request_pipe.is_valid()) {
service_manager_connection_ = ServiceManagerConnection::Create(
mojo::MakeRequest<service_manager::mojom::Service>(
std::move(service_request_pipe)),
service_manager::mojom::ServiceRequest(std::move(service_request_pipe)),
GetIOTaskRunner());
}

Expand Down
3 changes: 1 addition & 2 deletions content/common/service_manager/child_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class ChildConnection::IOThreadContext
service_manager::mojom::ServicePtr service;
service.Bind(mojo::InterfacePtrInfo<service_manager::mojom::Service>(
std::move(service_pipe), 0u));
service_manager::mojom::PIDReceiverRequest pid_receiver_request(
&pid_receiver_);
auto pid_receiver_request = mojo::MakeRequest(&pid_receiver_);

if (connector_) {
connector_->StartService(child_identity, std::move(service),
Expand Down
Loading

0 comments on commit f4d8a94

Please sign in to comment.