| 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 <utility> | 10 #include <utility> |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 #include "content/child/thread_safe_sender.h" | 67 #include "content/child/thread_safe_sender.h" |
| 68 #include "content/child/web_database_observer_impl.h" | 68 #include "content/child/web_database_observer_impl.h" |
| 69 #include "content/child/worker_thread_registry.h" | 69 #include "content/child/worker_thread_registry.h" |
| 70 #include "content/common/child_process_messages.h" | 70 #include "content/common/child_process_messages.h" |
| 71 #include "content/common/content_constants_internal.h" | 71 #include "content/common/content_constants_internal.h" |
| 72 #include "content/common/dom_storage/dom_storage_messages.h" | 72 #include "content/common/dom_storage/dom_storage_messages.h" |
| 73 #include "content/common/frame_messages.h" | 73 #include "content/common/frame_messages.h" |
| 74 #include "content/common/frame_owner_properties.h" | 74 #include "content/common/frame_owner_properties.h" |
| 75 #include "content/common/render_process_messages.h" | 75 #include "content/common/render_process_messages.h" |
| 76 #include "content/common/resource_messages.h" | 76 #include "content/common/resource_messages.h" |
| 77 #include "content/common/service_worker/embedded_worker_setup.mojom.h" | |
| 78 #include "content/common/site_isolation_policy.h" | 77 #include "content/common/site_isolation_policy.h" |
| 79 #include "content/common/view_messages.h" | 78 #include "content/common/view_messages.h" |
| 80 #include "content/common/worker_messages.h" | 79 #include "content/common/worker_messages.h" |
| 81 #include "content/public/common/content_constants.h" | 80 #include "content/public/common/content_constants.h" |
| 82 #include "content/public/common/content_features.h" | 81 #include "content/public/common/content_features.h" |
| 83 #include "content/public/common/content_paths.h" | 82 #include "content/public/common/content_paths.h" |
| 84 #include "content/public/common/content_switches.h" | 83 #include "content/public/common/content_switches.h" |
| 85 #include "content/public/common/renderer_preferences.h" | 84 #include "content/public/common/renderer_preferences.h" |
| 86 #include "content/public/common/url_constants.h" | 85 #include "content/public/common/url_constants.h" |
| 87 #include "content/public/renderer/content_renderer_client.h" | 86 #include "content/public/renderer/content_renderer_client.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 356 |
| 358 private: | 357 private: |
| 359 int32_t routing_id_highmark_; | 358 int32_t routing_id_highmark_; |
| 360 }; | 359 }; |
| 361 | 360 |
| 362 void CreateFrameFactory(mojom::FrameFactoryRequest request) { | 361 void CreateFrameFactory(mojom::FrameFactoryRequest request) { |
| 363 mojo::MakeStrongBinding(base::MakeUnique<FrameFactoryImpl>(), | 362 mojo::MakeStrongBinding(base::MakeUnique<FrameFactoryImpl>(), |
| 364 std::move(request)); | 363 std::move(request)); |
| 365 } | 364 } |
| 366 | 365 |
| 367 void SetupEmbeddedWorkerOnWorkerThread( | |
| 368 mojom::ServiceWorkerEventDispatcherRequest request) { | |
| 369 ServiceWorkerContextClient* client = | |
| 370 ServiceWorkerContextClient::ThreadSpecificInstance(); | |
| 371 // It is possible for client to be null if for some reason the worker died | |
| 372 // before this call made it to the worker thread. In that case just do | |
| 373 // nothing and let mojo close the connection. | |
| 374 if (!client) | |
| 375 return; | |
| 376 client->BindEventDispatcher(std::move(request)); | |
| 377 } | |
| 378 | |
| 379 class EmbeddedWorkerSetupImpl : public mojom::EmbeddedWorkerSetup { | |
| 380 public: | |
| 381 EmbeddedWorkerSetupImpl() = default; | |
| 382 | |
| 383 void AttachServiceWorkerEventDispatcher( | |
| 384 int32_t thread_id, | |
| 385 mojom::ServiceWorkerEventDispatcherRequest request) override { | |
| 386 WorkerThreadRegistry::Instance()->GetTaskRunnerFor(thread_id)->PostTask( | |
| 387 FROM_HERE, | |
| 388 base::Bind(&SetupEmbeddedWorkerOnWorkerThread, base::Passed(&request))); | |
| 389 } | |
| 390 }; | |
| 391 | |
| 392 void CreateEmbeddedWorkerSetup(mojom::EmbeddedWorkerSetupRequest request) { | |
| 393 mojo::MakeStrongBinding(base::MakeUnique<EmbeddedWorkerSetupImpl>(), | |
| 394 std::move(request)); | |
| 395 } | |
| 396 | |
| 397 scoped_refptr<ui::ContextProviderCommandBuffer> CreateOffscreenContext( | 366 scoped_refptr<ui::ContextProviderCommandBuffer> CreateOffscreenContext( |
| 398 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, | 367 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host, |
| 399 const gpu::SharedMemoryLimits& limits, | 368 const gpu::SharedMemoryLimits& limits, |
| 400 bool support_locking, | 369 bool support_locking, |
| 401 ui::command_buffer_metrics::ContextType type, | 370 ui::command_buffer_metrics::ContextType type, |
| 402 int32_t stream_id, | 371 int32_t stream_id, |
| 403 gpu::GpuStreamPriority stream_priority) { | 372 gpu::GpuStreamPriority stream_priority) { |
| 404 DCHECK(gpu_channel_host); | 373 DCHECK(gpu_channel_host); |
| 405 // This is used to create a few different offscreen contexts: | 374 // This is used to create a few different offscreen contexts: |
| 406 // - The shared main thread context (offscreen) used by blink for canvas. | 375 // - The shared main thread context (offscreen) used by blink for canvas. |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 // TODO(boliu): In single process, browser main loop should set up the | 868 // TODO(boliu): In single process, browser main loop should set up the |
| 900 // discardable memory manager, and should skip this if kSingleProcess. | 869 // discardable memory manager, and should skip this if kSingleProcess. |
| 901 // See crbug.com/503724. | 870 // See crbug.com/503724. |
| 902 base::DiscardableMemoryAllocator::SetInstance( | 871 base::DiscardableMemoryAllocator::SetInstance( |
| 903 discardable_shared_memory_manager_.get()); | 872 discardable_shared_memory_manager_.get()); |
| 904 | 873 |
| 905 GetContentClient()->renderer()->ExposeInterfacesToBrowser( | 874 GetContentClient()->renderer()->ExposeInterfacesToBrowser( |
| 906 GetInterfaceRegistry()); | 875 GetInterfaceRegistry()); |
| 907 | 876 |
| 908 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); | 877 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); |
| 909 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); | |
| 910 GetInterfaceRegistry()->AddInterface( | 878 GetInterfaceRegistry()->AddInterface( |
| 911 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, | 879 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, |
| 912 base::Unretained(embedded_worker_dispatcher_.get()))); | 880 base::Unretained(embedded_worker_dispatcher_.get()))); |
| 913 | 881 |
| 914 GetRemoteInterfaces()->GetInterface( | 882 GetRemoteInterfaces()->GetInterface( |
| 915 mojo::MakeRequest(&storage_partition_service_)); | 883 mojo::MakeRequest(&storage_partition_service_)); |
| 916 | 884 |
| 917 #if defined(OS_LINUX) | 885 #if defined(OS_LINUX) |
| 918 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); | 886 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); |
| 919 ChildThreadImpl::current()->SetThreadPriority( | 887 ChildThreadImpl::current()->SetThreadPriority( |
| (...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2421 } | 2389 } |
| 2422 } | 2390 } |
| 2423 | 2391 |
| 2424 void RenderThreadImpl::OnRendererInterfaceRequest( | 2392 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2425 mojom::RendererAssociatedRequest request) { | 2393 mojom::RendererAssociatedRequest request) { |
| 2426 DCHECK(!renderer_binding_.is_bound()); | 2394 DCHECK(!renderer_binding_.is_bound()); |
| 2427 renderer_binding_.Bind(std::move(request)); | 2395 renderer_binding_.Bind(std::move(request)); |
| 2428 } | 2396 } |
| 2429 | 2397 |
| 2430 } // namespace content | 2398 } // namespace content |
| OLD | NEW |