| Index: cc/test/test_context_provider.cc
|
| diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc
|
| index ca7714d30cf9f4ca1b0eaaaeb7c117f7ddd180de..e690797b44039aa9587260d5083b902c1019d676 100644
|
| --- a/cc/test/test_context_provider.cc
|
| +++ b/cc/test/test_context_provider.cc
|
| @@ -19,7 +19,20 @@ namespace cc {
|
|
|
| // static
|
| scoped_refptr<TestContextProvider> TestContextProvider::Create() {
|
| - return Create(TestWebGraphicsContext3D::Create().Pass());
|
| + return Create(TestWebGraphicsContext3D::Create());
|
| +}
|
| +
|
| +// static
|
| +scoped_refptr<TestContextProvider> TestContextProvider::CreateWorker() {
|
| + scoped_refptr<TestContextProvider> worker_context_provider =
|
| + Create(TestWebGraphicsContext3D::Create());
|
| + if (!worker_context_provider)
|
| + return nullptr;
|
| + // Worker contexts are bound to the thread they are created on.
|
| + if (!worker_context_provider->BindToCurrentThread())
|
| + return nullptr;
|
| + worker_context_provider->SetupLock();
|
| + return worker_context_provider;
|
| }
|
|
|
| // static
|
| @@ -35,7 +48,7 @@ TestContextProvider::TestContextProvider(
|
| : context3d_(context.Pass()),
|
| context_gl_(new TestGLES2Interface(context3d_.get())),
|
| bound_(false),
|
| - destroyed_(false),
|
| + lost_(false),
|
| weak_ptr_factory_(this) {
|
| DCHECK(main_thread_checker_.CalledOnValidThread());
|
| DCHECK(context3d_);
|
| @@ -44,8 +57,6 @@ TestContextProvider::TestContextProvider(
|
| }
|
|
|
| TestContextProvider::~TestContextProvider() {
|
| - DCHECK(main_thread_checker_.CalledOnValidThread() ||
|
| - context_thread_checker_.CalledOnValidThread());
|
| }
|
|
|
| bool TestContextProvider::BindToCurrentThread() {
|
| @@ -56,8 +67,8 @@ bool TestContextProvider::BindToCurrentThread() {
|
| return true;
|
|
|
| if (context_gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
|
| - base::AutoLock lock(destroyed_lock_);
|
| - destroyed_ = true;
|
| + base::AutoLock lock(lost_lock_);
|
| + lost_ = true;
|
| return false;
|
| }
|
| bound_ = true;
|
| @@ -132,28 +143,28 @@ void TestContextProvider::VerifyContexts() {
|
| DCHECK(context_thread_checker_.CalledOnValidThread());
|
|
|
| if (ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
|
| - base::AutoLock lock(destroyed_lock_);
|
| - destroyed_ = true;
|
| + base::AutoLock lock(lost_lock_);
|
| + lost_ = true;
|
| }
|
| }
|
|
|
| void TestContextProvider::DeleteCachedResources() {
|
| }
|
|
|
| -bool TestContextProvider::DestroyedOnMainThread() {
|
| +bool TestContextProvider::HasBeenLostOnMainThread() {
|
| DCHECK(main_thread_checker_.CalledOnValidThread());
|
|
|
| - base::AutoLock lock(destroyed_lock_);
|
| - return destroyed_;
|
| + base::AutoLock lock(lost_lock_);
|
| + return lost_;
|
| }
|
|
|
| void TestContextProvider::OnLostContext() {
|
| DCHECK(context_thread_checker_.CalledOnValidThread());
|
| {
|
| - base::AutoLock lock(destroyed_lock_);
|
| - if (destroyed_)
|
| + base::AutoLock lock(lost_lock_);
|
| + if (lost_)
|
| return;
|
| - destroyed_ = true;
|
| + lost_ = true;
|
| }
|
| if (!lost_context_callback_.is_null())
|
| base::ResetAndReturn(&lost_context_callback_).Run();
|
| @@ -198,4 +209,9 @@ void TestContextProvider::SetMaxTransferBufferUsageBytes(
|
| context3d_->SetMaxTransferBufferUsageBytes(max_transfer_buffer_usage_bytes);
|
| }
|
|
|
| +bool TestContextProvider::HasBeenDestroyed() {
|
| + DCHECK(context_thread_checker_.CalledOnValidThread());
|
| + return false;
|
| +}
|
| +
|
| } // namespace cc
|
|
|