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

Side by Side Diff: cc/scoped_thread_proxy.cc

Issue 11571068: Use WeakPtr for posting cc tasks to main thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/scoped_thread_proxy.h ('k') | cc/test/layer_tree_test_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/scoped_thread_proxy.h"
6
7 #include "base/bind.h"
8
9 namespace cc {
10
11 ScopedThreadProxy::ScopedThreadProxy(cc::Thread* targetThread)
12 : m_targetThread(targetThread)
13 , m_shutdown(false)
14 {
15 }
16
17 ScopedThreadProxy::~ScopedThreadProxy()
18 {
19 }
20
21 void ScopedThreadProxy::postTask(const tracked_objects::Location& location, base ::Closure cb)
22 {
23 m_targetThread->postTask(base::Bind(&ScopedThreadProxy::runTaskIfNotShutdown , this, cb));
24 }
25
26 void ScopedThreadProxy::shutdown()
27 {
28 DCHECK(m_targetThread->belongsToCurrentThread());
29 DCHECK(!m_shutdown);
30 m_shutdown = true;
31 }
32
33 void ScopedThreadProxy::runTaskIfNotShutdown(base::Closure cb)
34 {
35 // If our shutdown flag is set, it's possible that m_targetThread has alread y been destroyed so don't
36 // touch it.
37 if (m_shutdown) {
38 return;
39 }
40 DCHECK(m_targetThread->belongsToCurrentThread());
41 cb.Run();
42 }
43
44 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scoped_thread_proxy.h ('k') | cc/test/layer_tree_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698