Chromium Code Reviews| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 #include "content/common/child_process_messages.h" | 134 #include "content/common/child_process_messages.h" |
| 135 #include "content/common/content_switches_internal.h" | 135 #include "content/common/content_switches_internal.h" |
| 136 #include "content/common/frame_messages.h" | 136 #include "content/common/frame_messages.h" |
| 137 #include "content/common/in_process_child_thread_params.h" | 137 #include "content/common/in_process_child_thread_params.h" |
| 138 #include "content/common/render_process_messages.h" | 138 #include "content/common/render_process_messages.h" |
| 139 #include "content/common/resource_messages.h" | 139 #include "content/common/resource_messages.h" |
| 140 #include "content/common/service_manager/child_connection.h" | 140 #include "content/common/service_manager/child_connection.h" |
| 141 #include "content/common/service_manager/service_manager_connection_impl.h" | 141 #include "content/common/service_manager/service_manager_connection_impl.h" |
| 142 #include "content/common/site_isolation_policy.h" | 142 #include "content/common/site_isolation_policy.h" |
| 143 #include "content/common/view_messages.h" | 143 #include "content/common/view_messages.h" |
| 144 #include "content/common/worker_url_loader_factory_provider.mojom.h" | |
| 144 #include "content/public/browser/browser_context.h" | 145 #include "content/public/browser/browser_context.h" |
| 145 #include "content/public/browser/browser_thread.h" | 146 #include "content/public/browser/browser_thread.h" |
| 146 #include "content/public/browser/content_browser_client.h" | 147 #include "content/public/browser/content_browser_client.h" |
| 147 #include "content/public/browser/notification_service.h" | 148 #include "content/public/browser/notification_service.h" |
| 148 #include "content/public/browser/notification_types.h" | 149 #include "content/public/browser/notification_types.h" |
| 149 #include "content/public/browser/render_process_host_factory.h" | 150 #include "content/public/browser/render_process_host_factory.h" |
| 150 #include "content/public/browser/render_process_host_observer.h" | 151 #include "content/public/browser/render_process_host_observer.h" |
| 151 #include "content/public/browser/render_widget_host.h" | 152 #include "content/public/browser/render_widget_host.h" |
| 152 #include "content/public/browser/render_widget_host_iterator.h" | 153 #include "content/public/browser/render_widget_host_iterator.h" |
| 153 #include "content/public/browser/resource_context.h" | 154 #include "content/public/browser/resource_context.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 171 #include "gpu/command_buffer/service/gpu_switches.h" | 172 #include "gpu/command_buffer/service/gpu_switches.h" |
| 172 #include "gpu/ipc/host/gpu_memory_buffer_support.h" | 173 #include "gpu/ipc/host/gpu_memory_buffer_support.h" |
| 173 #include "ipc/ipc.mojom.h" | 174 #include "ipc/ipc.mojom.h" |
| 174 #include "ipc/ipc_channel.h" | 175 #include "ipc/ipc_channel.h" |
| 175 #include "ipc/ipc_channel_mojo.h" | 176 #include "ipc/ipc_channel_mojo.h" |
| 176 #include "ipc/ipc_logging.h" | 177 #include "ipc/ipc_logging.h" |
| 177 #include "media/base/media_switches.h" | 178 #include "media/base/media_switches.h" |
| 178 #include "media/media_features.h" | 179 #include "media/media_features.h" |
| 179 #include "mojo/edk/embedder/embedder.h" | 180 #include "mojo/edk/embedder/embedder.h" |
| 180 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 181 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
| 182 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 181 #include "net/url_request/url_request_context_getter.h" | 183 #include "net/url_request/url_request_context_getter.h" |
| 182 #include "ppapi/features/features.h" | 184 #include "ppapi/features/features.h" |
| 183 #include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" | 185 #include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" |
| 184 #include "services/service_manager/public/cpp/binder_registry.h" | 186 #include "services/service_manager/public/cpp/binder_registry.h" |
| 185 #include "services/service_manager/public/cpp/connector.h" | 187 #include "services/service_manager/public/cpp/connector.h" |
| 186 #include "services/service_manager/public/cpp/interface_provider.h" | 188 #include "services/service_manager/public/cpp/interface_provider.h" |
| 187 #include "services/service_manager/runner/common/client_util.h" | 189 #include "services/service_manager/runner/common/client_util.h" |
| 188 #include "services/service_manager/runner/common/switches.h" | 190 #include "services/service_manager/runner/common/switches.h" |
| 189 #include "services/shape_detection/public/interfaces/barcodedetection.mojom.h" | 191 #include "services/shape_detection/public/interfaces/barcodedetection.mojom.h" |
| 190 #include "services/shape_detection/public/interfaces/constants.mojom.h" | 192 #include "services/shape_detection/public/interfaces/constants.mojom.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 // Forwards service requests to Service Manager since the renderer cannot launch | 466 // Forwards service requests to Service Manager since the renderer cannot launch |
| 465 // out-of-process services on is own. | 467 // out-of-process services on is own. |
| 466 template <typename R> | 468 template <typename R> |
| 467 void ForwardShapeDetectionRequest(R request) { | 469 void ForwardShapeDetectionRequest(R request) { |
| 468 service_manager::Connector* connector = | 470 service_manager::Connector* connector = |
| 469 ServiceManagerConnection::GetForProcess()->GetConnector(); | 471 ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 470 connector->BindInterface(shape_detection::mojom::kServiceName, | 472 connector->BindInterface(shape_detection::mojom::kServiceName, |
| 471 std::move(request)); | 473 std::move(request)); |
| 472 } | 474 } |
| 473 | 475 |
| 476 class WorkerURLLoaderFactoryProviderImpl | |
| 477 : public mojom::WorkerURLLoaderFactoryProvider { | |
| 478 public: | |
| 479 static void Create( | |
| 480 int render_process_id, | |
| 481 scoped_refptr<ResourceMessageFilter> resource_message_filter, | |
| 482 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context, | |
| 483 mojom::WorkerURLLoaderFactoryProviderRequest request) { | |
| 484 DCHECK(base::FeatureList::IsEnabled(features::kOffMainThreadFetch)); | |
| 485 mojo::MakeStrongBinding( | |
|
yhirano
2017/04/21 09:18:41
When is this destructed?
yhirano
2017/04/21 09:30:44
Sorry, I was confused. I retract this comment.
| |
| 486 base::MakeUnique<WorkerURLLoaderFactoryProviderImpl>( | |
| 487 render_process_id, resource_message_filter->GetWeakPtr(), | |
| 488 std::move(service_worker_context)), | |
| 489 std::move(request)); | |
| 490 } | |
| 491 WorkerURLLoaderFactoryProviderImpl( | |
| 492 int render_process_id, | |
| 493 base::WeakPtr<ResourceMessageFilter> resource_message_filter, | |
| 494 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context) | |
| 495 : render_process_id_(render_process_id), | |
| 496 url_loader_factory_binding_(resource_message_filter.get()), | |
| 497 service_worker_context_(std::move(service_worker_context)) {} | |
| 498 ~WorkerURLLoaderFactoryProviderImpl() override {} | |
| 499 | |
| 500 void GetURLLoaderFactoryAndRegisterClient( | |
| 501 mojom::URLLoaderFactoryAssociatedRequest loader_request, | |
| 502 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info, | |
| 503 int service_worker_provider_id) override { | |
| 504 url_loader_factory_binding_.Bind(std::move(loader_request)); | |
| 505 service_worker_context_->BindWorkerFetchContext(render_process_id_, | |
| 506 service_worker_provider_id, | |
| 507 std::move(client_ptr_info)); | |
| 508 } | |
| 509 | |
| 510 void GetURLLoaderFactory( | |
| 511 mojom::URLLoaderFactoryAssociatedRequest loader_request) override { | |
| 512 url_loader_factory_binding_.Bind(std::move(loader_request)); | |
| 513 } | |
| 514 | |
| 515 private: | |
| 516 const int render_process_id_; | |
| 517 mojo::AssociatedBinding<mojom::URLLoaderFactory> url_loader_factory_binding_; | |
| 518 | |
| 519 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | |
| 520 }; | |
| 521 | |
| 474 } // namespace | 522 } // namespace |
| 475 | 523 |
| 476 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 524 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
| 477 | 525 |
| 478 base::MessageLoop* g_in_process_thread; | 526 base::MessageLoop* g_in_process_thread; |
| 479 | 527 |
| 480 // Stores the maximum number of renderer processes the content module can | 528 // Stores the maximum number of renderer processes the content module can |
| 481 // create. | 529 // create. |
| 482 static size_t g_max_renderer_count_override = 0; | 530 static size_t g_max_renderer_count_override = 0; |
| 483 | 531 |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1289 make_scoped_refptr( | 1337 make_scoped_refptr( |
| 1290 storage_partition_impl_->GetBackgroundFetchContext()))); | 1338 storage_partition_impl_->GetBackgroundFetchContext()))); |
| 1291 | 1339 |
| 1292 registry->AddInterface(base::Bind(&RenderProcessHostImpl::CreateMusGpuRequest, | 1340 registry->AddInterface(base::Bind(&RenderProcessHostImpl::CreateMusGpuRequest, |
| 1293 base::Unretained(this))); | 1341 base::Unretained(this))); |
| 1294 | 1342 |
| 1295 registry->AddInterface( | 1343 registry->AddInterface( |
| 1296 base::Bind(&VideoCaptureHost::Create, | 1344 base::Bind(&VideoCaptureHost::Create, |
| 1297 BrowserMainLoop::GetInstance()->media_stream_manager())); | 1345 BrowserMainLoop::GetInstance()->media_stream_manager())); |
| 1298 | 1346 |
| 1347 if (base::FeatureList::IsEnabled(features::kOffMainThreadFetch)) { | |
| 1348 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context( | |
| 1349 static_cast<ServiceWorkerContextWrapper*>( | |
| 1350 storage_partition_impl_->GetServiceWorkerContext())); | |
| 1351 registry->AddInterface( | |
| 1352 base::Bind(&WorkerURLLoaderFactoryProviderImpl::Create, GetID(), | |
| 1353 resource_message_filter_, service_worker_context)); | |
| 1354 } | |
| 1355 | |
| 1299 // This is to support usage of WebSockets in cases in which there is no | 1356 // This is to support usage of WebSockets in cases in which there is no |
| 1300 // associated RenderFrame (e.g., Shared Workers). | 1357 // associated RenderFrame (e.g., Shared Workers). |
| 1301 AddUIThreadInterface( | 1358 AddUIThreadInterface( |
| 1302 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(), | 1359 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(), |
| 1303 MSG_ROUTING_NONE)); | 1360 MSG_ROUTING_NONE)); |
| 1304 | 1361 |
| 1305 // Chrome browser process only provides DiscardableSharedMemory service when | 1362 // Chrome browser process only provides DiscardableSharedMemory service when |
| 1306 // Chrome is not running in mus+ash. | 1363 // Chrome is not running in mus+ash. |
| 1307 if (!service_manager::ServiceManagerIsRemote()) { | 1364 if (!service_manager::ServiceManagerIsRemote()) { |
| 1308 discardable_memory::DiscardableSharedMemoryManager* manager = | 1365 discardable_memory::DiscardableSharedMemoryManager* manager = |
| (...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3085 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; | 3142 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
| 3086 | 3143 |
| 3087 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3144 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
| 3088 // Capture the error message in a crash key value. | 3145 // Capture the error message in a crash key value. |
| 3089 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3146 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
| 3090 bad_message::ReceivedBadMessage(render_process_id, | 3147 bad_message::ReceivedBadMessage(render_process_id, |
| 3091 bad_message::RPH_MOJO_PROCESS_ERROR); | 3148 bad_message::RPH_MOJO_PROCESS_ERROR); |
| 3092 } | 3149 } |
| 3093 | 3150 |
| 3094 } // namespace content | 3151 } // namespace content |
| OLD | NEW |