| OLD | NEW |
| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "ipc/ipc_channel_mojo.h" | 61 #include "ipc/ipc_channel_mojo.h" |
| 62 #include "ipc/ipc_logging.h" | 62 #include "ipc/ipc_logging.h" |
| 63 #include "ipc/ipc_platform_file.h" | 63 #include "ipc/ipc_platform_file.h" |
| 64 #include "ipc/ipc_switches.h" | 64 #include "ipc/ipc_switches.h" |
| 65 #include "ipc/ipc_sync_channel.h" | 65 #include "ipc/ipc_sync_channel.h" |
| 66 #include "ipc/ipc_sync_message_filter.h" | 66 #include "ipc/ipc_sync_message_filter.h" |
| 67 #include "mojo/edk/embedder/embedder.h" | 67 #include "mojo/edk/embedder/embedder.h" |
| 68 #include "mojo/edk/embedder/named_platform_channel_pair.h" | 68 #include "mojo/edk/embedder/named_platform_channel_pair.h" |
| 69 #include "mojo/edk/embedder/platform_channel_pair.h" | 69 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 70 #include "mojo/edk/embedder/scoped_ipc_support.h" | 70 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 71 #include "services/shell/public/cpp/connector.h" |
| 71 #include "services/shell/public/cpp/interface_provider.h" | 72 #include "services/shell/public/cpp/interface_provider.h" |
| 72 #include "services/shell/public/cpp/interface_registry.h" | 73 #include "services/shell/public/cpp/interface_registry.h" |
| 73 #include "services/shell/runner/common/client_util.h" | 74 #include "services/shell/runner/common/client_util.h" |
| 74 | 75 |
| 75 #if defined(OS_POSIX) | 76 #if defined(OS_POSIX) |
| 76 #include "base/posix/global_descriptors.h" | 77 #include "base/posix/global_descriptors.h" |
| 77 #include "content/public/common/content_descriptors.h" | 78 #include "content/public/common/content_descriptors.h" |
| 78 #endif | 79 #endif |
| 79 | 80 |
| 80 using tracked_objects::ThreadData; | 81 using tracked_objects::ThreadData; |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 } else { | 425 } else { |
| 425 mojo_application_token = options.in_process_application_token; | 426 mojo_application_token = options.in_process_application_token; |
| 426 } | 427 } |
| 427 if (!mojo_application_token.empty()) { | 428 if (!mojo_application_token.empty()) { |
| 428 mojo::ScopedMessagePipeHandle handle = | 429 mojo::ScopedMessagePipeHandle handle = |
| 429 mojo::edk::CreateChildMessagePipe(mojo_application_token); | 430 mojo::edk::CreateChildMessagePipe(mojo_application_token); |
| 430 DCHECK(handle.is_valid()); | 431 DCHECK(handle.is_valid()); |
| 431 mojo_shell_connection_ = MojoShellConnection::Create( | 432 mojo_shell_connection_ = MojoShellConnection::Create( |
| 432 mojo::MakeRequest<shell::mojom::Service>(std::move(handle)), | 433 mojo::MakeRequest<shell::mojom::Service>(std::move(handle)), |
| 433 GetIOTaskRunner()); | 434 GetIOTaskRunner()); |
| 435 browser_connection_ = |
| 436 mojo_shell_connection_->GetConnector()->Connect("exe:content_browser"); |
| 434 | 437 |
| 435 // TODO(rockot): Remove this once all child-to-browser interface connections | 438 // TODO(rockot): Remove this once all child-to-browser interface connections |
| 436 // are made via a Connector rather than directly through an | 439 // are made via a Connector rather than directly through an |
| 437 // InterfaceProvider, and all exposed interfaces are exposed via a | 440 // InterfaceProvider, and all exposed interfaces are exposed via a |
| 438 // ConnectionFilter. | 441 // ConnectionFilter. |
| 439 mojo_shell_connection_->SetupInterfaceRequestProxies( | 442 mojo_shell_connection_->SetupInterfaceRequestProxies( |
| 440 GetInterfaceRegistry(), GetRemoteInterfaces()); | 443 GetInterfaceRegistry(), nullptr); |
| 441 | 444 |
| 442 if (options.auto_start_mojo_shell_connection) | 445 if (options.auto_start_mojo_shell_connection) |
| 443 StartMojoShellConnection(); | 446 StartMojoShellConnection(); |
| 444 } | 447 } |
| 445 | 448 |
| 446 sync_message_filter_ = channel_->CreateSyncMessageFilter(); | 449 sync_message_filter_ = channel_->CreateSyncMessageFilter(); |
| 447 thread_safe_sender_ = new ThreadSafeSender( | 450 thread_safe_sender_ = new ThreadSafeSender( |
| 448 message_loop_->task_runner(), sync_message_filter_.get()); | 451 message_loop_->task_runner(), sync_message_filter_.get()); |
| 449 | 452 |
| 450 resource_dispatcher_.reset(new ResourceDispatcher( | 453 resource_dispatcher_.reset(new ResourceDispatcher( |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 return mojo_shell_connection_.get(); | 622 return mojo_shell_connection_.get(); |
| 620 } | 623 } |
| 621 | 624 |
| 622 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() { | 625 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() { |
| 623 if (!interface_registry_.get()) | 626 if (!interface_registry_.get()) |
| 624 interface_registry_.reset(new shell::InterfaceRegistry(nullptr)); | 627 interface_registry_.reset(new shell::InterfaceRegistry(nullptr)); |
| 625 return interface_registry_.get(); | 628 return interface_registry_.get(); |
| 626 } | 629 } |
| 627 | 630 |
| 628 shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() { | 631 shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() { |
| 629 if (!remote_interfaces_.get()) | 632 return browser_connection_->GetRemoteInterfaces(); |
| 630 remote_interfaces_.reset(new shell::InterfaceProvider); | |
| 631 return remote_interfaces_.get(); | |
| 632 } | 633 } |
| 633 | 634 |
| 634 IPC::MessageRouter* ChildThreadImpl::GetRouter() { | 635 IPC::MessageRouter* ChildThreadImpl::GetRouter() { |
| 635 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread()); | 636 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread()); |
| 636 return &router_; | 637 return &router_; |
| 637 } | 638 } |
| 638 | 639 |
| 639 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( | 640 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( |
| 640 size_t buf_size) { | 641 size_t buf_size) { |
| 641 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread()); | 642 DCHECK(message_loop_->task_runner()->BelongsToCurrentThread()); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 void ChildThreadImpl::EnsureConnected() { | 787 void ChildThreadImpl::EnsureConnected() { |
| 787 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; | 788 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; |
| 788 base::Process::Current().Terminate(0, false); | 789 base::Process::Current().Terminate(0, false); |
| 789 } | 790 } |
| 790 | 791 |
| 791 bool ChildThreadImpl::IsInBrowserProcess() const { | 792 bool ChildThreadImpl::IsInBrowserProcess() const { |
| 792 return static_cast<bool>(browser_process_io_runner_); | 793 return static_cast<bool>(browser_process_io_runner_); |
| 793 } | 794 } |
| 794 | 795 |
| 795 } // namespace content | 796 } // namespace content |
| OLD | NEW |