| Index: content/renderer/render_thread_impl.cc
|
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
|
| index be2f9b1376bf5c2994b23b544c0bbdf9f6e7081f..950f485cffe1baab6071fdbbfa52c0b196479eb3 100644
|
| --- a/content/renderer/render_thread_impl.cc
|
| +++ b/content/renderer/render_thread_impl.cc
|
| @@ -123,6 +123,7 @@
|
| #include "content/renderer/shared_worker/embedded_shared_worker_stub.h"
|
| #include "gin/public/debug.h"
|
| #include "gpu/GLES2/gl2extchromium.h"
|
| +#include "gpu/command_buffer/client/context_support.h"
|
| #include "gpu/command_buffer/client/shared_memory_limits.h"
|
| #include "gpu/ipc/client/command_buffer_proxy_impl.h"
|
| #include "gpu/ipc/client/gpu_channel_host.h"
|
| @@ -160,6 +161,7 @@
|
| #include "third_party/WebKit/public/web/WebView.h"
|
| #include "third_party/icu/source/i18n/unicode/timezone.h"
|
| #include "third_party/skia/include/core/SkGraphics.h"
|
| +#include "third_party/skia/include/gpu/GrContext.h"
|
| #include "ui/base/layout.h"
|
| #include "ui/base/ui_base_switches.h"
|
|
|
| @@ -440,6 +442,23 @@ bool IsRunningInMash() {
|
| return cmdline->HasSwitch(switches::kIsRunningInMash);
|
| }
|
|
|
| +void OnSharedWorkerContextIdle(cc::ContextProvider* context_provider) {
|
| + // If we can't acquire the lock, someone has started using this context, so
|
| + // we are no longer idle.
|
| + base::Lock* lock = context_provider->GetLock();
|
| + if (!lock->Try())
|
| + return;
|
| +
|
| + context_provider->DetachFromThread();
|
| + context_provider->BindToCurrentThread();
|
| +
|
| + context_provider->DeleteCachedResources();
|
| +
|
| + // Detach from thread to allow a new thread to attach.
|
| + context_provider->DetachFromThread();
|
| + lock->Release();
|
| +}
|
| +
|
| } // namespace
|
|
|
| // For measuring memory usage after each task. Behind a command line flag.
|
| @@ -2126,6 +2145,13 @@ RenderThreadImpl::SharedCompositorWorkerContextProvider() {
|
| stream_priority);
|
| if (!shared_worker_context_provider_->BindToCurrentThread())
|
| shared_worker_context_provider_ = nullptr;
|
| +
|
| + // Set the idle callback. This callback is only called if ContextSupport
|
| + // is alive, so we know that the unretained worker context provider
|
| + // pointer will also be alive.
|
| + shared_worker_context_provider_->ContextSupport()->SetIdleCallback(
|
| + base::Bind(&OnSharedWorkerContextIdle,
|
| + base::Unretained(shared_worker_context_provider_.get())));
|
| return shared_worker_context_provider_;
|
| }
|
|
|
|
|