Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: content/browser/android/in_process/context_provider_in_process.cc

Issue 1317743002: cc: Implement shared worker contexts. (v1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tear down Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/android/in_process/context_provider_in_process.h" 5 #include "content/browser/android/in_process/context_provider_in_process.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "cc/output/managed_memory_policy.h" 10 #include "cc/output/managed_memory_policy.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, 42 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
43 const std::string& debug_name) { 43 const std::string& debug_name) {
44 if (!context3d) 44 if (!context3d)
45 return NULL; 45 return NULL;
46 return new ContextProviderInProcess(context3d.Pass(), debug_name); 46 return new ContextProviderInProcess(context3d.Pass(), debug_name);
47 } 47 }
48 48
49 ContextProviderInProcess::ContextProviderInProcess( 49 ContextProviderInProcess::ContextProviderInProcess(
50 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d, 50 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d,
51 const std::string& debug_name) 51 const std::string& debug_name)
52 : context3d_(context3d.Pass()), 52 : context3d_(context3d.Pass()), lost_(false), debug_name_(debug_name) {
53 destroyed_(false),
54 debug_name_(debug_name) {
55 DCHECK(main_thread_checker_.CalledOnValidThread()); 53 DCHECK(main_thread_checker_.CalledOnValidThread());
56 DCHECK(context3d_); 54 DCHECK(context3d_);
57 context_thread_checker_.DetachFromThread(); 55 context_thread_checker_.DetachFromThread();
58 } 56 }
59 57
60 ContextProviderInProcess::~ContextProviderInProcess() { 58 ContextProviderInProcess::~ContextProviderInProcess() {
61 DCHECK(main_thread_checker_.CalledOnValidThread() ||
62 context_thread_checker_.CalledOnValidThread());
63 } 59 }
64 60
65 blink::WebGraphicsContext3D* ContextProviderInProcess::WebContext3D() { 61 blink::WebGraphicsContext3D* ContextProviderInProcess::WebContext3D() {
66 DCHECK(lost_context_callback_proxy_); // Is bound to thread. 62 DCHECK(lost_context_callback_proxy_); // Is bound to thread.
67 DCHECK(context_thread_checker_.CalledOnValidThread()); 63 DCHECK(context_thread_checker_.CalledOnValidThread());
68 64
69 return context3d_.get(); 65 return context3d_.get();
70 } 66 }
71 67
72 bool ContextProviderInProcess::BindToCurrentThread() { 68 bool ContextProviderInProcess::BindToCurrentThread() {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void ContextProviderInProcess::DeleteCachedResources() { 166 void ContextProviderInProcess::DeleteCachedResources() {
171 DCHECK(context_thread_checker_.CalledOnValidThread()); 167 DCHECK(context_thread_checker_.CalledOnValidThread());
172 168
173 if (gr_context_) 169 if (gr_context_)
174 gr_context_->FreeGpuResources(); 170 gr_context_->FreeGpuResources();
175 } 171 }
176 172
177 void ContextProviderInProcess::OnLostContext() { 173 void ContextProviderInProcess::OnLostContext() {
178 DCHECK(context_thread_checker_.CalledOnValidThread()); 174 DCHECK(context_thread_checker_.CalledOnValidThread());
179 { 175 {
180 base::AutoLock lock(destroyed_lock_); 176 base::AutoLock lock(lost_lock_);
181 if (destroyed_) 177 if (lost_)
182 return; 178 return;
183 destroyed_ = true; 179 lost_ = true;
184 } 180 }
185 if (!lost_context_callback_.is_null()) 181 if (!lost_context_callback_.is_null())
186 base::ResetAndReturn(&lost_context_callback_).Run(); 182 base::ResetAndReturn(&lost_context_callback_).Run();
187 if (gr_context_) 183 if (gr_context_)
188 gr_context_->OnLostContext(); 184 gr_context_->OnLostContext();
189 } 185 }
190 186
191 bool ContextProviderInProcess::DestroyedOnMainThread() { 187 bool ContextProviderInProcess::HasBeenLostOnMainThread() {
192 DCHECK(main_thread_checker_.CalledOnValidThread()); 188 DCHECK(main_thread_checker_.CalledOnValidThread());
193 189
194 base::AutoLock lock(destroyed_lock_); 190 base::AutoLock lock(lost_lock_);
195 return destroyed_; 191 return lost_;
196 } 192 }
197 193
198 void ContextProviderInProcess::SetLostContextCallback( 194 void ContextProviderInProcess::SetLostContextCallback(
199 const LostContextCallback& lost_context_callback) { 195 const LostContextCallback& lost_context_callback) {
200 DCHECK(context_thread_checker_.CalledOnValidThread()); 196 DCHECK(context_thread_checker_.CalledOnValidThread());
201 DCHECK(lost_context_callback_.is_null() || 197 DCHECK(lost_context_callback_.is_null() ||
202 lost_context_callback.is_null()); 198 lost_context_callback.is_null());
203 lost_context_callback_ = lost_context_callback; 199 lost_context_callback_ = lost_context_callback;
204 } 200 }
205 201
206 void ContextProviderInProcess::SetMemoryPolicyChangedCallback( 202 void ContextProviderInProcess::SetMemoryPolicyChangedCallback(
207 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { 203 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
208 // There's no memory manager for the in-process implementation. 204 // There's no memory manager for the in-process implementation.
209 } 205 }
210 206
207 bool ContextProviderInProcess::HasBeenDestroyed() {
208 DCHECK(context_thread_checker_.CalledOnValidThread());
209 return false;
210 }
211
211 } // namespace content 212 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698