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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" | 78 #include "content/browser/indexed_db/indexed_db_dispatcher_host.h" |
79 #include "content/browser/loader/resource_message_filter.h" | 79 #include "content/browser/loader/resource_message_filter.h" |
80 #include "content/browser/loader/resource_scheduler_filter.h" | 80 #include "content/browser/loader/resource_scheduler_filter.h" |
81 #include "content/browser/media/capture/audio_mirroring_manager.h" | 81 #include "content/browser/media/capture/audio_mirroring_manager.h" |
82 #include "content/browser/media/capture/image_capture_impl.h" | 82 #include "content/browser/media/capture/image_capture_impl.h" |
83 #include "content/browser/media/media_internals.h" | 83 #include "content/browser/media/media_internals.h" |
84 #include "content/browser/media/midi_host.h" | 84 #include "content/browser/media/midi_host.h" |
85 #include "content/browser/memory/memory_message_filter.h" | 85 #include "content/browser/memory/memory_message_filter.h" |
86 #include "content/browser/message_port_message_filter.h" | 86 #include "content/browser/message_port_message_filter.h" |
87 #include "content/browser/mime_registry_impl.h" | 87 #include "content/browser/mime_registry_impl.h" |
88 #include "content/browser/mojo/constants.h" | |
89 #include "content/browser/mojo/mojo_child_connection.h" | 88 #include "content/browser/mojo/mojo_child_connection.h" |
90 #include "content/browser/notifications/notification_message_filter.h" | 89 #include "content/browser/notifications/notification_message_filter.h" |
91 #include "content/browser/notifications/platform_notification_context_impl.h" | 90 #include "content/browser/notifications/platform_notification_context_impl.h" |
92 #include "content/browser/permissions/permission_service_context.h" | 91 #include "content/browser/permissions/permission_service_context.h" |
93 #include "content/browser/permissions/permission_service_impl.h" | 92 #include "content/browser/permissions/permission_service_impl.h" |
94 #include "content/browser/profiler_message_filter.h" | 93 #include "content/browser/profiler_message_filter.h" |
95 #include "content/browser/push_messaging/push_messaging_message_filter.h" | 94 #include "content/browser/push_messaging/push_messaging_message_filter.h" |
96 #include "content/browser/quota_dispatcher_host.h" | 95 #include "content/browser/quota_dispatcher_host.h" |
97 #include "content/browser/renderer_host/clipboard_message_filter.h" | 96 #include "content/browser/renderer_host/clipboard_message_filter.h" |
98 #include "content/browser/renderer_host/database_message_filter.h" | 97 #include "content/browser/renderer_host/database_message_filter.h" |
(...skipping 23 matching lines...) Expand all Loading... |
122 #include "content/browser/storage_partition_impl.h" | 121 #include "content/browser/storage_partition_impl.h" |
123 #include "content/browser/streams/stream_context.h" | 122 #include "content/browser/streams/stream_context.h" |
124 #include "content/browser/tracing/trace_message_filter.h" | 123 #include "content/browser/tracing/trace_message_filter.h" |
125 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 124 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
126 #include "content/common/child_process_host_impl.h" | 125 #include "content/common/child_process_host_impl.h" |
127 #include "content/common/child_process_messages.h" | 126 #include "content/common/child_process_messages.h" |
128 #include "content/common/content_switches_internal.h" | 127 #include "content/common/content_switches_internal.h" |
129 #include "content/common/frame_messages.h" | 128 #include "content/common/frame_messages.h" |
130 #include "content/common/gpu_host_messages.h" | 129 #include "content/common/gpu_host_messages.h" |
131 #include "content/common/in_process_child_thread_params.h" | 130 #include "content/common/in_process_child_thread_params.h" |
| 131 #include "content/common/mojo/constants.h" |
132 #include "content/common/mojo/mojo_shell_connection_impl.h" | 132 #include "content/common/mojo/mojo_shell_connection_impl.h" |
133 #include "content/common/render_process_messages.h" | 133 #include "content/common/render_process_messages.h" |
134 #include "content/common/resource_messages.h" | 134 #include "content/common/resource_messages.h" |
135 #include "content/common/site_isolation_policy.h" | 135 #include "content/common/site_isolation_policy.h" |
136 #include "content/common/view_messages.h" | 136 #include "content/common/view_messages.h" |
137 #include "content/public/browser/browser_context.h" | 137 #include "content/public/browser/browser_context.h" |
138 #include "content/public/browser/browser_thread.h" | 138 #include "content/public/browser/browser_thread.h" |
139 #include "content/public/browser/content_browser_client.h" | 139 #include "content/public/browser/content_browser_client.h" |
140 #include "content/public/browser/notification_service.h" | 140 #include "content/public/browser/notification_service.h" |
141 #include "content/public/browser/notification_types.h" | 141 #include "content/public/browser/notification_types.h" |
142 #include "content/public/browser/render_process_host_factory.h" | 142 #include "content/public/browser/render_process_host_factory.h" |
143 #include "content/public/browser/render_process_host_observer.h" | 143 #include "content/public/browser/render_process_host_observer.h" |
144 #include "content/public/browser/render_widget_host.h" | 144 #include "content/public/browser/render_widget_host.h" |
145 #include "content/public/browser/render_widget_host_iterator.h" | 145 #include "content/public/browser/render_widget_host_iterator.h" |
146 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 146 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
147 #include "content/public/browser/resource_context.h" | 147 #include "content/public/browser/resource_context.h" |
148 #include "content/public/browser/user_metrics.h" | 148 #include "content/public/browser/user_metrics.h" |
149 #include "content/public/browser/worker_service.h" | 149 #include "content/public/browser/worker_service.h" |
150 #include "content/public/common/child_process_host.h" | 150 #include "content/public/common/child_process_host.h" |
| 151 #include "content/public/common/connection_filter.h" |
151 #include "content/public/common/content_constants.h" | 152 #include "content/public/common/content_constants.h" |
152 #include "content/public/common/content_features.h" | 153 #include "content/public/common/content_features.h" |
153 #include "content/public/common/content_switches.h" | 154 #include "content/public/common/content_switches.h" |
154 #include "content/public/common/mojo_channel_switches.h" | 155 #include "content/public/common/mojo_channel_switches.h" |
155 #include "content/public/common/process_type.h" | 156 #include "content/public/common/process_type.h" |
156 #include "content/public/common/resource_type.h" | 157 #include "content/public/common/resource_type.h" |
157 #include "content/public/common/result_codes.h" | 158 #include "content/public/common/result_codes.h" |
158 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 159 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
159 #include "content/public/common/url_constants.h" | 160 #include "content/public/common/url_constants.h" |
160 #include "device/battery/battery_monitor_impl.h" | 161 #include "device/battery/battery_monitor_impl.h" |
161 #include "gpu/GLES2/gl2extchromium.h" | 162 #include "gpu/GLES2/gl2extchromium.h" |
162 #include "gpu/command_buffer/client/gpu_switches.h" | 163 #include "gpu/command_buffer/client/gpu_switches.h" |
163 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 164 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
164 #include "gpu/command_buffer/service/gpu_switches.h" | 165 #include "gpu/command_buffer/service/gpu_switches.h" |
165 #include "ipc/attachment_broker.h" | 166 #include "ipc/attachment_broker.h" |
166 #include "ipc/attachment_broker_privileged.h" | 167 #include "ipc/attachment_broker_privileged.h" |
167 #include "ipc/ipc_channel.h" | 168 #include "ipc/ipc_channel.h" |
168 #include "ipc/ipc_channel_mojo.h" | 169 #include "ipc/ipc_channel_mojo.h" |
169 #include "ipc/ipc_logging.h" | 170 #include "ipc/ipc_logging.h" |
170 #include "ipc/ipc_switches.h" | 171 #include "ipc/ipc_switches.h" |
171 #include "media/base/media_switches.h" | 172 #include "media/base/media_switches.h" |
172 #include "mojo/edk/embedder/embedder.h" | 173 #include "mojo/edk/embedder/embedder.h" |
173 #include "net/url_request/url_request_context_getter.h" | 174 #include "net/url_request/url_request_context_getter.h" |
174 #include "ppapi/shared_impl/ppapi_switches.h" | 175 #include "ppapi/shared_impl/ppapi_switches.h" |
| 176 #include "services/shell/public/cpp/connection.h" |
175 #include "services/shell/public/cpp/interface_provider.h" | 177 #include "services/shell/public/cpp/interface_provider.h" |
176 #include "services/shell/public/cpp/interface_registry.h" | 178 #include "services/shell/public/cpp/interface_registry.h" |
177 #include "services/shell/runner/common/switches.h" | 179 #include "services/shell/runner/common/switches.h" |
178 #include "storage/browser/fileapi/sandbox_file_system_backend.h" | 180 #include "storage/browser/fileapi/sandbox_file_system_backend.h" |
179 #include "third_party/skia/include/core/SkBitmap.h" | 181 #include "third_party/skia/include/core/SkBitmap.h" |
180 #include "ui/base/ui_base_switches.h" | 182 #include "ui/base/ui_base_switches.h" |
181 #include "ui/display/display_switches.h" | 183 #include "ui/display/display_switches.h" |
182 #include "ui/events/event_switches.h" | 184 #include "ui/events/event_switches.h" |
183 #include "ui/gfx/switches.h" | 185 #include "ui/gfx/switches.h" |
184 #include "ui/gl/gl_switches.h" | 186 #include "ui/gl/gl_switches.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 BrowserMainLoop::GetInstance()->memory_coordinator()->CreateHandle( | 452 BrowserMainLoop::GetInstance()->memory_coordinator()->CreateHandle( |
451 render_process_id, std::move(request)); | 453 render_process_id, std::move(request)); |
452 } | 454 } |
453 | 455 |
454 } // namespace | 456 } // namespace |
455 | 457 |
456 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 458 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
457 | 459 |
458 base::MessageLoop* g_in_process_thread; | 460 base::MessageLoop* g_in_process_thread; |
459 | 461 |
| 462 // Stores the maximum number of renderer processes the content module can |
| 463 // create. |
| 464 static size_t g_max_renderer_count_override = 0; |
| 465 |
| 466 // static |
| 467 bool g_run_renderer_in_process_ = false; |
| 468 |
| 469 // Held by the RPH's BrowserContext's MojoShellConnection, ownership transferred |
| 470 // back to RPH upon RPH destruction. |
| 471 class RenderProcessHostImpl::ConnectionFilterImpl : public ConnectionFilter { |
| 472 public: |
| 473 ConnectionFilterImpl( |
| 474 const shell::Identity& child_identity, |
| 475 std::unique_ptr<shell::InterfaceRegistry> registry) |
| 476 : child_identity_(child_identity), |
| 477 registry_(std::move(registry)) {} |
| 478 ~ConnectionFilterImpl() override { |
| 479 scoped_refptr<base::SequencedTaskRunner> io_task_runner = |
| 480 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
| 481 io_task_runner->DeleteSoon(FROM_HERE, weak_factory_.release()); |
| 482 } |
| 483 |
| 484 private: |
| 485 // ConnectionFilter: |
| 486 bool OnConnect(shell::Connection* connection, |
| 487 shell::Connector* connector) override { |
| 488 if (!weak_factory_) |
| 489 weak_factory_.reset(new base::WeakPtrFactory<ConnectionFilterImpl>(this)); |
| 490 |
| 491 // We only fulfill connections from the renderer we host. |
| 492 const shell::Identity& remote_identity = connection->GetRemoteIdentity(); |
| 493 if (child_identity_.name() != remote_identity.name() || |
| 494 child_identity_.instance() != remote_identity.instance()) { |
| 495 return false; |
| 496 } |
| 497 |
| 498 std::set<std::string> interface_names; |
| 499 registry_->GetInterfaceNames(&interface_names); |
| 500 for (auto& interface_name : interface_names) { |
| 501 // Note that the added callbacks may outlive this object, which is |
| 502 // destroyed in RPH::Cleanup(). |
| 503 connection->GetInterfaceRegistry()->AddInterface( |
| 504 interface_name, |
| 505 base::Bind(&ConnectionFilterImpl::GetInterface, |
| 506 weak_factory_->GetWeakPtr(), |
| 507 interface_name)); |
| 508 } |
| 509 return true; |
| 510 } |
| 511 |
| 512 void GetInterface(const std::string& interface_name, |
| 513 mojo::ScopedMessagePipeHandle handle) { |
| 514 shell::mojom::InterfaceProvider* provider = registry_.get(); |
| 515 provider->GetInterface(interface_name, std::move(handle)); |
| 516 } |
| 517 |
| 518 shell::Identity child_identity_; |
| 519 std::unique_ptr<shell::InterfaceRegistry> registry_; |
| 520 std::unique_ptr<base::WeakPtrFactory<ConnectionFilterImpl>> weak_factory_; |
| 521 |
| 522 DISALLOW_COPY_AND_ASSIGN(ConnectionFilterImpl); |
| 523 }; |
| 524 |
460 base::MessageLoop* | 525 base::MessageLoop* |
461 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { | 526 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { |
462 return g_in_process_thread; | 527 return g_in_process_thread; |
463 } | 528 } |
464 | 529 |
465 // Stores the maximum number of renderer processes the content module can | |
466 // create. | |
467 static size_t g_max_renderer_count_override = 0; | |
468 | |
469 // static | 530 // static |
470 size_t RenderProcessHost::GetMaxRendererProcessCount() { | 531 size_t RenderProcessHost::GetMaxRendererProcessCount() { |
471 if (g_max_renderer_count_override) | 532 if (g_max_renderer_count_override) |
472 return g_max_renderer_count_override; | 533 return g_max_renderer_count_override; |
473 | 534 |
474 #if defined(OS_ANDROID) | 535 #if defined(OS_ANDROID) |
475 // On Android we don't maintain a limit of renderer process hosts - we are | 536 // On Android we don't maintain a limit of renderer process hosts - we are |
476 // happy with keeping a lot of these, as long as the number of live renderer | 537 // happy with keeping a lot of these, as long as the number of live renderer |
477 // processes remains reasonable, and on Android the OS takes care of that. | 538 // processes remains reasonable, and on Android the OS takes care of that. |
478 return std::numeric_limits<size_t>::max(); | 539 return std::numeric_limits<size_t>::max(); |
(...skipping 27 matching lines...) Expand all Loading... |
506 max_count /= kEstimatedWebContentsMemoryUsage; | 567 max_count /= kEstimatedWebContentsMemoryUsage; |
507 | 568 |
508 const size_t kMinRendererProcessCount = 3; | 569 const size_t kMinRendererProcessCount = 3; |
509 max_count = std::max(max_count, kMinRendererProcessCount); | 570 max_count = std::max(max_count, kMinRendererProcessCount); |
510 max_count = std::min(max_count, kMaxRendererProcessCount); | 571 max_count = std::min(max_count, kMaxRendererProcessCount); |
511 } | 572 } |
512 return max_count; | 573 return max_count; |
513 } | 574 } |
514 | 575 |
515 // static | 576 // static |
516 bool g_run_renderer_in_process_ = false; | |
517 | |
518 // static | |
519 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { | 577 void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { |
520 g_max_renderer_count_override = count; | 578 g_max_renderer_count_override = count; |
521 } | 579 } |
522 | 580 |
523 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 581 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
524 // static | 582 // static |
525 void RenderProcessHostImpl::EarlyZygoteLaunch() { | 583 void RenderProcessHostImpl::EarlyZygoteLaunch() { |
526 DCHECK(!g_render_zygote); | 584 DCHECK(!g_render_zygote); |
527 // TODO(kerrnel): Investigate doing this without the ZygoteHostImpl as a | 585 // TODO(kerrnel): Investigate doing this without the ZygoteHostImpl as a |
528 // proxy. It is currently done this way due to concerns about race | 586 // proxy. It is currently done this way due to concerns about race |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 AddFilter(new HistogramMessageFilter()); | 1103 AddFilter(new HistogramMessageFilter()); |
1046 AddFilter(new MemoryMessageFilter(this)); | 1104 AddFilter(new MemoryMessageFilter(this)); |
1047 AddFilter(new PushMessagingMessageFilter( | 1105 AddFilter(new PushMessagingMessageFilter( |
1048 GetID(), storage_partition_impl_->GetServiceWorkerContext())); | 1106 GetID(), storage_partition_impl_->GetServiceWorkerContext())); |
1049 #if defined(OS_ANDROID) | 1107 #if defined(OS_ANDROID) |
1050 AddFilter(new ScreenOrientationMessageFilterAndroid()); | 1108 AddFilter(new ScreenOrientationMessageFilterAndroid()); |
1051 #endif | 1109 #endif |
1052 } | 1110 } |
1053 | 1111 |
1054 void RenderProcessHostImpl::RegisterMojoInterfaces() { | 1112 void RenderProcessHostImpl::RegisterMojoInterfaces() { |
1055 #if !defined(OS_ANDROID) | 1113 std::unique_ptr<shell::InterfaceRegistry> registry( |
1056 GetInterfaceRegistry()->AddInterface( | 1114 new shell::InterfaceRegistry(nullptr)); |
1057 base::Bind(&device::BatteryMonitorImpl::Create)); | 1115 #if defined(OS_ANDROID) |
| 1116 interface_registry_android_ = |
| 1117 InterfaceRegistryAndroid::Create(registry.get()); |
| 1118 InterfaceRegistrarAndroid::ExposeInterfacesToRenderer( |
| 1119 interface_registry_android_.get()); |
1058 #endif | 1120 #endif |
1059 | 1121 |
1060 GetInterfaceRegistry()->AddInterface( | 1122 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner = |
| 1123 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI); |
| 1124 #if !defined(OS_ANDROID) |
| 1125 registry->AddInterface(base::Bind(&device::BatteryMonitorImpl::Create), |
| 1126 ui_task_runner); |
| 1127 #endif |
| 1128 registry->AddInterface( |
1061 base::Bind(&PermissionServiceContext::CreateService, | 1129 base::Bind(&PermissionServiceContext::CreateService, |
1062 base::Unretained(permission_service_context_.get()))); | 1130 base::Unretained(permission_service_context_.get())), |
1063 | 1131 ui_task_runner); |
1064 // TODO(mcasas): finalize arguments. | 1132 // TODO(mcasas): finalize arguments. |
1065 GetInterfaceRegistry()->AddInterface( | 1133 registry->AddInterface(base::Bind(&ImageCaptureImpl::Create), |
1066 base::Bind(&ImageCaptureImpl::Create)); | 1134 ui_task_runner); |
1067 | 1135 registry->AddInterface(base::Bind(&OffscreenCanvasSurfaceImpl::Create), |
1068 GetInterfaceRegistry()->AddInterface( | 1136 ui_task_runner); |
1069 base::Bind(&OffscreenCanvasSurfaceImpl::Create)); | 1137 registry->AddInterface( |
1070 | 1138 base::Bind(&BackgroundSyncContext::CreateService, |
1071 GetInterfaceRegistry()->AddInterface(base::Bind( | 1139 base::Unretained( |
1072 &BackgroundSyncContext::CreateService, | 1140 storage_partition_impl_->GetBackgroundSyncContext())), |
1073 base::Unretained(storage_partition_impl_->GetBackgroundSyncContext()))); | 1141 ui_task_runner); |
1074 | 1142 registry->AddInterface( |
1075 GetInterfaceRegistry()->AddInterface(base::Bind( | 1143 base::Bind(&PlatformNotificationContextImpl::CreateService, |
1076 &PlatformNotificationContextImpl::CreateService, | 1144 base::Unretained( |
1077 base::Unretained( | 1145 storage_partition_impl_->GetPlatformNotificationContext()), |
1078 storage_partition_impl_->GetPlatformNotificationContext()), GetID())); | 1146 GetID()), |
1079 | 1147 ui_task_runner); |
1080 GetInterfaceRegistry()->AddInterface( | 1148 registry->AddInterface( |
1081 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, | 1149 base::Bind(&RenderProcessHostImpl::CreateStoragePartitionService, |
1082 base::Unretained(this))); | 1150 base::Unretained(this)), |
1083 | 1151 ui_task_runner); |
1084 GetInterfaceRegistry()->AddInterface( | 1152 registry->AddInterface( |
1085 base::Bind(&BroadcastChannelProvider::Connect, | 1153 base::Bind(&BroadcastChannelProvider::Connect, |
1086 base::Unretained( | 1154 base::Unretained( |
1087 storage_partition_impl_->GetBroadcastChannelProvider()))); | 1155 storage_partition_impl_->GetBroadcastChannelProvider())), |
| 1156 ui_task_runner); |
| 1157 if (memory_coordinator::IsEnabled()) { |
| 1158 registry->AddInterface(base::Bind(&CreateMemoryCoordinatorHandle, GetID()), |
| 1159 ui_task_runner); |
| 1160 } |
1088 | 1161 |
1089 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = | 1162 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner = |
1090 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE); | 1163 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE); |
1091 GetInterfaceRegistry()->AddInterface( | 1164 registry->AddInterface(base::Bind(&MimeRegistryImpl::Create), |
1092 base::Bind(&MimeRegistryImpl::Create), file_task_runner); | 1165 file_task_runner); |
1093 | |
1094 #if defined(USE_MINIKIN_HYPHENATION) | 1166 #if defined(USE_MINIKIN_HYPHENATION) |
1095 GetInterfaceRegistry()->AddInterface( | 1167 registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create), |
1096 base::Bind(&hyphenation::HyphenationImpl::Create), file_task_runner); | 1168 file_task_runner); |
1097 #endif | 1169 #endif |
1098 | 1170 |
1099 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = | 1171 // These callbacks will be run immediately on the IO thread. |
1100 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); | 1172 registry->AddInterface(base::Bind(&DeviceLightHost::Create)); |
1101 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceLightHost::Create), | 1173 registry->AddInterface(base::Bind(&DeviceMotionHost::Create)); |
1102 io_task_runner); | 1174 registry->AddInterface(base::Bind(&DeviceOrientationHost::Create)); |
1103 GetInterfaceRegistry()->AddInterface(base::Bind(&DeviceMotionHost::Create), | 1175 registry->AddInterface(base::Bind(&DeviceOrientationAbsoluteHost::Create)); |
1104 io_task_runner); | |
1105 GetInterfaceRegistry()->AddInterface( | |
1106 base::Bind(&DeviceOrientationHost::Create), io_task_runner); | |
1107 GetInterfaceRegistry()->AddInterface( | |
1108 base::Bind(&DeviceOrientationAbsoluteHost::Create), io_task_runner); | |
1109 | 1176 |
1110 if (memory_coordinator::IsEnabled()) { | 1177 GetContentClient()->browser()->ExposeInterfacesToRenderer(registry.get(), |
1111 GetInterfaceRegistry()->AddInterface( | 1178 this); |
1112 base::Bind(&CreateMemoryCoordinatorHandle, GetID())); | |
1113 } | |
1114 | 1179 |
1115 #if defined(OS_ANDROID) | 1180 MojoShellConnection* mojo_shell_connection = |
1116 InterfaceRegistrarAndroid::ExposeInterfacesToRenderer( | 1181 BrowserContext::GetMojoShellConnectionFor(browser_context_); |
1117 mojo_child_connection_->interface_registry_android()); | 1182 std::unique_ptr<ConnectionFilterImpl> connection_filter( |
1118 #endif | 1183 new ConnectionFilterImpl(mojo_child_connection_->child_identity(), |
1119 | 1184 std::move(registry))); |
1120 GetContentClient()->browser()->ExposeInterfacesToRenderer( | 1185 connection_filter_ = connection_filter.get(); |
1121 GetInterfaceRegistry(), this); | 1186 mojo_shell_connection->AddConnectionFilter(std::move(connection_filter)); |
1122 } | 1187 } |
1123 | 1188 |
1124 void RenderProcessHostImpl::CreateStoragePartitionService( | 1189 void RenderProcessHostImpl::CreateStoragePartitionService( |
1125 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { | 1190 mojo::InterfaceRequest<mojom::StoragePartitionService> request) { |
1126 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! | 1191 // DO NOT REMOVE THIS COMMAND LINE CHECK WITHOUT SECURITY REVIEW! |
1127 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1192 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1128 switches::kMojoLocalStorage)) { | 1193 switches::kMojoLocalStorage)) { |
1129 storage_partition_impl_->Bind(std::move(request)); | 1194 storage_partition_impl_->Bind(std::move(request)); |
1130 } | 1195 } |
1131 } | 1196 } |
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1918 RenderProcessHostObserver, observers_, | 1983 RenderProcessHostObserver, observers_, |
1919 RenderProcessExited(this, base::TERMINATION_STATUS_NORMAL_TERMINATION, | 1984 RenderProcessExited(this, base::TERMINATION_STATUS_NORMAL_TERMINATION, |
1920 0)); | 1985 0)); |
1921 } | 1986 } |
1922 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, | 1987 FOR_EACH_OBSERVER(RenderProcessHostObserver, observers_, |
1923 RenderProcessHostDestroyed(this)); | 1988 RenderProcessHostDestroyed(this)); |
1924 NotificationService::current()->Notify( | 1989 NotificationService::current()->Notify( |
1925 NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 1990 NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
1926 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 1991 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
1927 | 1992 |
| 1993 if (connection_filter_) { |
| 1994 MojoShellConnection* mojo_shell_connection = |
| 1995 BrowserContext::GetMojoShellConnectionFor(browser_context_); |
| 1996 // Throw the result away, so the connection filter is deleted. |
| 1997 mojo_shell_connection->RemoveConnectionFilter(connection_filter_); |
| 1998 } |
| 1999 |
1928 #ifndef NDEBUG | 2000 #ifndef NDEBUG |
1929 is_self_deleted_ = true; | 2001 is_self_deleted_ = true; |
1930 #endif | 2002 #endif |
1931 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 2003 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
1932 deleting_soon_ = true; | 2004 deleting_soon_ = true; |
1933 | 2005 |
1934 #if USE_ATTACHMENT_BROKER | 2006 #if USE_ATTACHMENT_BROKER |
1935 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( | 2007 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel( |
1936 channel_.get()); | 2008 channel_.get()); |
1937 #endif | 2009 #endif |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2767 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 2839 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
2768 | 2840 |
2769 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias | 2841 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. Alias |
2770 // enough information here so that we can determine what the bad message was. | 2842 // enough information here so that we can determine what the bad message was. |
2771 base::debug::Alias(&error); | 2843 base::debug::Alias(&error); |
2772 bad_message::ReceivedBadMessage(process.get(), | 2844 bad_message::ReceivedBadMessage(process.get(), |
2773 bad_message::RPH_MOJO_PROCESS_ERROR); | 2845 bad_message::RPH_MOJO_PROCESS_ERROR); |
2774 } | 2846 } |
2775 | 2847 |
2776 } // namespace content | 2848 } // namespace content |
OLD | NEW |