Chromium Code Reviews| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 #include "content/renderer/render_process_impl.h" | 116 #include "content/renderer/render_process_impl.h" |
| 117 #include "content/renderer/render_view_impl.h" | 117 #include "content/renderer/render_view_impl.h" |
| 118 #include "content/renderer/renderer_blink_platform_impl.h" | 118 #include "content/renderer/renderer_blink_platform_impl.h" |
| 119 #include "content/renderer/scheduler/resource_dispatch_throttler.h" | 119 #include "content/renderer/scheduler/resource_dispatch_throttler.h" |
| 120 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" | 120 #include "content/renderer/service_worker/embedded_worker_dispatcher.h" |
| 121 #include "content/renderer/service_worker/service_worker_context_client.h" | 121 #include "content/renderer/service_worker/service_worker_context_client.h" |
| 122 #include "content/renderer/service_worker/service_worker_context_message_filter. h" | 122 #include "content/renderer/service_worker/service_worker_context_message_filter. h" |
| 123 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" | 123 #include "content/renderer/shared_worker/embedded_shared_worker_stub.h" |
| 124 #include "gin/public/debug.h" | 124 #include "gin/public/debug.h" |
| 125 #include "gpu/GLES2/gl2extchromium.h" | 125 #include "gpu/GLES2/gl2extchromium.h" |
| 126 #include "gpu/command_buffer/client/context_support.h" | |
| 126 #include "gpu/command_buffer/client/shared_memory_limits.h" | 127 #include "gpu/command_buffer/client/shared_memory_limits.h" |
| 127 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 128 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 128 #include "gpu/ipc/client/gpu_channel_host.h" | 129 #include "gpu/ipc/client/gpu_channel_host.h" |
| 129 #include "ipc/ipc_channel_handle.h" | 130 #include "ipc/ipc_channel_handle.h" |
| 130 #include "ipc/ipc_channel_mojo.h" | 131 #include "ipc/ipc_channel_mojo.h" |
| 131 #include "ipc/ipc_platform_file.h" | 132 #include "ipc/ipc_platform_file.h" |
| 132 #include "media/base/media.h" | 133 #include "media/base/media.h" |
| 133 #include "media/renderers/gpu_video_accelerator_factories.h" | 134 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 134 #include "mojo/common/common_type_converters.h" | 135 #include "mojo/common/common_type_converters.h" |
| 135 #include "mojo/public/cpp/bindings/strong_binding.h" | 136 #include "mojo/public/cpp/bindings/strong_binding.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 153 #include "third_party/WebKit/public/web/WebDocument.h" | 154 #include "third_party/WebKit/public/web/WebDocument.h" |
| 154 #include "third_party/WebKit/public/web/WebFrame.h" | 155 #include "third_party/WebKit/public/web/WebFrame.h" |
| 155 #include "third_party/WebKit/public/web/WebKit.h" | 156 #include "third_party/WebKit/public/web/WebKit.h" |
| 156 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" | 157 #include "third_party/WebKit/public/web/WebNetworkStateNotifier.h" |
| 157 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 158 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 158 #include "third_party/WebKit/public/web/WebScriptController.h" | 159 #include "third_party/WebKit/public/web/WebScriptController.h" |
| 159 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 160 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 160 #include "third_party/WebKit/public/web/WebView.h" | 161 #include "third_party/WebKit/public/web/WebView.h" |
| 161 #include "third_party/icu/source/i18n/unicode/timezone.h" | 162 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 162 #include "third_party/skia/include/core/SkGraphics.h" | 163 #include "third_party/skia/include/core/SkGraphics.h" |
| 164 #include "third_party/skia/include/gpu/GrContext.h" | |
| 163 #include "ui/base/layout.h" | 165 #include "ui/base/layout.h" |
| 164 #include "ui/base/ui_base_switches.h" | 166 #include "ui/base/ui_base_switches.h" |
| 165 | 167 |
| 166 #if defined(OS_ANDROID) | 168 #if defined(OS_ANDROID) |
| 167 #include <cpu-features.h> | 169 #include <cpu-features.h> |
| 168 #include "content/renderer/android/synchronous_compositor_filter.h" | 170 #include "content/renderer/android/synchronous_compositor_filter.h" |
| 169 #include "content/renderer/android/synchronous_compositor_output_surface.h" | 171 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
| 170 #include "content/renderer/media/android/renderer_demuxer_android.h" | 172 #include "content/renderer/media/android/renderer_demuxer_android.h" |
| 171 #include "content/renderer/media/android/stream_texture_factory.h" | 173 #include "content/renderer/media/android/stream_texture_factory.h" |
| 172 #include "media/base/android/media_codec_util.h" | 174 #include "media/base/android/media_codec_util.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 gpu::kNullSurfaceHandle, | 435 gpu::kNullSurfaceHandle, |
| 434 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), | 436 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), |
| 435 automatic_flushes, support_locking, limits, attributes, nullptr, type)); | 437 automatic_flushes, support_locking, limits, attributes, nullptr, type)); |
| 436 } | 438 } |
| 437 | 439 |
| 438 bool IsRunningInMash() { | 440 bool IsRunningInMash() { |
| 439 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 441 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 440 return cmdline->HasSwitch(switches::kIsRunningInMash); | 442 return cmdline->HasSwitch(switches::kIsRunningInMash); |
| 441 } | 443 } |
| 442 | 444 |
| 445 void OnSharedWorkerContextIdle(cc::ContextProvider* context_provider) { | |
| 446 // If we can't acquire the lock, someone has started using this context, so | |
| 447 // we are no longer idle. | |
| 448 base::Lock* lock = context_provider->GetLock(); | |
| 449 if (!lock->Try()) | |
| 450 return; | |
| 451 | |
| 452 context_provider->DetachFromThread(); | |
| 453 context_provider->BindToCurrentThread(); | |
| 454 | |
| 455 context_provider->DeleteCachedResources(); | |
| 456 context_provider->ContextSupport()->TrimResources(); | |
|
danakj
2016/08/23 01:26:24
Why do we need a separate TrimResources from Delet
| |
| 457 | |
| 458 // Detach from thread to allow a new thread to attach. | |
| 459 context_provider->DetachFromThread(); | |
| 460 lock->Release(); | |
| 461 } | |
| 462 | |
| 443 } // namespace | 463 } // namespace |
| 444 | 464 |
| 445 // For measuring memory usage after each task. Behind a command line flag. | 465 // For measuring memory usage after each task. Behind a command line flag. |
| 446 class MemoryObserver : public base::MessageLoop::TaskObserver { | 466 class MemoryObserver : public base::MessageLoop::TaskObserver { |
| 447 public: | 467 public: |
| 448 MemoryObserver() {} | 468 MemoryObserver() {} |
| 449 ~MemoryObserver() override {} | 469 ~MemoryObserver() override {} |
| 450 | 470 |
| 451 void WillProcessTask(const base::PendingTask& pending_task) override {} | 471 void WillProcessTask(const base::PendingTask& pending_task) override {} |
| 452 | 472 |
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2119 stream_priority = gpu::GpuStreamPriority::LOW; | 2139 stream_priority = gpu::GpuStreamPriority::LOW; |
| 2120 } | 2140 } |
| 2121 | 2141 |
| 2122 bool support_locking = true; | 2142 bool support_locking = true; |
| 2123 shared_worker_context_provider_ = CreateOffscreenContext( | 2143 shared_worker_context_provider_ = CreateOffscreenContext( |
| 2124 std::move(gpu_channel_host), gpu::SharedMemoryLimits(), support_locking, | 2144 std::move(gpu_channel_host), gpu::SharedMemoryLimits(), support_locking, |
| 2125 command_buffer_metrics::RENDER_WORKER_CONTEXT, stream_id, | 2145 command_buffer_metrics::RENDER_WORKER_CONTEXT, stream_id, |
| 2126 stream_priority); | 2146 stream_priority); |
| 2127 if (!shared_worker_context_provider_->BindToCurrentThread()) | 2147 if (!shared_worker_context_provider_->BindToCurrentThread()) |
| 2128 shared_worker_context_provider_ = nullptr; | 2148 shared_worker_context_provider_ = nullptr; |
| 2149 | |
| 2150 // Set the idle callback. This callback is only called if ContextSupport | |
| 2151 // is alive, so we know that the unreatained worker context provider | |
|
danakj
2016/08/23 01:26:24
unretained
| |
| 2152 // pointer will also be alive. | |
| 2153 shared_worker_context_provider_->ContextSupport()->SetIdleCallback( | |
| 2154 base::Bind(&OnSharedWorkerContextIdle, | |
| 2155 base::Unretained(shared_worker_context_provider_.get())), | |
| 2156 base::ThreadTaskRunnerHandle::Get()); | |
|
danakj
2016/08/23 01:26:24
what about just making it use the task runner the
ericrk
2016/08/24 18:32:21
The current callback systems always funnels throug
| |
| 2129 return shared_worker_context_provider_; | 2157 return shared_worker_context_provider_; |
| 2130 } | 2158 } |
| 2131 | 2159 |
| 2132 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { | 2160 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { |
| 2133 blink_platform_impl_->sampleGamepads(*data); | 2161 blink_platform_impl_->sampleGamepads(*data); |
| 2134 } | 2162 } |
| 2135 | 2163 |
| 2136 bool RenderThreadImpl::RendererIsHidden() const { | 2164 bool RenderThreadImpl::RendererIsHidden() const { |
| 2137 return widget_count_ > 0 && hidden_widget_count_ == widget_count_; | 2165 return widget_count_ > 0 && hidden_widget_count_ == widget_count_; |
| 2138 } | 2166 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2231 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2259 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
| 2232 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2260 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
| 2233 | 2261 |
| 2234 blink::mainThreadIsolate()->MemoryPressureNotification( | 2262 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2235 v8_memory_pressure_level); | 2263 v8_memory_pressure_level); |
| 2236 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2264 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2237 v8_memory_pressure_level); | 2265 v8_memory_pressure_level); |
| 2238 } | 2266 } |
| 2239 | 2267 |
| 2240 } // namespace content | 2268 } // namespace content |
| OLD | NEW |