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

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

Issue 2096643002: Eliminate MojoApplicationHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mah3
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/child/mojo/mojo_application.h » ('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 23 matching lines...) Expand all
34 #include "components/tracing/child/child_trace_message_filter.h" 34 #include "components/tracing/child/child_trace_message_filter.h"
35 #include "content/child/child_discardable_shared_memory_manager.h" 35 #include "content/child/child_discardable_shared_memory_manager.h"
36 #include "content/child/child_gpu_memory_buffer_manager.h" 36 #include "content/child/child_gpu_memory_buffer_manager.h"
37 #include "content/child/child_histogram_message_filter.h" 37 #include "content/child/child_histogram_message_filter.h"
38 #include "content/child/child_process.h" 38 #include "content/child/child_process.h"
39 #include "content/child/child_resource_message_filter.h" 39 #include "content/child/child_resource_message_filter.h"
40 #include "content/child/child_shared_bitmap_manager.h" 40 #include "content/child/child_shared_bitmap_manager.h"
41 #include "content/child/fileapi/file_system_dispatcher.h" 41 #include "content/child/fileapi/file_system_dispatcher.h"
42 #include "content/child/fileapi/webfilesystem_impl.h" 42 #include "content/child/fileapi/webfilesystem_impl.h"
43 #include "content/child/memory/child_memory_message_filter.h" 43 #include "content/child/memory/child_memory_message_filter.h"
44 #include "content/child/mojo/mojo_application.h"
45 #include "content/child/notifications/notification_dispatcher.h" 44 #include "content/child/notifications/notification_dispatcher.h"
46 #include "content/child/power_monitor_broadcast_source.h" 45 #include "content/child/power_monitor_broadcast_source.h"
47 #include "content/child/push_messaging/push_dispatcher.h" 46 #include "content/child/push_messaging/push_dispatcher.h"
48 #include "content/child/quota_dispatcher.h" 47 #include "content/child/quota_dispatcher.h"
49 #include "content/child/quota_message_filter.h" 48 #include "content/child/quota_message_filter.h"
50 #include "content/child/resource_dispatcher.h" 49 #include "content/child/resource_dispatcher.h"
51 #include "content/child/service_worker/service_worker_message_filter.h" 50 #include "content/child/service_worker/service_worker_message_filter.h"
52 #include "content/child/thread_safe_sender.h" 51 #include "content/child/thread_safe_sender.h"
53 #include "content/child/websocket_dispatcher.h" 52 #include "content/child/websocket_dispatcher.h"
54 #include "content/child/websocket_message_filter.h" 53 #include "content/child/websocket_message_filter.h"
55 #include "content/common/child_process_messages.h" 54 #include "content/common/child_process_messages.h"
56 #include "content/common/in_process_child_thread_params.h" 55 #include "content/common/in_process_child_thread_params.h"
57 #include "content/common/mojo/mojo_shell_connection_impl.h"
58 #include "content/public/common/content_switches.h" 56 #include "content/public/common/content_switches.h"
59 #include "content/public/common/mojo_channel_switches.h" 57 #include "content/public/common/mojo_channel_switches.h"
58 #include "content/public/common/mojo_shell_connection.h"
60 #include "ipc/attachment_broker.h" 59 #include "ipc/attachment_broker.h"
61 #include "ipc/attachment_broker_unprivileged.h" 60 #include "ipc/attachment_broker_unprivileged.h"
62 #include "ipc/ipc_channel_mojo.h" 61 #include "ipc/ipc_channel_mojo.h"
63 #include "ipc/ipc_logging.h" 62 #include "ipc/ipc_logging.h"
64 #include "ipc/ipc_platform_file.h" 63 #include "ipc/ipc_platform_file.h"
65 #include "ipc/ipc_switches.h" 64 #include "ipc/ipc_switches.h"
66 #include "ipc/ipc_sync_channel.h" 65 #include "ipc/ipc_sync_channel.h"
67 #include "ipc/ipc_sync_message_filter.h" 66 #include "ipc/ipc_sync_message_filter.h"
68 #include "mojo/edk/embedder/embedder.h" 67 #include "mojo/edk/embedder/embedder.h"
69 #include "mojo/edk/embedder/named_platform_channel_pair.h" 68 #include "mojo/edk/embedder/named_platform_channel_pair.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 #ifdef IPC_MESSAGE_LOG_ENABLED 393 #ifdef IPC_MESSAGE_LOG_ENABLED
395 if (!IsInBrowserProcess()) 394 if (!IsInBrowserProcess())
396 IPC::Logging::GetInstance()->SetIPCSender(this); 395 IPC::Logging::GetInstance()->SetIPCSender(this);
397 #endif 396 #endif
398 397
399 if (!IsInBrowserProcess()) { 398 if (!IsInBrowserProcess()) {
400 // Don't double-initialize IPC support in single-process mode. 399 // Don't double-initialize IPC support in single-process mode.
401 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport(GetIOTaskRunner())); 400 mojo_ipc_support_.reset(new mojo::edk::ScopedIPCSupport(GetIOTaskRunner()));
402 InitializeMojoIPCChannel(); 401 InitializeMojoIPCChannel();
403 } 402 }
404 if (shell::ShellIsRemote()) {
405 MojoShellConnection::SetForProcess(
406 MojoShellConnection::Create(
407 shell::GetShellClientRequestFromCommandLine()));
408 }
409 mojo_application_.reset(new MojoApplication());
410 std::string mojo_application_token; 403 std::string mojo_application_token;
411 if (!IsInBrowserProcess()) { 404 if (!IsInBrowserProcess()) {
412 mojo_application_token = 405 mojo_application_token =
413 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 406 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
414 switches::kMojoApplicationChannelToken); 407 switches::kMojoApplicationChannelToken);
415 } else { 408 } else {
416 mojo_application_token = options.in_process_application_token; 409 mojo_application_token = options.in_process_application_token;
417 } 410 }
418 if (!mojo_application_token.empty()) 411 mojo::ScopedMessagePipeHandle handle =
419 mojo_application_->InitWithToken(mojo_application_token); 412 mojo::edk::CreateChildMessagePipe(mojo_application_token);
413 DCHECK(handle.is_valid());
414 mojo_shell_connection_ = MojoShellConnection::Create(
415 mojo::MakeRequest<shell::mojom::ShellClient>(std::move(handle)));
416 mojo_shell_connection_->AddEmbeddedShellClient(this);
420 417
421 sync_message_filter_ = channel_->CreateSyncMessageFilter(); 418 sync_message_filter_ = channel_->CreateSyncMessageFilter();
422 thread_safe_sender_ = new ThreadSafeSender( 419 thread_safe_sender_ = new ThreadSafeSender(
423 message_loop_->task_runner(), sync_message_filter_.get()); 420 message_loop_->task_runner(), sync_message_filter_.get());
424 421
425 resource_dispatcher_.reset(new ResourceDispatcher( 422 resource_dispatcher_.reset(new ResourceDispatcher(
426 this, message_loop()->task_runner())); 423 this, message_loop()->task_runner()));
427 websocket_dispatcher_.reset(new WebSocketDispatcher); 424 websocket_dispatcher_.reset(new WebSocketDispatcher);
428 file_system_dispatcher_.reset(new FileSystemDispatcher()); 425 file_system_dispatcher_.reset(new FileSystemDispatcher());
429 426
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 #endif 583 #endif
587 584
588 void ChildThreadImpl::RecordAction(const base::UserMetricsAction& action) { 585 void ChildThreadImpl::RecordAction(const base::UserMetricsAction& action) {
589 NOTREACHED(); 586 NOTREACHED();
590 } 587 }
591 588
592 void ChildThreadImpl::RecordComputedAction(const std::string& action) { 589 void ChildThreadImpl::RecordComputedAction(const std::string& action) {
593 NOTREACHED(); 590 NOTREACHED();
594 } 591 }
595 592
593 MojoShellConnection* ChildThreadImpl::GetMojoShellConnection() {
594 return mojo_shell_connection_.get();
595 }
596
597 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistry() {
598 if (!interface_registry_.get())
599 interface_registry_.reset(new shell::InterfaceRegistry(nullptr));
600 return interface_registry_.get();
601 }
602
603 shell::InterfaceProvider* ChildThreadImpl::GetRemoteInterfaces() {
604 if (!remote_interfaces_.get())
605 remote_interfaces_.reset(new shell::InterfaceProvider);
606 return remote_interfaces_.get();
607 }
608
609 shell::InterfaceRegistry* ChildThreadImpl::GetInterfaceRegistryForConnection() {
610 return GetInterfaceRegistry();
611 }
612
613 shell::InterfaceProvider* ChildThreadImpl::GetInterfaceProviderForConnection() {
614 return GetRemoteInterfaces();
615 }
616
596 IPC::MessageRouter* ChildThreadImpl::GetRouter() { 617 IPC::MessageRouter* ChildThreadImpl::GetRouter() {
597 DCHECK(base::MessageLoop::current() == message_loop()); 618 DCHECK(base::MessageLoop::current() == message_loop());
598 return &router_; 619 return &router_;
599 } 620 }
600 621
601 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory( 622 std::unique_ptr<base::SharedMemory> ChildThreadImpl::AllocateSharedMemory(
602 size_t buf_size) { 623 size_t buf_size) {
603 DCHECK(base::MessageLoop::current() == message_loop()); 624 DCHECK(base::MessageLoop::current() == message_loop());
604 return AllocateSharedMemory(buf_size, this, nullptr); 625 return AllocateSharedMemory(buf_size, this, nullptr);
605 } 626 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 void ChildThreadImpl::EnsureConnected() { 764 void ChildThreadImpl::EnsureConnected() {
744 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 765 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
745 base::Process::Current().Terminate(0, false); 766 base::Process::Current().Terminate(0, false);
746 } 767 }
747 768
748 bool ChildThreadImpl::IsInBrowserProcess() const { 769 bool ChildThreadImpl::IsInBrowserProcess() const {
749 return static_cast<bool>(browser_process_io_runner_); 770 return static_cast<bool>(browser_process_io_runner_);
750 } 771 }
751 772
752 } // namespace content 773 } // namespace content
OLDNEW
« no previous file with comments | « content/child/child_thread_impl.h ('k') | content/child/mojo/mojo_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698