12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "webkit/common/gpu/context_provider_in_process.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include <set>
8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
93551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "base/bind.h"
10fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch#include "base/callback_helpers.h"
11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/strings/string_split.h"
12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/strings/stringprintf.h"
133551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "cc/output/managed_memory_policy.h"
148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "gpu/command_buffer/client/gles2_implementation.h"
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace webkit {
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace gpu {
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ContextProviderInProcess::LostContextCallbackProxy
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)    : public blink::WebGraphicsContext3D::WebGraphicsContextLostCallback {
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  explicit LostContextCallbackProxy(ContextProviderInProcess* provider)
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      : provider_(provider) {
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    provider_->context3d_->setContextLostCallback(this);
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
287dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  virtual ~LostContextCallbackProxy() {
297dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch    provider_->context3d_->setContextLostCallback(NULL);
307dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  }
317dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual void onContextLost() {
33fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch    provider_->OnLostContext();
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ContextProviderInProcess* provider_;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
403551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// static
413551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)scoped_refptr<ContextProviderInProcess> ContextProviderInProcess::Create(
42d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
43d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    const std::string& debug_name) {
443551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  if (!context3d)
453551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    return NULL;
46d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  return new ContextProviderInProcess(context3d.Pass(), debug_name);
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
493551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)// static
503551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)scoped_refptr<ContextProviderInProcess>
51e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen MurdochContextProviderInProcess::CreateOffscreen(
52e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    bool lose_context_when_out_of_memory) {
53f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebGraphicsContext3D::Attributes attributes;
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  attributes.depth = false;
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  attributes.stencil = true;
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  attributes.antialias = false;
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  attributes.shareResources = true;
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  attributes.noAutomaticFlushes = true;
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
603551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  return Create(
61c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
62e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch          attributes, lose_context_when_out_of_memory),
63e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch      "Offscreen");
643551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)}
653551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
663551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)ContextProviderInProcess::ContextProviderInProcess(
67d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
68d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    const std::string& debug_name)
693551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    : context3d_(context3d.Pass()),
70d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)      destroyed_(false),
71d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)      debug_name_(debug_name) {
723551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  DCHECK(main_thread_checker_.CalledOnValidThread());
733551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  DCHECK(context3d_);
743551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  context_thread_checker_.DetachFromThread();
753551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)}
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
773551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)ContextProviderInProcess::~ContextProviderInProcess() {
783551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  DCHECK(main_thread_checker_.CalledOnValidThread() ||
793551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)         context_thread_checker_.CalledOnValidThread());
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)blink::WebGraphicsContext3D* ContextProviderInProcess::WebContext3D() {
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DCHECK(lost_context_callback_proxy_);  // Is bound to thread.
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  DCHECK(context_thread_checker_.CalledOnValidThread());
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return context3d_.get();
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool ContextProviderInProcess::BindToCurrentThread() {
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DCHECK(context3d_);
912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
92fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  // This is called on the thread the context will be used.
93fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  DCHECK(context_thread_checker_.CalledOnValidThread());
94fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch
952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (lost_context_callback_proxy_)
962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return true;
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
981320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  if (!context3d_->InitializeOnCurrentThread())
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return false;
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
101a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  InitializeCapabilities();
102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
103d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  std::string unique_context_name =
104d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)      base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get());
105d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  context3d_->pushGroupMarkerEXT(unique_context_name.c_str());
106d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this));
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return true;
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
111a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void ContextProviderInProcess::InitializeCapabilities() {
1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  capabilities_.gpu = context3d_->GetImplementation()->capabilities();
11303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)
11403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit();
11503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  capabilities_.max_transfer_buffer_usage_bytes =
11603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)      mapped_memory_limit ==
11703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)              WebGraphicsContext3DInProcessCommandBufferImpl::kNoLimit
11803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          ? std::numeric_limits<size_t>::max()
11903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)          : mapped_memory_limit;
120a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}
121a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
122424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)cc::ContextProvider::Capabilities
123424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)ContextProviderInProcess::ContextCapabilities() {
124a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  DCHECK(lost_context_callback_proxy_);  // Is bound to thread.
125a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  DCHECK(context_thread_checker_.CalledOnValidThread());
126a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  return capabilities_;
127424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
128424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
129a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)::gpu::gles2::GLES2Interface* ContextProviderInProcess::ContextGL() {
1308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DCHECK(context3d_);
1318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DCHECK(lost_context_callback_proxy_);  // Is bound to thread.
1328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  DCHECK(context_thread_checker_.CalledOnValidThread());
1338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
134a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  return context3d_->GetGLInterface();
135a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}
136a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
137a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)::gpu::ContextSupport* ContextProviderInProcess::ContextSupport() {
138a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  DCHECK(context3d_);
139a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  if (!lost_context_callback_proxy_)
140a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)    return NULL;  // Not bound to anything.
141a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
142a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  DCHECK(context_thread_checker_.CalledOnValidThread());
143a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
1448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  return context3d_->GetContextSupport();
1458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
1468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class GrContext* ContextProviderInProcess::GrContext() {
1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DCHECK(lost_context_callback_proxy_);  // Is bound to thread.
149fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  DCHECK(context_thread_checker_.CalledOnValidThread());
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (gr_context_)
1522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return gr_context_->get();
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  gr_context_.reset(
1552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      new webkit::gpu::GrContextForWebGraphicsContext3D(context3d_.get()));
1562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return gr_context_->get();
1572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
159f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)bool ContextProviderInProcess::IsContextLost() {
160f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  DCHECK(lost_context_callback_proxy_);  // Is bound to thread.
161f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  DCHECK(context_thread_checker_.CalledOnValidThread());
162f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
163f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  return context3d_->isContextLost();
164f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}
165f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
1662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void ContextProviderInProcess::VerifyContexts() {
1672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DCHECK(lost_context_callback_proxy_);  // Is bound to thread.
168fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  DCHECK(context_thread_checker_.CalledOnValidThread());
1692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  if (context3d_->isContextLost())
171fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch    OnLostContext();
1722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1745c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liuvoid ContextProviderInProcess::DeleteCachedResources() {
1755c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  DCHECK(context_thread_checker_.CalledOnValidThread());
1765c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
1775c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu  if (gr_context_)
1785c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu    gr_context_->FreeGpuResources();
1795c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu}
1805c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu
181fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdochvoid ContextProviderInProcess::OnLostContext() {
182fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  DCHECK(context_thread_checker_.CalledOnValidThread());
1832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  {
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    base::AutoLock lock(destroyed_lock_);
1852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if (destroyed_)
1862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      return;
1872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    destroyed_ = true;
1882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
189fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  if (!lost_context_callback_.is_null())
190fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch    base::ResetAndReturn(&lost_context_callback_).Run();
191c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  if (gr_context_)
192c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch    gr_context_->OnLostContext();
1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)bool ContextProviderInProcess::DestroyedOnMainThread() {
196fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  DCHECK(main_thread_checker_.CalledOnValidThread());
197fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch
1982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  base::AutoLock lock(destroyed_lock_);
1992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  return destroyed_;
2002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
202fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdochvoid ContextProviderInProcess::SetLostContextCallback(
203fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch    const LostContextCallback& lost_context_callback) {
204fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  DCHECK(context_thread_checker_.CalledOnValidThread());
2053551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)  DCHECK(lost_context_callback_.is_null() ||
2063551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)         lost_context_callback.is_null());
207fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch  lost_context_callback_ = lost_context_callback;
208fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch}
209fb250657ef40d7500f20882d5c9909c1013367d3Ben Murdoch
2103551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)void ContextProviderInProcess::SetMemoryPolicyChangedCallback(
2113551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)    const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
2121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // There's no memory manager for the in-process implementation.
2132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
2142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace gpu
2162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace webkit
217