OLD | NEW |
| (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 | |
OLD | NEW |