| OLD | NEW |
| 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #include "content/common/content_constants_internal.h" | 60 #include "content/common/content_constants_internal.h" |
| 61 #include "content/common/database_messages.h" | 61 #include "content/common/database_messages.h" |
| 62 #include "content/common/dom_storage/dom_storage_messages.h" | 62 #include "content/common/dom_storage/dom_storage_messages.h" |
| 63 #include "content/common/frame_messages.h" | 63 #include "content/common/frame_messages.h" |
| 64 #include "content/common/gpu/client/context_provider_command_buffer.h" | 64 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 65 #include "content/common/gpu/client/gpu_channel_host.h" | 65 #include "content/common/gpu/client/gpu_channel_host.h" |
| 66 #include "content/common/gpu/gpu_messages.h" | 66 #include "content/common/gpu/gpu_messages.h" |
| 67 #include "content/common/gpu/gpu_process_launch_causes.h" | 67 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 68 #include "content/common/render_frame_setup.mojom.h" | 68 #include "content/common/render_frame_setup.mojom.h" |
| 69 #include "content/common/resource_messages.h" | 69 #include "content/common/resource_messages.h" |
| 70 #include "content/common/service_worker/embedded_worker_setup.mojom.h" |
| 70 #include "content/common/view_messages.h" | 71 #include "content/common/view_messages.h" |
| 71 #include "content/common/worker_messages.h" | 72 #include "content/common/worker_messages.h" |
| 72 #include "content/public/common/content_constants.h" | 73 #include "content/public/common/content_constants.h" |
| 73 #include "content/public/common/content_paths.h" | 74 #include "content/public/common/content_paths.h" |
| 74 #include "content/public/common/content_switches.h" | 75 #include "content/public/common/content_switches.h" |
| 75 #include "content/public/common/mojo_channel_switches.h" | 76 #include "content/public/common/mojo_channel_switches.h" |
| 76 #include "content/public/common/renderer_preferences.h" | 77 #include "content/public/common/renderer_preferences.h" |
| 77 #include "content/public/common/url_constants.h" | 78 #include "content/public/common/url_constants.h" |
| 78 #include "content/public/renderer/content_renderer_client.h" | 79 #include "content/public/renderer/content_renderer_client.h" |
| 79 #include "content/public/renderer/render_process_observer.h" | 80 #include "content/public/renderer/render_process_observer.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 103 #include "content/renderer/media/video_capture_impl_manager.h" | 104 #include "content/renderer/media/video_capture_impl_manager.h" |
| 104 #include "content/renderer/media/video_capture_message_filter.h" | 105 #include "content/renderer/media/video_capture_message_filter.h" |
| 105 #include "content/renderer/net_info_helper.h" | 106 #include "content/renderer/net_info_helper.h" |
| 106 #include "content/renderer/p2p/socket_dispatcher.h" | 107 #include "content/renderer/p2p/socket_dispatcher.h" |
| 107 #include "content/renderer/render_frame_proxy.h" | 108 #include "content/renderer/render_frame_proxy.h" |
| 108 #include "content/renderer/render_process_impl.h" | 109 #include "content/renderer/render_process_impl.h" |
| 109 #include "content/renderer/render_view_impl.h" | 110 #include "content/renderer/render_view_impl.h" |
| 110 #include "content/renderer/renderer_blink_platform_impl.h" | 111 #include "content/renderer/renderer_blink_platform_impl.h" |
| 111 #include "content/renderer/scheduler/resource_dispatch_throttler.h" | 112 #include "content/renderer/scheduler/resource_dispatch_throttler.h" |
| 112 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 113 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 114 #include "content/renderer/service_worker/service_worker_context_client.h" |
| 113 #include "content/renderer/service_worker/service_worker_context_message_filter.
h" | 115 #include "content/renderer/service_worker/service_worker_context_message_filter.
h" |
| 114 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 116 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 115 #include "gin/public/debug.h" | 117 #include "gin/public/debug.h" |
| 116 #include "gpu/GLES2/gl2extchromium.h" | 118 #include "gpu/GLES2/gl2extchromium.h" |
| 117 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 119 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 118 #include "ipc/ipc_channel_handle.h" | 120 #include "ipc/ipc_channel_handle.h" |
| 119 #include "ipc/ipc_platform_file.h" | 121 #include "ipc/ipc_platform_file.h" |
| 120 #include "ipc/mojo/ipc_channel_mojo.h" | 122 #include "ipc/mojo/ipc_channel_mojo.h" |
| 121 #include "media/base/audio_hardware_config.h" | 123 #include "media/base/audio_hardware_config.h" |
| 122 #include "media/base/media.h" | 124 #include "media/base/media.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 blink::WebGraphicsContext3D::Attributes GetOffscreenAttribs() { | 372 blink::WebGraphicsContext3D::Attributes GetOffscreenAttribs() { |
| 371 blink::WebGraphicsContext3D::Attributes attributes; | 373 blink::WebGraphicsContext3D::Attributes attributes; |
| 372 attributes.shareResources = true; | 374 attributes.shareResources = true; |
| 373 attributes.depth = false; | 375 attributes.depth = false; |
| 374 attributes.stencil = false; | 376 attributes.stencil = false; |
| 375 attributes.antialias = false; | 377 attributes.antialias = false; |
| 376 attributes.noAutomaticFlushes = true; | 378 attributes.noAutomaticFlushes = true; |
| 377 return attributes; | 379 return attributes; |
| 378 } | 380 } |
| 379 | 381 |
| 382 void SetupEmbeddedWorkerOnWorkerThread( |
| 383 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 384 mojo::ServiceProviderPtr exposed_services) { |
| 385 ServiceWorkerContextClient* client = |
| 386 ServiceWorkerContextClient::ThreadSpecificInstance(); |
| 387 // It is possible for client to be null if for some reason the worker died |
| 388 // before this call made it to the worker thread. In that case just do |
| 389 // nothing and let mojo close the connection. |
| 390 if (!client) |
| 391 return; |
| 392 client->BindServiceRegistry(services.Pass(), exposed_services.Pass()); |
| 393 } |
| 394 |
| 395 class EmbeddedWorkerSetupImpl : public EmbeddedWorkerSetup { |
| 396 public: |
| 397 explicit EmbeddedWorkerSetupImpl( |
| 398 mojo::InterfaceRequest<EmbeddedWorkerSetup> request) |
| 399 : binding_(this, request.Pass()) {} |
| 400 |
| 401 void ExchangeServiceProviders( |
| 402 int32_t thread_id, |
| 403 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 404 mojo::ServiceProviderPtr exposed_services) override { |
| 405 WorkerTaskRunner::Instance()->GetTaskRunnerFor(thread_id)->PostTask( |
| 406 FROM_HERE, |
| 407 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&services), |
| 408 base::Passed(&exposed_services))); |
| 409 } |
| 410 |
| 411 private: |
| 412 mojo::StrongBinding<EmbeddedWorkerSetup> binding_; |
| 413 }; |
| 414 |
| 415 void CreateEmbeddedWorkerSetup( |
| 416 mojo::InterfaceRequest<EmbeddedWorkerSetup> request) { |
| 417 new EmbeddedWorkerSetupImpl(request.Pass()); |
| 418 } |
| 419 |
| 380 } // namespace | 420 } // namespace |
| 381 | 421 |
| 382 class RasterWorkerPool : public base::SequencedTaskRunner, | 422 class RasterWorkerPool : public base::SequencedTaskRunner, |
| 383 public base::DelegateSimpleThread::Delegate { | 423 public base::DelegateSimpleThread::Delegate { |
| 384 public: | 424 public: |
| 385 RasterWorkerPool() | 425 RasterWorkerPool() |
| 386 : namespace_token_(task_graph_runner_.GetNamespaceToken()) {} | 426 : namespace_token_(task_graph_runner_.GetNamespaceToken()) {} |
| 387 | 427 |
| 388 void Start(int num_threads, | 428 void Start(int num_threads, |
| 389 const base::SimpleThread::Options& thread_options) { | 429 const base::SimpleThread::Options& thread_options) { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 raster_worker_pool_->Start(num_raster_threads, thread_options); | 840 raster_worker_pool_->Start(num_raster_threads, thread_options); |
| 801 | 841 |
| 802 // TODO(boliu): In single process, browser main loop should set up the | 842 // TODO(boliu): In single process, browser main loop should set up the |
| 803 // discardable memory manager, and should skip this if kSingleProcess. | 843 // discardable memory manager, and should skip this if kSingleProcess. |
| 804 // See crbug.com/503724. | 844 // See crbug.com/503724. |
| 805 base::DiscardableMemoryAllocator::SetInstance( | 845 base::DiscardableMemoryAllocator::SetInstance( |
| 806 ChildThreadImpl::discardable_shared_memory_manager()); | 846 ChildThreadImpl::discardable_shared_memory_manager()); |
| 807 | 847 |
| 808 service_registry()->AddService<RenderFrameSetup>( | 848 service_registry()->AddService<RenderFrameSetup>( |
| 809 base::Bind(CreateRenderFrameSetup)); | 849 base::Bind(CreateRenderFrameSetup)); |
| 850 service_registry()->AddService<EmbeddedWorkerSetup>( |
| 851 base::Bind(CreateEmbeddedWorkerSetup)); |
| 810 | 852 |
| 811 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); | 853 TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, ""); |
| 812 } | 854 } |
| 813 | 855 |
| 814 RenderThreadImpl::~RenderThreadImpl() { | 856 RenderThreadImpl::~RenderThreadImpl() { |
| 815 } | 857 } |
| 816 | 858 |
| 817 void RenderThreadImpl::Shutdown() { | 859 void RenderThreadImpl::Shutdown() { |
| 818 FOR_EACH_OBSERVER( | 860 FOR_EACH_OBSERVER( |
| 819 RenderProcessObserver, observers_, OnRenderProcessShutdown()); | 861 RenderProcessObserver, observers_, OnRenderProcessShutdown()); |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 } | 2037 } |
| 1996 | 2038 |
| 1997 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2039 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 1998 size_t erased = | 2040 size_t erased = |
| 1999 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2041 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2000 routing_id_); | 2042 routing_id_); |
| 2001 DCHECK_EQ(1u, erased); | 2043 DCHECK_EQ(1u, erased); |
| 2002 } | 2044 } |
| 2003 | 2045 |
| 2004 } // namespace content | 2046 } // namespace content |
| OLD | NEW |