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

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

Issue 2111673006: Revert of 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 std::string token = IsInBrowserProcess() ? ipc_token : 357 if (!IsInBrowserProcess()) {
358 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 358 DCHECK(!handle.is_valid());
359 switches::kMojoChannelToken); 359 handle = mojo::edk::CreateChildMessagePipe(
360 if (token.empty()) { 360 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
361 IPC::mojom::BootstrapRequest request = GetProxy(&pending_bootstrap_); 361 switches::kMojoChannelToken));
362 handle = request.PassMessagePipe();
363 } else { 362 } else {
364 handle = mojo::edk::CreateChildMessagePipe(token); 363 handle = mojo::edk::CreateChildMessagePipe(ipc_token);
365 } 364 }
366 DCHECK(handle.is_valid()); 365 DCHECK(handle.is_valid());
367 channel_->Init(IPC::ChannelMojo::CreateClientFactory(std::move(handle)), 366 channel_->Init(IPC::ChannelMojo::CreateClientFactory(std::move(handle)),
368 create_pipe_now); 367 create_pipe_now);
369 return; 368 return;
370 } 369 }
371 370
372 VLOG(1) << "Mojo is disabled on child"; 371 VLOG(1) << "Mojo is disabled on child";
373 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now); 372 channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now);
374 } 373 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 589 }
591 590
592 void ChildThreadImpl::RecordComputedAction(const std::string& action) { 591 void ChildThreadImpl::RecordComputedAction(const std::string& action) {
593 NOTREACHED(); 592 NOTREACHED();
594 } 593 }
595 594
596 MojoShellConnection* ChildThreadImpl::GetMojoShellConnection() { 595 MojoShellConnection* ChildThreadImpl::GetMojoShellConnection() {
597 return mojo_shell_connection_.get(); 596 return mojo_shell_connection_.get();
598 } 597 }
599 598
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
608 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() { 599 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() {
609 if (!interface_registry_.get()) 600 if (!interface_registry_.get())
610 interface_registry_.reset(new shell::InterfaceRegistry(nullptr)); 601 interface_registry_.reset(new shell::InterfaceRegistry(nullptr));
611 return interface_registry_.get(); 602 return interface_registry_.get();
612 } 603 }
613 604
614 shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() { 605 shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() {
615 if (!remote_interfaces_.get()) 606 if (!remote_interfaces_.get())
616 remote_interfaces_.reset(new shell::InterfaceProvider); 607 remote_interfaces_.reset(new shell::InterfaceProvider);
617 return remote_interfaces_.get(); 608 return remote_interfaces_.get();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 // race conditions if the process refcount is 0 but there's an IPC message 761 // race conditions if the process refcount is 0 but there's an IPC message
771 // inflight that would addref it. 762 // inflight that would addref it.
772 Send(new ChildProcessHostMsg_ShutdownRequest); 763 Send(new ChildProcessHostMsg_ShutdownRequest);
773 } 764 }
774 765
775 void ChildThreadImpl::EnsureConnected() { 766 void ChildThreadImpl::EnsureConnected() {
776 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 767 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
777 base::Process::Current().Terminate(0, false); 768 base::Process::Current().Terminate(0, false);
778 } 769 }
779 770
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
787 bool ChildThreadImpl::IsInBrowserProcess() const { 771 bool ChildThreadImpl::IsInBrowserProcess() const {
788 return static_cast<bool>(browser_process_io_runner_); 772 return static_cast<bool>(browser_process_io_runner_);
789 } 773 }
790 774
791 } // namespace content 775 } // 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