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( | |
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 CreateWorkerFetchContext( | |
kinuko
2017/04/19 11:08:14
I still think this could be named like GetURLLoade
horo
2017/04/19 13:52:27
Done.
| |
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 }; | |
kinuko
2017/04/19 11:08:14
nit: no need of semicolon
horo
2017/04/19 13:52:27
Done.
| |
509 void GetURLLoaderFactory( | |
510 mojom::URLLoaderFactoryAssociatedRequest loader_request) override { | |
511 url_loader_factory_binding_.Bind(std::move(loader_request)); | |
512 } | |
513 | |
514 private: | |
515 const int render_process_id_; | |
516 mojo::AssociatedBinding<mojom::URLLoaderFactory> url_loader_factory_binding_; | |
517 | |
518 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | |
519 }; | |
520 | |
474 } // namespace | 521 } // namespace |
475 | 522 |
476 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 523 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
477 | 524 |
478 base::MessageLoop* g_in_process_thread; | 525 base::MessageLoop* g_in_process_thread; |
479 | 526 |
480 // Stores the maximum number of renderer processes the content module can | 527 // Stores the maximum number of renderer processes the content module can |
481 // create. | 528 // create. |
482 static size_t g_max_renderer_count_override = 0; | 529 static size_t g_max_renderer_count_override = 0; |
483 | 530 |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1289 make_scoped_refptr( | 1336 make_scoped_refptr( |
1290 storage_partition_impl_->GetBackgroundFetchContext()))); | 1337 storage_partition_impl_->GetBackgroundFetchContext()))); |
1291 | 1338 |
1292 registry->AddInterface(base::Bind(&RenderProcessHostImpl::CreateMusGpuRequest, | 1339 registry->AddInterface(base::Bind(&RenderProcessHostImpl::CreateMusGpuRequest, |
1293 base::Unretained(this))); | 1340 base::Unretained(this))); |
1294 | 1341 |
1295 registry->AddInterface( | 1342 registry->AddInterface( |
1296 base::Bind(&VideoCaptureHost::Create, | 1343 base::Bind(&VideoCaptureHost::Create, |
1297 BrowserMainLoop::GetInstance()->media_stream_manager())); | 1344 BrowserMainLoop::GetInstance()->media_stream_manager())); |
1298 | 1345 |
1346 if (base::FeatureList::IsEnabled(features::kOffMainThreadFetch)) { | |
1347 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context( | |
1348 static_cast<ServiceWorkerContextWrapper*>( | |
1349 storage_partition_impl_->GetServiceWorkerContext())); | |
1350 registry->AddInterface( | |
1351 base::Bind(&WorkerURLLoaderFactoryProviderImpl::Create, GetID(), | |
1352 resource_message_filter_, service_worker_context)); | |
1353 } | |
1354 | |
1299 // This is to support usage of WebSockets in cases in which there is no | 1355 // This is to support usage of WebSockets in cases in which there is no |
1300 // associated RenderFrame (e.g., Shared Workers). | 1356 // associated RenderFrame (e.g., Shared Workers). |
1301 AddUIThreadInterface( | 1357 AddUIThreadInterface( |
1302 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(), | 1358 registry.get(), base::Bind(&WebSocketManager::CreateWebSocket, GetID(), |
1303 MSG_ROUTING_NONE)); | 1359 MSG_ROUTING_NONE)); |
1304 | 1360 |
1305 // Chrome browser process only provides DiscardableSharedMemory service when | 1361 // Chrome browser process only provides DiscardableSharedMemory service when |
1306 // Chrome is not running in mus+ash. | 1362 // Chrome is not running in mus+ash. |
1307 if (!service_manager::ServiceManagerIsRemote()) { | 1363 if (!service_manager::ServiceManagerIsRemote()) { |
1308 discardable_memory::DiscardableSharedMemoryManager* manager = | 1364 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; | 3141 LOG(ERROR) << "Terminating render process for bad Mojo message: " << error; |
3086 | 3142 |
3087 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. | 3143 // The ReceivedBadMessage call below will trigger a DumpWithoutCrashing. |
3088 // Capture the error message in a crash key value. | 3144 // Capture the error message in a crash key value. |
3089 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); | 3145 base::debug::ScopedCrashKey error_key_value("mojo-message-error", error); |
3090 bad_message::ReceivedBadMessage(render_process_id, | 3146 bad_message::ReceivedBadMessage(render_process_id, |
3091 bad_message::RPH_MOJO_PROCESS_ERROR); | 3147 bad_message::RPH_MOJO_PROCESS_ERROR); |
3092 } | 3148 } |
3093 | 3149 |
3094 } // namespace content | 3150 } // namespace content |
OLD | NEW |