| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "cc/output/compositor_frame_sink.h" | 46 #include "cc/output/compositor_frame_sink.h" |
| 47 #include "cc/output/copy_output_request.h" | 47 #include "cc/output/copy_output_request.h" |
| 48 #include "cc/output/vulkan_in_process_context_provider.h" | 48 #include "cc/output/vulkan_in_process_context_provider.h" |
| 49 #include "cc/raster/task_graph_runner.h" | 49 #include "cc/raster/task_graph_runner.h" |
| 50 #include "cc/trees/layer_tree_host_common.h" | 50 #include "cc/trees/layer_tree_host_common.h" |
| 51 #include "cc/trees/layer_tree_settings.h" | 51 #include "cc/trees/layer_tree_settings.h" |
| 52 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" | 52 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" |
| 53 #include "content/child/appcache/appcache_dispatcher.h" | 53 #include "content/child/appcache/appcache_dispatcher.h" |
| 54 #include "content/child/appcache/appcache_frontend_impl.h" | 54 #include "content/child/appcache/appcache_frontend_impl.h" |
| 55 #include "content/child/blob_storage/blob_message_filter.h" | 55 #include "content/child/blob_storage/blob_message_filter.h" |
| 56 #include "content/child/child_gpu_memory_buffer_manager.h" | |
| 57 #include "content/child/child_histogram_message_filter.h" | 56 #include "content/child/child_histogram_message_filter.h" |
| 58 #include "content/child/child_resource_message_filter.h" | 57 #include "content/child/child_resource_message_filter.h" |
| 59 #include "content/child/child_shared_bitmap_manager.h" | 58 #include "content/child/child_shared_bitmap_manager.h" |
| 60 #include "content/child/content_child_helpers.h" | 59 #include "content/child/content_child_helpers.h" |
| 61 #include "content/child/db_message_filter.h" | 60 #include "content/child/db_message_filter.h" |
| 62 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 61 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
| 63 #include "content/child/memory/child_memory_coordinator_impl.h" | 62 #include "content/child/memory/child_memory_coordinator_impl.h" |
| 64 #include "content/child/resource_dispatcher.h" | 63 #include "content/child/resource_dispatcher.h" |
| 65 #include "content/child/resource_scheduling_filter.h" | 64 #include "content/child/resource_scheduling_filter.h" |
| 66 #include "content/child/runtime_features.h" | 65 #include "content/child/runtime_features.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 #include "content/renderer/media/aec_dump_message_filter.h" | 190 #include "content/renderer/media/aec_dump_message_filter.h" |
| 192 #include "content/renderer/media/peer_connection_tracker.h" | 191 #include "content/renderer/media/peer_connection_tracker.h" |
| 193 #include "content/renderer/media/rtc_peer_connection_handler.h" | 192 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 194 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 193 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 195 #endif | 194 #endif |
| 196 | 195 |
| 197 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 196 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
| 198 #include "v8/src/third_party/vtune/v8-vtune.h" | 197 #include "v8/src/third_party/vtune/v8-vtune.h" |
| 199 #endif | 198 #endif |
| 200 | 199 |
| 201 #if defined(USE_AURA) | |
| 202 #include "content/public/common/service_manager_connection.h" | 200 #include "content/public/common/service_manager_connection.h" |
| 203 #include "content/renderer/mus/render_widget_mus_connection.h" | 201 #include "content/renderer/mus/render_widget_mus_connection.h" |
| 204 #include "content/renderer/mus/render_widget_window_tree_client_factory.h" | 202 #include "content/renderer/mus/render_widget_window_tree_client_factory.h" |
| 205 #include "services/ui/public/cpp/gpu/gpu.h" | 203 #include "services/ui/public/cpp/gpu/gpu.h" |
| 206 #endif | |
| 207 | 204 |
| 208 #if defined(ENABLE_IPC_FUZZER) | 205 #if defined(ENABLE_IPC_FUZZER) |
| 209 #include "content/common/external_ipc_dumper.h" | 206 #include "content/common/external_ipc_dumper.h" |
| 210 #endif | 207 #endif |
| 211 | 208 |
| 212 #if defined(OS_MACOSX) | 209 #if defined(OS_MACOSX) |
| 213 #include <malloc/malloc.h> | 210 #include <malloc/malloc.h> |
| 214 #else | 211 #else |
| 215 #include <malloc.h> | 212 #include <malloc.h> |
| 216 #endif | 213 #endif |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 #if defined(USE_EXTERNAL_POPUP_MENU) | 643 #if defined(USE_EXTERNAL_POPUP_MENU) |
| 647 // On Mac and Android Java UI, the select popups are rendered by the browser. | 644 // On Mac and Android Java UI, the select popups are rendered by the browser. |
| 648 blink::WebView::setUseExternalPopupMenus(true); | 645 blink::WebView::setUseExternalPopupMenus(true); |
| 649 #endif | 646 #endif |
| 650 | 647 |
| 651 lazy_tls.Pointer()->Set(this); | 648 lazy_tls.Pointer()->Set(this); |
| 652 | 649 |
| 653 // Register this object as the main thread. | 650 // Register this object as the main thread. |
| 654 ChildProcess::current()->set_main_thread(this); | 651 ChildProcess::current()->set_main_thread(this); |
| 655 | 652 |
| 656 #if defined(USE_AURA) | |
| 657 if (IsRunningInMash()) { | 653 if (IsRunningInMash()) { |
| 658 gpu_ = ui::Gpu::Create(GetServiceManagerConnection()->GetConnector(), | 654 gpu_ = ui::Gpu::Create(GetServiceManagerConnection()->GetConnector(), |
| 659 ChildProcess::current()->io_task_runner()); | 655 ChildProcess::current()->io_task_runner()); |
| 656 } else { |
| 657 gpu_ = ui::Gpu::Create(GetRemoteInterfaces(), |
| 658 ChildProcess::current()->io_task_runner()); |
| 660 } | 659 } |
| 661 #endif | |
| 662 gpu_memory_buffer_manager_ = | |
| 663 base::MakeUnique<ChildGpuMemoryBufferManager>(thread_safe_sender()); | |
| 664 | 660 |
| 665 thread_safe_associated_interface_ptr_provider_ = | 661 thread_safe_associated_interface_ptr_provider_ = |
| 666 base::MakeUnique<ThreadSafeAssociatedInterfacePtrProvider>(channel()); | 662 base::MakeUnique<ThreadSafeAssociatedInterfacePtrProvider>(channel()); |
| 667 thread_safe_render_message_filter_ = | 663 thread_safe_render_message_filter_ = |
| 668 thread_safe_associated_interface_ptr_provider_ | 664 thread_safe_associated_interface_ptr_provider_ |
| 669 ->CreateInterfacePtr<mojom::RenderMessageFilter>(); | 665 ->CreateInterfacePtr<mojom::RenderMessageFilter>(); |
| 670 shared_bitmap_manager_.reset( | 666 shared_bitmap_manager_.reset( |
| 671 new ChildSharedBitmapManager(thread_safe_render_message_filter_)); | 667 new ChildSharedBitmapManager(thread_safe_render_message_filter_)); |
| 672 | 668 |
| 673 InitializeWebKit(resource_task_queue); | 669 InitializeWebKit(resource_task_queue); |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 RenderThreadImpl::GetCompositorMainThreadTaskRunner() { | 1647 RenderThreadImpl::GetCompositorMainThreadTaskRunner() { |
| 1652 return main_thread_compositor_task_runner_; | 1648 return main_thread_compositor_task_runner_; |
| 1653 } | 1649 } |
| 1654 | 1650 |
| 1655 scoped_refptr<base::SingleThreadTaskRunner> | 1651 scoped_refptr<base::SingleThreadTaskRunner> |
| 1656 RenderThreadImpl::GetCompositorImplThreadTaskRunner() { | 1652 RenderThreadImpl::GetCompositorImplThreadTaskRunner() { |
| 1657 return compositor_task_runner_; | 1653 return compositor_task_runner_; |
| 1658 } | 1654 } |
| 1659 | 1655 |
| 1660 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { | 1656 gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { |
| 1661 #if defined(USE_AURA) | 1657 return gpu_->gpu_memory_buffer_manager(); |
| 1662 if (gpu_) | |
| 1663 return gpu_->gpu_memory_buffer_manager(); | |
| 1664 #endif | |
| 1665 return gpu_memory_buffer_manager_.get(); | |
| 1666 } | 1658 } |
| 1667 | 1659 |
| 1668 blink::scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { | 1660 blink::scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { |
| 1669 return renderer_scheduler_.get(); | 1661 return renderer_scheduler_.get(); |
| 1670 } | 1662 } |
| 1671 | 1663 |
| 1672 std::unique_ptr<cc::BeginFrameSource> | 1664 std::unique_ptr<cc::BeginFrameSource> |
| 1673 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { | 1665 RenderThreadImpl::CreateExternalBeginFrameSource(int routing_id) { |
| 1674 const base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 1666 const base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 1675 if (cmd->HasSwitch(switches::kDisableGpuVsync)) { | 1667 if (cmd->HasSwitch(switches::kDisableGpuVsync)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 | 1705 |
| 1714 void RenderThreadImpl::OnRAILModeChanged(v8::RAILMode rail_mode) { | 1706 void RenderThreadImpl::OnRAILModeChanged(v8::RAILMode rail_mode) { |
| 1715 blink::mainThreadIsolate()->SetRAILMode(rail_mode); | 1707 blink::mainThreadIsolate()->SetRAILMode(rail_mode); |
| 1716 blink::setRAILModeOnWorkerThreadIsolates(rail_mode); | 1708 blink::setRAILModeOnWorkerThreadIsolates(rail_mode); |
| 1717 } | 1709 } |
| 1718 | 1710 |
| 1719 bool RenderThreadImpl::IsMainThread() { | 1711 bool RenderThreadImpl::IsMainThread() { |
| 1720 return !!current(); | 1712 return !!current(); |
| 1721 } | 1713 } |
| 1722 | 1714 |
| 1723 scoped_refptr<base::SingleThreadTaskRunner> | |
| 1724 RenderThreadImpl::GetIOThreadTaskRunner() { | |
| 1725 return io_thread_task_runner_; | |
| 1726 } | |
| 1727 | |
| 1728 std::unique_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( | |
| 1729 size_t size) { | |
| 1730 return HostAllocateSharedMemoryBuffer(size); | |
| 1731 } | |
| 1732 | |
| 1733 void RenderThreadImpl::OnChannelError() { | 1715 void RenderThreadImpl::OnChannelError() { |
| 1734 // In single-process mode, the renderer can't be restarted after shutdown. | 1716 // In single-process mode, the renderer can't be restarted after shutdown. |
| 1735 // So, if we get a channel error, crash the whole process right now to get a | 1717 // So, if we get a channel error, crash the whole process right now to get a |
| 1736 // more informative stack, since we will otherwise just crash later when we | 1718 // more informative stack, since we will otherwise just crash later when we |
| 1737 // try to restart it. | 1719 // try to restart it. |
| 1738 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1720 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1739 switches::kSingleProcess)); | 1721 switches::kSingleProcess)); |
| 1740 ChildThreadImpl::OnChannelError(); | 1722 ChildThreadImpl::OnChannelError(); |
| 1741 } | 1723 } |
| 1742 | 1724 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 // Do nothing if we already have a GPU channel or are already | 1894 // Do nothing if we already have a GPU channel or are already |
| 1913 // establishing one. | 1895 // establishing one. |
| 1914 if (!gpu_channel_->IsLost()) | 1896 if (!gpu_channel_->IsLost()) |
| 1915 return gpu_channel_; | 1897 return gpu_channel_; |
| 1916 | 1898 |
| 1917 // Recreate the channel if it has been lost. | 1899 // Recreate the channel if it has been lost. |
| 1918 gpu_channel_->DestroyChannel(); | 1900 gpu_channel_->DestroyChannel(); |
| 1919 gpu_channel_ = nullptr; | 1901 gpu_channel_ = nullptr; |
| 1920 } | 1902 } |
| 1921 | 1903 |
| 1922 if (!IsRunningInMash()) { | 1904 gpu_channel_ = gpu_->EstablishGpuChannelSync(); |
| 1923 int client_id = 0; | 1905 if (gpu_channel_) |
| 1924 IPC::ChannelHandle channel_handle; | 1906 GetContentClient()->SetGpuInfo(gpu_channel_->gpu_info()); |
| 1925 gpu::GPUInfo gpu_info; | |
| 1926 // Ask the browser for the channel name. | |
| 1927 if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( | |
| 1928 &client_id, &channel_handle, &gpu_info)) || | |
| 1929 !channel_handle.mojo_handle.is_valid()) { | |
| 1930 // Otherwise cancel the connection. | |
| 1931 return nullptr; | |
| 1932 } | |
| 1933 GetContentClient()->SetGpuInfo(gpu_info); | |
| 1934 | |
| 1935 // Cache some variables that are needed on the compositor thread for our | |
| 1936 // implementation of GpuChannelHostFactory. | |
| 1937 io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); | |
| 1938 | |
| 1939 gpu_channel_ = | |
| 1940 gpu::GpuChannelHost::Create(this, client_id, gpu_info, channel_handle, | |
| 1941 ChildProcess::current()->GetShutDownEvent(), | |
| 1942 GetGpuMemoryBufferManager()); | |
| 1943 } else { | |
| 1944 #if defined(USE_AURA) | |
| 1945 gpu_channel_ = gpu_->EstablishGpuChannelSync(); | |
| 1946 #else | |
| 1947 NOTREACHED(); | |
| 1948 #endif | |
| 1949 } | |
| 1950 return gpu_channel_; | 1907 return gpu_channel_; |
| 1951 } | 1908 } |
| 1952 | 1909 |
| 1953 std::unique_ptr<cc::CompositorFrameSink> | 1910 std::unique_ptr<cc::CompositorFrameSink> |
| 1954 RenderThreadImpl::CreateCompositorFrameSink( | 1911 RenderThreadImpl::CreateCompositorFrameSink( |
| 1955 bool use_software, | 1912 bool use_software, |
| 1956 int routing_id, | 1913 int routing_id, |
| 1957 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, | 1914 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, |
| 1958 const GURL& url) { | 1915 const GURL& url) { |
| 1959 const base::CommandLine& command_line = | 1916 const base::CommandLine& command_line = |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2503 } | 2460 } |
| 2504 } | 2461 } |
| 2505 | 2462 |
| 2506 void RenderThreadImpl::OnRendererInterfaceRequest( | 2463 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2507 mojom::RendererAssociatedRequest request) { | 2464 mojom::RendererAssociatedRequest request) { |
| 2508 DCHECK(!renderer_binding_.is_bound()); | 2465 DCHECK(!renderer_binding_.is_bound()); |
| 2509 renderer_binding_.Bind(std::move(request)); | 2466 renderer_binding_.Bind(std::move(request)); |
| 2510 } | 2467 } |
| 2511 | 2468 |
| 2512 } // namespace content | 2469 } // namespace content |
| OLD | NEW |