Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: content/child/child_thread_impl.cc

Issue 2109043002: Eliminate the ChannelMojo channel for renderers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 return browser_process_io_runner_; 347 return browser_process_io_runner_;
348 return ChildProcess::current()->io_task_runner(); 348 return ChildProcess::current()->io_task_runner();
349 } 349 }
350 350
351 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel, 351 void ChildThreadImpl::ConnectChannel(bool use_mojo_channel,
352 const std::string& ipc_token) { 352 const std::string& ipc_token) {
353 bool create_pipe_now = true; 353 bool create_pipe_now = true;
354 if (use_mojo_channel) { 354 if (use_mojo_channel) {
355 VLOG(1) << "Mojo is enabled on child"; 355 VLOG(1) << "Mojo is enabled on child";
356 mojo::ScopedMessagePipeHandle handle; 356 mojo::ScopedMessagePipeHandle handle;
357 if (!IsInBrowserProcess()) { 357 std::string token = IsInBrowserProcess() ? ipc_token :
358 DCHECK(!handle.is_valid()); 358 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
359 handle = mojo::edk::CreateChildMessagePipe( 359 switches::kMojoChannelToken);
360 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 360 if (token.empty()) {
361 switches::kMojoChannelToken)); 361 IPC::mojom::BootstrapRequest request = GetProxy(&pending_bootstrap_);
362 handle = request.PassMessagePipe();
362 } else { 363 } else {
363 handle = mojo::edk::CreateChildMessagePipe(ipc_token); 364 handle = mojo::edk::CreateChildMessagePipe(token);
364 } 365 }
365 DCHECK(handle.is_valid()); 366 DCHECK(handle.is_valid());
366 channel_->Init(IPC::ChannelMojo::CreateClientFactory(std::move(handle)), 367 channel_->Init(IPC::ChannelMojo::CreateClientFactory(std::move(handle)),
367 create_pipe_now); 368 create_pipe_now);
368 return; 369 return;
369 } 370 }
370 371
371 VLOG(1) << "Mojo is disabled on child"; 372 VLOG(1) << "Mojo is disabled on child";
372 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now); 373 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now);
373 } 374 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 590 }
590 591
591 void ChildThreadImpl::RecordComputedAction(const std::string& action) { 592 void ChildThreadImpl::RecordComputedAction(const std::string& action) {
592 NOTREACHED(); 593 NOTREACHED();
593 } 594 }
594 595
595 MojoShellConnection* ChildThreadImpl::GetMojoShellConnection() { 596 MojoShellConnection* ChildThreadImpl::GetMojoShellConnection() {
596 return mojo_shell_connection_.get(); 597 return mojo_shell_connection_.get();
597 } 598 }
598 599
600 bool ChildThreadImpl::AcceptConnection(shell::Connection* connection) {
601 connection->GetInterfaceRegistry()->AddInterface(
602 IPC::mojom::Bootstrap::Name_,
603 base::Bind(&ChildThreadImpl::BindBootstrapRequest,
604 base::Unretained(this)));
605 return true;
606 }
607
599 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() { 608 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() {
600 if (!interface_registry_.get()) 609 if (!interface_registry_.get())
601 interface_registry_.reset(new shell::InterfaceRegistry(nullptr)); 610 interface_registry_.reset(new shell::InterfaceRegistry(nullptr));
602 return interface_registry_.get(); 611 return interface_registry_.get();
603 } 612 }
604 613
605 shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() { 614 shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() {
606 if (!remote_interfaces_.get()) 615 if (!remote_interfaces_.get())
607 remote_interfaces_.reset(new shell::InterfaceProvider); 616 remote_interfaces_.reset(new shell::InterfaceProvider);
608 return remote_interfaces_.get(); 617 return remote_interfaces_.get();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 // race conditions if the process refcount is 0 but there's an IPC message 770 // race conditions if the process refcount is 0 but there's an IPC message
762 // inflight that would addref it. 771 // inflight that would addref it.
763 Send(new ChildProcessHostMsg_ShutdownRequest); 772 Send(new ChildProcessHostMsg_ShutdownRequest);
764 } 773 }
765 774
766 void ChildThreadImpl::EnsureConnected() { 775 void ChildThreadImpl::EnsureConnected() {
767 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 776 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
768 base::Process::Current().Terminate(0, false); 777 base::Process::Current().Terminate(0, false);
769 } 778 }
770 779
780 void ChildThreadImpl::BindBootstrapRequest(
781 mojo::ScopedMessagePipeHandle handle) {
782 IPC::mojom::BootstrapRequest request =
783 mojo::MakeRequest<IPC::mojom::Bootstrap>(std::move(handle));
784 mojo::FuseInterface(std::move(request), pending_bootstrap_.PassInterface());
785 }
786
771 bool ChildThreadImpl::IsInBrowserProcess() const { 787 bool ChildThreadImpl::IsInBrowserProcess() const {
772 return static_cast<bool>(browser_process_io_runner_); 788 return static_cast<bool>(browser_process_io_runner_);
773 } 789 }
774 790
775 } // namespace content 791 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698