OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #include "content/browser/streams/stream_context.h" | 122 #include "content/browser/streams/stream_context.h" |
123 #include "content/browser/tracing/trace_message_filter.h" | 123 #include "content/browser/tracing/trace_message_filter.h" |
124 #include "content/browser/websockets/websocket_manager.h" | 124 #include "content/browser/websockets/websocket_manager.h" |
125 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 125 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
126 #include "content/common/child_process_host_impl.h" | 126 #include "content/common/child_process_host_impl.h" |
127 #include "content/common/child_process_messages.h" | 127 #include "content/common/child_process_messages.h" |
128 #include "content/common/content_switches_internal.h" | 128 #include "content/common/content_switches_internal.h" |
129 #include "content/common/frame_messages.h" | 129 #include "content/common/frame_messages.h" |
130 #include "content/common/gpu_host_messages.h" | 130 #include "content/common/gpu_host_messages.h" |
131 #include "content/common/in_process_child_thread_params.h" | 131 #include "content/common/in_process_child_thread_params.h" |
132 #include "content/common/mojo/mojo_child_connection.h" | |
133 #include "content/common/mojo/mojo_shell_connection_impl.h" | |
134 #include "content/common/render_process_messages.h" | 132 #include "content/common/render_process_messages.h" |
135 #include "content/common/resource_messages.h" | 133 #include "content/common/resource_messages.h" |
| 134 #include "content/common/service_manager/child_connection.h" |
| 135 #include "content/common/service_manager/service_manager_connection_impl.h" |
136 #include "content/common/site_isolation_policy.h" | 136 #include "content/common/site_isolation_policy.h" |
137 #include "content/common/view_messages.h" | 137 #include "content/common/view_messages.h" |
138 #include "content/public/browser/browser_context.h" | 138 #include "content/public/browser/browser_context.h" |
139 #include "content/public/browser/browser_thread.h" | 139 #include "content/public/browser/browser_thread.h" |
140 #include "content/public/browser/content_browser_client.h" | 140 #include "content/public/browser/content_browser_client.h" |
141 #include "content/public/browser/notification_service.h" | 141 #include "content/public/browser/notification_service.h" |
142 #include "content/public/browser/notification_types.h" | 142 #include "content/public/browser/notification_types.h" |
143 #include "content/public/browser/render_process_host_factory.h" | 143 #include "content/public/browser/render_process_host_factory.h" |
144 #include "content/public/browser/render_process_host_observer.h" | 144 #include "content/public/browser/render_process_host_observer.h" |
145 #include "content/public/browser/render_widget_host.h" | 145 #include "content/public/browser/render_widget_host.h" |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 506 |
507 void Detach() { | 507 void Detach() { |
508 base::AutoLock lock(lock_); | 508 base::AutoLock lock(lock_); |
509 filter_ = nullptr; | 509 filter_ = nullptr; |
510 } | 510 } |
511 | 511 |
512 base::Lock lock_; | 512 base::Lock lock_; |
513 ConnectionFilterImpl* filter_; | 513 ConnectionFilterImpl* filter_; |
514 }; | 514 }; |
515 | 515 |
516 // Held by the RPH's BrowserContext's MojoShellConnection, ownership transferred | 516 // Held by the RPH's BrowserContext's ServiceManagerConnection, ownership |
517 // back to RPH upon RPH destruction. | 517 // transferred back to RPH upon RPH destruction. |
518 class RenderProcessHostImpl::ConnectionFilterImpl : public ConnectionFilter { | 518 class RenderProcessHostImpl::ConnectionFilterImpl : public ConnectionFilter { |
519 public: | 519 public: |
520 ConnectionFilterImpl( | 520 ConnectionFilterImpl( |
521 const shell::Identity& child_identity, | 521 const shell::Identity& child_identity, |
522 std::unique_ptr<shell::InterfaceRegistry> registry) | 522 std::unique_ptr<shell::InterfaceRegistry> registry) |
523 : child_identity_(child_identity), | 523 : child_identity_(child_identity), |
524 registry_(std::move(registry)), | 524 registry_(std::move(registry)), |
525 controller_(new ConnectionFilterController(this)), | 525 controller_(new ConnectionFilterController(this)), |
526 weak_factory_(this) { | 526 weak_factory_(this) { |
527 // Registration of this filter may race with browser shutdown, in which case | 527 // Registration of this filter may race with browser shutdown, in which case |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded( | 749 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded( |
750 MachBroker::GetInstance()); | 750 MachBroker::GetInstance()); |
751 #else | 751 #else |
752 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded(); | 752 IPC::AttachmentBrokerPrivileged::CreateBrokerIfNeeded(); |
753 #endif // defined(OS_MACOSX) | 753 #endif // defined(OS_MACOSX) |
754 #endif // USE_ATTACHMENT_BROKER | 754 #endif // USE_ATTACHMENT_BROKER |
755 | 755 |
756 scoped_refptr<base::SequencedTaskRunner> io_task_runner = | 756 scoped_refptr<base::SequencedTaskRunner> io_task_runner = |
757 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); | 757 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
758 shell::Connector* connector = | 758 shell::Connector* connector = |
759 BrowserContext::GetShellConnectorFor(browser_context_); | 759 BrowserContext::GetConnectorFor(browser_context_); |
760 // Some embedders may not initialize Mojo or the shell connector for a browser | 760 // Some embedders may not initialize Mojo or the shell connector for a browser |
761 // context (e.g. Android WebView)... so just fall back to the per-process | 761 // context (e.g. Android WebView)... so just fall back to the per-process |
762 // connector. | 762 // connector. |
763 if (!connector) { | 763 if (!connector) { |
764 // Additionally, some test code may not initialize the process-wide | 764 // Additionally, some test code may not initialize the process-wide |
765 // MojoShellConnection prior to this point. This class of test code doesn't | 765 // ServiceManagerConnection prior to this point. This class of test code |
766 // care about render processes so we can initialize a dummy one. | 766 // doesn't care about render processes so we can initialize a dummy one. |
767 if (!MojoShellConnection::GetForProcess()) { | 767 if (!ServiceManagerConnection::GetForProcess()) { |
768 shell::mojom::ServiceRequest request = mojo::GetProxy(&test_service_); | 768 shell::mojom::ServiceRequest request = mojo::GetProxy(&test_service_); |
769 MojoShellConnection::SetForProcess(MojoShellConnection::Create( | 769 ServiceManagerConnection::SetForProcess(ServiceManagerConnection::Create( |
770 std::move(request), io_task_runner)); | 770 std::move(request), io_task_runner)); |
771 } | 771 } |
772 connector = MojoShellConnection::GetForProcess()->GetConnector(); | 772 connector = ServiceManagerConnection::GetForProcess()->GetConnector(); |
773 } | 773 } |
774 mojo_child_connection_.reset(new MojoChildConnection( | 774 child_connection_.reset(new ChildConnection( |
775 kRendererMojoApplicationName, | 775 kRendererServiceName, |
776 base::StringPrintf("%d_%d", id_, instance_id_++), child_token_, connector, | 776 base::StringPrintf("%d_%d", id_, instance_id_++), child_token_, connector, |
777 io_task_runner)); | 777 io_task_runner)); |
778 } | 778 } |
779 | 779 |
780 // static | 780 // static |
781 void RenderProcessHostImpl::ShutDownInProcessRenderer() { | 781 void RenderProcessHostImpl::ShutDownInProcessRenderer() { |
782 DCHECK(g_run_renderer_in_process_); | 782 DCHECK(g_run_renderer_in_process_); |
783 | 783 |
784 switch (g_all_hosts.Pointer()->size()) { | 784 switch (g_all_hosts.Pointer()->size()) { |
785 case 0: | 785 case 0: |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 DCHECK(g_renderer_main_thread_factory); | 924 DCHECK(g_renderer_main_thread_factory); |
925 // Crank up a thread and run the initialization there. With the way that | 925 // Crank up a thread and run the initialization there. With the way that |
926 // messages flow between the browser and renderer, this thread is required | 926 // messages flow between the browser and renderer, this thread is required |
927 // to prevent a deadlock in single-process mode. Since the primordial | 927 // to prevent a deadlock in single-process mode. Since the primordial |
928 // thread in the renderer process runs the WebKit code and can sometimes | 928 // thread in the renderer process runs the WebKit code and can sometimes |
929 // make blocking calls to the UI thread (i.e. this thread), they need to run | 929 // make blocking calls to the UI thread (i.e. this thread), they need to run |
930 // on separate threads. | 930 // on separate threads. |
931 in_process_renderer_.reset( | 931 in_process_renderer_.reset( |
932 g_renderer_main_thread_factory(InProcessChildThreadParams( | 932 g_renderer_main_thread_factory(InProcessChildThreadParams( |
933 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), | 933 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
934 mojo_child_connection_->service_token()))); | 934 child_connection_->service_token()))); |
935 | 935 |
936 base::Thread::Options options; | 936 base::Thread::Options options; |
937 #if defined(OS_WIN) && !defined(OS_MACOSX) | 937 #if defined(OS_WIN) && !defined(OS_MACOSX) |
938 // In-process plugins require this to be a UI message loop. | 938 // In-process plugins require this to be a UI message loop. |
939 options.message_loop_type = base::MessageLoop::TYPE_UI; | 939 options.message_loop_type = base::MessageLoop::TYPE_UI; |
940 #else | 940 #else |
941 // We can't have multiple UI loops on Linux and Android, so we don't support | 941 // We can't have multiple UI loops on Linux and Android, so we don't support |
942 // in-process plugins. | 942 // in-process plugins. |
943 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; | 943 options.message_loop_type = base::MessageLoop::TYPE_DEFAULT; |
944 #endif | 944 #endif |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 | 1285 |
1286 // This is to support usage of WebSockets in cases in which there is no | 1286 // This is to support usage of WebSockets in cases in which there is no |
1287 // associated RenderFrame (e.g., Shared Workers). | 1287 // associated RenderFrame (e.g., Shared Workers). |
1288 AddUIThreadInterface( | 1288 AddUIThreadInterface( |
1289 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(), | 1289 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(), |
1290 MSG_ROUTING_NONE)); | 1290 MSG_ROUTING_NONE)); |
1291 | 1291 |
1292 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), | 1292 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), |
1293 this); | 1293 this); |
1294 | 1294 |
1295 MojoShellConnection* mojo_shell_connection = | 1295 ServiceManagerConnection* service_manager_connection = |
1296 BrowserContext::GetMojoShellConnectionFor(browser_context_); | 1296 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
1297 std::unique_ptr<ConnectionFilterImpl> connection_filter( | 1297 std::unique_ptr<ConnectionFilterImpl> connection_filter( |
1298 new ConnectionFilterImpl(mojo_child_connection_->child_identity(), | 1298 new ConnectionFilterImpl(child_connection_->child_identity(), |
1299 std::move(registry))); | 1299 std::move(registry))); |
1300 connection_filter_controller_ = connection_filter->controller(); | 1300 connection_filter_controller_ = connection_filter->controller(); |
1301 connection_filter_id_ = | 1301 connection_filter_id_ = service_manager_connection->AddConnectionFilter( |
1302 mojo_shell_connection->AddConnectionFilter(std::move(connection_filter)); | 1302 std::move(connection_filter)); |
1303 } | 1303 } |
1304 | 1304 |
1305 void RenderProcessHostImpl::GetRoute( | 1305 void RenderProcessHostImpl::GetRoute( |
1306 int32_t routing_id, | 1306 int32_t routing_id, |
1307 mojom::AssociatedInterfaceProviderAssociatedRequest request) { | 1307 mojom::AssociatedInterfaceProviderAssociatedRequest request) { |
1308 DCHECK(request.is_pending()); | 1308 DCHECK(request.is_pending()); |
1309 associated_interface_provider_bindings_.AddBinding( | 1309 associated_interface_provider_bindings_.AddBinding( |
1310 this, std::move(request), | 1310 this, std::move(request), |
1311 reinterpret_cast<void*>(static_cast<uintptr_t>(routing_id))); | 1311 reinterpret_cast<void*>(static_cast<uintptr_t>(routing_id))); |
1312 } | 1312 } |
(...skipping 20 matching lines...) Expand all Loading... |
1333 int RenderProcessHostImpl::GetNextRoutingID() { | 1333 int RenderProcessHostImpl::GetNextRoutingID() { |
1334 return widget_helper_->GetNextRoutingID(); | 1334 return widget_helper_->GetNextRoutingID(); |
1335 } | 1335 } |
1336 | 1336 |
1337 void RenderProcessHostImpl::ResumeDeferredNavigation( | 1337 void RenderProcessHostImpl::ResumeDeferredNavigation( |
1338 const GlobalRequestID& request_id) { | 1338 const GlobalRequestID& request_id) { |
1339 widget_helper_->ResumeDeferredNavigation(request_id); | 1339 widget_helper_->ResumeDeferredNavigation(request_id); |
1340 } | 1340 } |
1341 | 1341 |
1342 shell::InterfaceProvider* RenderProcessHostImpl::GetRemoteInterfaces() { | 1342 shell::InterfaceProvider* RenderProcessHostImpl::GetRemoteInterfaces() { |
1343 return mojo_child_connection_->GetRemoteInterfaces(); | 1343 return child_connection_->GetRemoteInterfaces(); |
1344 } | 1344 } |
1345 | 1345 |
1346 std::unique_ptr<base::SharedPersistentMemoryAllocator> | 1346 std::unique_ptr<base::SharedPersistentMemoryAllocator> |
1347 RenderProcessHostImpl::TakeMetricsAllocator() { | 1347 RenderProcessHostImpl::TakeMetricsAllocator() { |
1348 return std::move(metrics_allocator_); | 1348 return std::move(metrics_allocator_); |
1349 } | 1349 } |
1350 | 1350 |
1351 const base::TimeTicks& RenderProcessHostImpl::GetInitTimeForNavigationMetrics() | 1351 const base::TimeTicks& RenderProcessHostImpl::GetInitTimeForNavigationMetrics() |
1352 const { | 1352 const { |
1353 return init_time_; | 1353 return init_time_; |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 command_line->AppendSwitch(switches::kEnablePinch); | 1605 command_line->AppendSwitch(switches::kEnablePinch); |
1606 | 1606 |
1607 #if defined(OS_WIN) | 1607 #if defined(OS_WIN) |
1608 command_line->AppendSwitchASCII( | 1608 command_line->AppendSwitchASCII( |
1609 switches::kDeviceScaleFactor, | 1609 switches::kDeviceScaleFactor, |
1610 base::DoubleToString(display::win::GetDPIScale())); | 1610 base::DoubleToString(display::win::GetDPIScale())); |
1611 #endif | 1611 #endif |
1612 | 1612 |
1613 AppendCompositorCommandLineFlags(command_line); | 1613 AppendCompositorCommandLineFlags(command_line); |
1614 | 1614 |
1615 command_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 1615 command_line->AppendSwitchASCII(switches::kServiceRequestChannelToken, |
1616 mojo_child_connection_->service_token()); | 1616 child_connection_->service_token()); |
1617 } | 1617 } |
1618 | 1618 |
1619 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( | 1619 void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( |
1620 const base::CommandLine& browser_cmd, | 1620 const base::CommandLine& browser_cmd, |
1621 base::CommandLine* renderer_cmd) const { | 1621 base::CommandLine* renderer_cmd) const { |
1622 // Propagate the following switches to the renderer command line (along | 1622 // Propagate the following switches to the renderer command line (along |
1623 // with any associated values) if present in the browser command line. | 1623 // with any associated values) if present in the browser command line. |
1624 static const char* const kSwitchNames[] = { | 1624 static const char* const kSwitchNames[] = { |
1625 switches::kAgcStartupMinVolume, | 1625 switches::kAgcStartupMinVolume, |
1626 switches::kAecRefinedAdaptiveFilter, | 1626 switches::kAecRefinedAdaptiveFilter, |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1863 // Add kWaitForDebugger to let renderer process wait for a debugger. | 1863 // Add kWaitForDebugger to let renderer process wait for a debugger. |
1864 if (browser_cmd.HasSwitch(switches::kWaitForDebuggerChildren)) { | 1864 if (browser_cmd.HasSwitch(switches::kWaitForDebuggerChildren)) { |
1865 // Look to pass-on the kWaitForDebugger flag. | 1865 // Look to pass-on the kWaitForDebugger flag. |
1866 std::string value = | 1866 std::string value = |
1867 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); | 1867 browser_cmd.GetSwitchValueASCII(switches::kWaitForDebuggerChildren); |
1868 if (value.empty() || value == switches::kRendererProcess) { | 1868 if (value.empty() || value == switches::kRendererProcess) { |
1869 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); | 1869 renderer_cmd->AppendSwitch(switches::kWaitForDebugger); |
1870 } | 1870 } |
1871 } | 1871 } |
1872 | 1872 |
1873 DCHECK(mojo_child_connection_); | 1873 DCHECK(child_connection_); |
1874 renderer_cmd->AppendSwitchASCII(switches::kPrimordialPipeToken, | 1874 renderer_cmd->AppendSwitchASCII(switches::kPrimordialPipeToken, |
1875 mojo_child_connection_->service_token()); | 1875 child_connection_->service_token()); |
1876 | 1876 |
1877 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) | 1877 #if defined(OS_WIN) && !defined(OFFICIAL_BUILD) |
1878 // Needed because we can't show the dialog from the sandbox. Don't pass | 1878 // Needed because we can't show the dialog from the sandbox. Don't pass |
1879 // --no-sandbox in official builds because that would bypass the bad_flgs | 1879 // --no-sandbox in official builds because that would bypass the bad_flgs |
1880 // prompt. | 1880 // prompt. |
1881 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && | 1881 if (renderer_cmd->HasSwitch(switches::kRendererStartupDialog) && |
1882 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { | 1882 !renderer_cmd->HasSwitch(switches::kNoSandbox)) { |
1883 renderer_cmd->AppendSwitch(switches::kNoSandbox); | 1883 renderer_cmd->AppendSwitch(switches::kNoSandbox); |
1884 } | 1884 } |
1885 #endif | 1885 #endif |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2157 RenderProcessExited(this, base::TERMINATION_STATUS_NORMAL_TERMINATION, | 2157 RenderProcessExited(this, base::TERMINATION_STATUS_NORMAL_TERMINATION, |
2158 0)); | 2158 0)); |
2159 } | 2159 } |
2160 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2160 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, |
2161 RenderProcessHostDestroyed(this)); | 2161 RenderProcessHostDestroyed(this)); |
2162 NotificationService::current()->Notify( | 2162 NotificationService::current()->Notify( |
2163 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 2163 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
2164 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 2164 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
2165 | 2165 |
2166 if (connection_filter_id_ != | 2166 if (connection_filter_id_ != |
2167 MojoShellConnection::kInvalidConnectionFilterId) { | 2167 ServiceManagerConnection::kInvalidConnectionFilterId) { |
2168 MojoShellConnection* mojo_shell_connection = | 2168 ServiceManagerConnection* service_manager_connection = |
2169 BrowserContext::GetMojoShellConnectionFor(browser_context_); | 2169 BrowserContext::GetServiceManagerConnectionFor(browser_context_); |
2170 connection_filter_controller_->DisableFilter(); | 2170 connection_filter_controller_->DisableFilter(); |
2171 mojo_shell_connection->RemoveConnectionFilter(connection_filter_id_); | 2171 service_manager_connection->RemoveConnectionFilter(connection_filter_id_); |
2172 connection_filter_id_ = MojoShellConnection::kInvalidConnectionFilterId; | 2172 connection_filter_id_ = |
| 2173 ServiceManagerConnection::kInvalidConnectionFilterId; |
2173 } | 2174 } |
2174 | 2175 |
2175 #ifndef NDEBUG | 2176 #ifndef NDEBUG |
2176 is_self_deleted_ = true; | 2177 is_self_deleted_ = true; |
2177 #endif | 2178 #endif |
2178 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 2179 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
2179 deleting_soon_ = true; | 2180 deleting_soon_ = true; |
2180 | 2181 |
2181 #if USE_ATTACHMENT_BROKER | 2182 #if USE_ATTACHMENT_BROKER |
2182 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( | 2183 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 RemoveUserData(kRendererInterfaceKeyName); | 2694 RemoveUserData(kRendererInterfaceKeyName); |
2694 | 2695 |
2695 UpdateProcessPriority(); | 2696 UpdateProcessPriority(); |
2696 DCHECK(!is_process_backgrounded_); | 2697 DCHECK(!is_process_backgrounded_); |
2697 | 2698 |
2698 // RenderProcessExited observers and RenderProcessGone handlers might | 2699 // RenderProcessExited observers and RenderProcessGone handlers might |
2699 // navigate or perform other actions that require a connection. Ensure that | 2700 // navigate or perform other actions that require a connection. Ensure that |
2700 // there is one before calling them. | 2701 // there is one before calling them. |
2701 child_token_ = mojo::edk::GenerateRandomToken(); | 2702 child_token_ = mojo::edk::GenerateRandomToken(); |
2702 shell::Connector* connector = | 2703 shell::Connector* connector = |
2703 BrowserContext::GetShellConnectorFor(browser_context_); | 2704 BrowserContext::GetConnectorFor(browser_context_); |
2704 if (!connector) | 2705 if (!connector) |
2705 connector = MojoShellConnection::GetForProcess()->GetConnector(); | 2706 connector = ServiceManagerConnection::GetForProcess()->GetConnector(); |
2706 mojo_child_connection_.reset(new MojoChildConnection( | 2707 child_connection_.reset(new ChildConnection( |
2707 kRendererMojoApplicationName, | 2708 kRendererServiceName, |
2708 base::StringPrintf("%d_%d", id_, instance_id_++), child_token_, connector, | 2709 base::StringPrintf("%d_%d", id_, instance_id_++), child_token_, connector, |
2709 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); | 2710 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); |
2710 | 2711 |
2711 within_process_died_observer_ = true; | 2712 within_process_died_observer_ = true; |
2712 NotificationService::current()->Notify( | 2713 NotificationService::current()->Notify( |
2713 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), | 2714 NOTIFICATION_RENDERER_PROCESS_CLOSED, Source<RenderProcessHost>(this), |
2714 Details<RendererClosedDetails>(&details)); | 2715 Details<RendererClosedDetails>(&details)); |
2715 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 2716 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, |
2716 RenderProcessExited(this, status, exit_code)); | 2717 RenderProcessExited(this, status, exit_code)); |
2717 within_process_died_observer_ = false; | 2718 within_process_died_observer_ = false; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2841 if (child_process_launcher_) { | 2842 if (child_process_launcher_) { |
2842 DCHECK(child_process_launcher_->GetProcess().IsValid()); | 2843 DCHECK(child_process_launcher_->GetProcess().IsValid()); |
2843 DCHECK(!is_process_backgrounded_); | 2844 DCHECK(!is_process_backgrounded_); |
2844 | 2845 |
2845 // Unpause the channel now that the process is launched. We don't flush it | 2846 // Unpause the channel now that the process is launched. We don't flush it |
2846 // yet to ensure that any initialization messages sent here (e.g., things | 2847 // yet to ensure that any initialization messages sent here (e.g., things |
2847 // done in response to NOTIFICATION_RENDER_PROCESS_CREATED; see below) | 2848 // done in response to NOTIFICATION_RENDER_PROCESS_CREATED; see below) |
2848 // preempt already queued messages. | 2849 // preempt already queued messages. |
2849 channel_->Unpause(false /* flush */); | 2850 channel_->Unpause(false /* flush */); |
2850 | 2851 |
2851 if (mojo_child_connection_) { | 2852 if (child_connection_) { |
2852 mojo_child_connection_->SetProcessHandle( | 2853 child_connection_->SetProcessHandle( |
2853 child_process_launcher_->GetProcess().Handle()); | 2854 child_process_launcher_->GetProcess().Handle()); |
2854 } | 2855 } |
2855 | 2856 |
2856 // Not all platforms launch processes in the same backgrounded state. Make | 2857 // Not all platforms launch processes in the same backgrounded state. Make |
2857 // sure |is_process_backgrounded_| reflects this platform's initial process | 2858 // sure |is_process_backgrounded_| reflects this platform's initial process |
2858 // state. | 2859 // state. |
2859 is_process_backgrounded_ = | 2860 is_process_backgrounded_ = |
2860 child_process_launcher_->GetProcess().IsProcessBackgrounded(); | 2861 child_process_launcher_->GetProcess().IsProcessBackgrounded(); |
2861 | 2862 |
2862 // Disable updating process priority on startup for now as it incorrectly | 2863 // Disable updating process priority on startup for now as it incorrectly |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3031 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3032 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3032 | 3033 |
3033 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 3034 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
3034 // enough information here so that we can determine what the bad message was. | 3035 // enough information here so that we can determine what the bad message was. |
3035 base::debug::Alias(&error); | 3036 base::debug::Alias(&error); |
3036 bad_message::ReceivedBadMessage(render_process_id, | 3037 bad_message::ReceivedBadMessage(render_process_id, |
3037 bad_message::RPH_MOJO_PROCESS_ERROR); | 3038 bad_message::RPH_MOJO_PROCESS_ERROR); |
3038 } | 3039 } |
3039 | 3040 |
3040 } // namespace content | 3041 } // namespace content |
OLD | NEW |