| 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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 | 817 |
| 818 categorized_worker_pool_->Start(num_raster_threads); | 818 categorized_worker_pool_->Start(num_raster_threads); |
| 819 | 819 |
| 820 // TODO(boliu): In single process, browser main loop should set up the | 820 // TODO(boliu): In single process, browser main loop should set up the |
| 821 // discardable memory manager, and should skip this if kSingleProcess. | 821 // discardable memory manager, and should skip this if kSingleProcess. |
| 822 // See crbug.com/503724. | 822 // See crbug.com/503724. |
| 823 base::DiscardableMemoryAllocator::SetInstance( | 823 base::DiscardableMemoryAllocator::SetInstance( |
| 824 ChildThreadImpl::discardable_shared_memory_manager()); | 824 ChildThreadImpl::discardable_shared_memory_manager()); |
| 825 | 825 |
| 826 GetContentClient()->renderer()->RegisterProcessMojoInterfaces( | 826 GetContentClient()->renderer()->RegisterProcessMojoInterfaces( |
| 827 interface_registry()); | 827 GetInterfaceRegistry()); |
| 828 | 828 |
| 829 interface_registry()->AddInterface(base::Bind(CreateFrameFactory)); | 829 GetInterfaceRegistry()->AddInterface(base::Bind(CreateFrameFactory)); |
| 830 interface_registry()->AddInterface(base::Bind(CreateEmbeddedWorkerSetup)); | 830 GetInterfaceRegistry()->AddInterface(base::Bind(CreateEmbeddedWorkerSetup)); |
| 831 | 831 |
| 832 #if defined(MOJO_SHELL_CLIENT) | 832 #if defined(MOJO_SHELL_CLIENT) |
| 833 // We may not have a MojoShellConnection object in tests that directly | 833 // We may not have a MojoShellConnection object in tests that directly |
| 834 // instantiate a RenderThreadImpl. | 834 // instantiate a RenderThreadImpl. |
| 835 if (MojoShellConnection::GetForProcess() && | 835 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 836 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 837 switches::kUseMusInRenderer)) | 836 switches::kUseMusInRenderer)) |
| 838 CreateRenderWidgetWindowTreeClientFactory(); | 837 CreateRenderWidgetWindowTreeClientFactory(); |
| 839 #endif | 838 #endif |
| 840 | 839 |
| 841 remote_interfaces()->GetInterface( | 840 GetRemoteInterfaces()->GetInterface(&storage_partition_service_); |
| 842 mojo::GetProxy(&storage_partition_service_)); | |
| 843 | 841 |
| 844 is_renderer_suspended_ = false; | 842 is_renderer_suspended_ = false; |
| 845 } | 843 } |
| 846 | 844 |
| 847 RenderThreadImpl::~RenderThreadImpl() { | 845 RenderThreadImpl::~RenderThreadImpl() { |
| 848 } | 846 } |
| 849 | 847 |
| 850 void RenderThreadImpl::Shutdown() { | 848 void RenderThreadImpl::Shutdown() { |
| 851 FOR_EACH_OBSERVER( | 849 FOR_EACH_OBSERVER( |
| 852 RenderThreadObserver, observers_, OnRenderProcessShutdown()); | 850 RenderThreadObserver, observers_, OnRenderProcessShutdown()); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 | 1146 |
| 1149 #ifdef ENABLE_VTUNE_JIT_INTERFACE | 1147 #ifdef ENABLE_VTUNE_JIT_INTERFACE |
| 1150 if (command_line.HasSwitch(switches::kEnableVtune)) | 1148 if (command_line.HasSwitch(switches::kEnableVtune)) |
| 1151 gin::Debug::SetJitCodeEventHandler(vTune::GetVtuneCodeEventHandler()); | 1149 gin::Debug::SetJitCodeEventHandler(vTune::GetVtuneCodeEventHandler()); |
| 1152 #endif | 1150 #endif |
| 1153 | 1151 |
| 1154 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); | 1152 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); |
| 1155 | 1153 |
| 1156 blink_platform_impl_.reset(new RendererBlinkPlatformImpl( | 1154 blink_platform_impl_.reset(new RendererBlinkPlatformImpl( |
| 1157 renderer_scheduler_.get(), | 1155 renderer_scheduler_.get(), |
| 1158 remote_interfaces()->GetWeakPtr())); | 1156 GetRemoteInterfaces()->GetWeakPtr())); |
| 1159 blink::initialize(blink_platform_impl_.get()); | 1157 blink::initialize(blink_platform_impl_.get()); |
| 1160 | 1158 |
| 1161 v8::Isolate* isolate = blink::mainThreadIsolate(); | 1159 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 1162 isolate->SetCreateHistogramFunction(CreateHistogram); | 1160 isolate->SetCreateHistogramFunction(CreateHistogram); |
| 1163 isolate->SetAddHistogramSampleFunction(AddHistogramSample); | 1161 isolate->SetAddHistogramSampleFunction(AddHistogramSample); |
| 1164 | 1162 |
| 1165 main_thread_compositor_task_runner_ = | 1163 main_thread_compositor_task_runner_ = |
| 1166 renderer_scheduler_->CompositorTaskRunner(); | 1164 renderer_scheduler_->CompositorTaskRunner(); |
| 1167 | 1165 |
| 1168 main_input_callback_.Reset( | 1166 main_input_callback_.Reset( |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 } | 1534 } |
| 1537 | 1535 |
| 1538 #if defined(OS_WIN) | 1536 #if defined(OS_WIN) |
| 1539 void RenderThreadImpl::PreCacheFontCharacters(const LOGFONT& log_font, | 1537 void RenderThreadImpl::PreCacheFontCharacters(const LOGFONT& log_font, |
| 1540 const base::string16& str) { | 1538 const base::string16& str) { |
| 1541 Send(new RenderProcessHostMsg_PreCacheFontCharacters(log_font, str)); | 1539 Send(new RenderProcessHostMsg_PreCacheFontCharacters(log_font, str)); |
| 1542 } | 1540 } |
| 1543 | 1541 |
| 1544 #endif // OS_WIN | 1542 #endif // OS_WIN |
| 1545 | 1543 |
| 1546 shell::InterfaceRegistry* RenderThreadImpl::GetInterfaceRegistry() { | |
| 1547 DCHECK(interface_registry()); | |
| 1548 return interface_registry(); | |
| 1549 } | |
| 1550 | |
| 1551 shell::InterfaceProvider* RenderThreadImpl::GetRemoteInterfaces() { | |
| 1552 DCHECK(remote_interfaces()); | |
| 1553 return remote_interfaces(); | |
| 1554 } | |
| 1555 | |
| 1556 bool RenderThreadImpl::IsGpuRasterizationForced() { | 1544 bool RenderThreadImpl::IsGpuRasterizationForced() { |
| 1557 return is_gpu_rasterization_forced_; | 1545 return is_gpu_rasterization_forced_; |
| 1558 } | 1546 } |
| 1559 | 1547 |
| 1560 bool RenderThreadImpl::IsGpuRasterizationEnabled() { | 1548 bool RenderThreadImpl::IsGpuRasterizationEnabled() { |
| 1561 return is_gpu_rasterization_enabled_; | 1549 return is_gpu_rasterization_enabled_; |
| 1562 } | 1550 } |
| 1563 | 1551 |
| 1564 bool RenderThreadImpl::IsAsyncWorkerContextEnabled() { | 1552 bool RenderThreadImpl::IsAsyncWorkerContextEnabled() { |
| 1565 return is_async_worker_context_enabled_; | 1553 return is_async_worker_context_enabled_; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 bool use_software, | 1793 bool use_software, |
| 1806 int routing_id, | 1794 int routing_id, |
| 1807 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, | 1795 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, |
| 1808 const GURL& url) { | 1796 const GURL& url) { |
| 1809 const base::CommandLine& command_line = | 1797 const base::CommandLine& command_line = |
| 1810 *base::CommandLine::ForCurrentProcess(); | 1798 *base::CommandLine::ForCurrentProcess(); |
| 1811 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) | 1799 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) |
| 1812 use_software = true; | 1800 use_software = true; |
| 1813 | 1801 |
| 1814 #if defined(MOJO_SHELL_CLIENT) | 1802 #if defined(MOJO_SHELL_CLIENT) |
| 1815 if (MojoShellConnection::GetForProcess() && !use_software && | 1803 if (!use_software && command_line.HasSwitch(switches::kUseMusInRenderer)) { |
| 1816 command_line.HasSwitch(switches::kUseMusInRenderer)) { | |
| 1817 RenderWidgetMusConnection* connection = | 1804 RenderWidgetMusConnection* connection = |
| 1818 RenderWidgetMusConnection::GetOrCreate(routing_id); | 1805 RenderWidgetMusConnection::GetOrCreate(routing_id); |
| 1819 return connection->CreateOutputSurface(); | 1806 return connection->CreateOutputSurface(); |
| 1820 } | 1807 } |
| 1821 #endif | 1808 #endif |
| 1822 | 1809 |
| 1823 uint32_t output_surface_id = g_next_output_surface_id++; | 1810 uint32_t output_surface_id = g_next_output_surface_id++; |
| 1824 | 1811 |
| 1825 if (command_line.HasSwitch(switches::kEnableVulkan)) { | 1812 if (command_line.HasSwitch(switches::kEnableVulkan)) { |
| 1826 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 1813 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2217 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2204 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
| 2218 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2205 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
| 2219 | 2206 |
| 2220 blink::mainThreadIsolate()->MemoryPressureNotification( | 2207 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2221 v8_memory_pressure_level); | 2208 v8_memory_pressure_level); |
| 2222 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2209 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2223 v8_memory_pressure_level); | 2210 v8_memory_pressure_level); |
| 2224 } | 2211 } |
| 2225 | 2212 |
| 2226 } // namespace content | 2213 } // namespace content |
| OLD | NEW |