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

Side by Side Diff: cc/proxy.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to 165064 Created 8 years, 1 month 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 2011 The Chromium Authors. All rights reserved. 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 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/proxy.h" 7 #include "cc/proxy.h"
8 8
9 #include "cc/thread.h" 9 #include "cc/thread.h"
10 #include "cc/thread_impl.h"
10 11
11 namespace cc { 12 namespace cc {
12 13
13 namespace { 14 void Proxy::setMainThread(Thread* thread)
14 #ifndef NDEBUG 15 {
15 bool implThreadIsOverridden = false; 16 m_mainThread.reset(thread);
16 bool s_isMainThreadBlocked = false;
17 #endif
18 Thread* s_mainThread = 0;
19 Thread* s_implThread = 0;
20 } 17 }
21 18
22 void Proxy::setMainThread(Thread* thread) 19 Thread* Proxy::mainThread() const
23 { 20 {
24 s_mainThread = thread; 21 return m_mainThread.get();
25 } 22 }
26 23
27 Thread* Proxy::mainThread() 24 bool Proxy::hasImplThread() const
28 { 25 {
29 return s_mainThread; 26 return !!m_implThread.get();
jamesr 2012/10/31 04:42:13 return m_implThread; will do the right thing
30 }
31
32 bool Proxy::hasImplThread()
33 {
34 return s_implThread;
35 } 27 }
36 28
37 void Proxy::setImplThread(Thread* thread) 29 void Proxy::setImplThread(Thread* thread)
38 { 30 {
39 s_implThread = thread; 31 m_implThread.reset(thread);
40 } 32 }
41 33
42 Thread* Proxy::implThread() 34 Thread* Proxy::implThread() const
43 { 35 {
44 return s_implThread; 36 return m_implThread.get();
45 } 37 }
46 38
47 Thread* Proxy::currentThread() 39 Thread* Proxy::currentThread() const
48 { 40 {
49 if (s_mainThread && s_mainThread->belongsToCurrentThread()) 41 if (mainThread() && mainThread()->belongsToCurrentThread())
50 return s_mainThread; 42 return mainThread();
51 if (s_implThread && s_implThread->belongsToCurrentThread()) 43 if (implThread() && implThread()->belongsToCurrentThread())
52 return s_implThread; 44 return implThread();
53 return 0; 45 return 0;
54 } 46 }
55 47
56 bool Proxy::isMainThread() 48 bool Proxy::isMainThread() const
57 { 49 {
58 #ifndef NDEBUG 50 #ifndef NDEBUG
59 DCHECK(s_mainThread); 51 DCHECK(mainThread());
60 if (implThreadIsOverridden) 52 if (m_implThreadIsOverridden)
61 return false; 53 return false;
62 return s_mainThread->belongsToCurrentThread(); 54 return mainThread()->belongsToCurrentThread();
63 #else 55 #else
64 return true; 56 return true;
65 #endif 57 #endif
66 } 58 }
67 59
68 bool Proxy::isImplThread() 60 bool Proxy::isImplThread() const
69 { 61 {
70 #ifndef NDEBUG 62 #ifndef NDEBUG
71 if (implThreadIsOverridden) 63 if (m_implThreadIsOverridden)
72 return true; 64 return true;
73 return s_implThread && s_implThread->belongsToCurrentThread(); 65 return implThread() && implThread()->belongsToCurrentThread();
74 #else 66 #else
75 return true; 67 return true;
76 #endif 68 #endif
77 } 69 }
78 70
79 #ifndef NDEBUG 71 #ifndef NDEBUG
80 void Proxy::setCurrentThreadIsImplThread(bool isImplThread) 72 void Proxy::setCurrentThreadIsImplThread(bool isImplThread)
81 { 73 {
82 implThreadIsOverridden = isImplThread; 74 m_implThreadIsOverridden = isImplThread;
83 } 75 }
84 #endif 76 #endif
85 77
86 bool Proxy::isMainThreadBlocked() 78 bool Proxy::isMainThreadBlocked() const
87 { 79 {
88 #ifndef NDEBUG 80 #ifndef NDEBUG
89 return s_isMainThreadBlocked; 81 return m_isMainThreadBlocked;
90 #else 82 #else
91 return true; 83 return true;
92 #endif 84 #endif
93 } 85 }
94 86
95 #ifndef NDEBUG 87 #ifndef NDEBUG
96 void Proxy::setMainThreadBlocked(bool isMainThreadBlocked) 88 void Proxy::setMainThreadBlocked(bool isMainThreadBlocked)
97 { 89 {
98 s_isMainThreadBlocked = isMainThreadBlocked; 90 m_isMainThreadBlocked = isMainThreadBlocked;
99 } 91 }
100 #endif 92 #endif
101 93
102 Proxy::Proxy() 94 Proxy::Proxy(Thread* implThread)
95 : m_mainThread(ThreadImpl::createForCurrentThread())
96 , m_implThread(implThread)
97 #ifndef NDEBUG
98 , m_implThreadIsOverridden(false)
99 , m_isMainThreadBlocked(false)
100 #endif
103 { 101 {
104 DCHECK(isMainThread());
105 } 102 }
106 103
107 Proxy::~Proxy() 104 Proxy::~Proxy()
108 { 105 {
109 DCHECK(isMainThread()); 106 DCHECK(isMainThread());
110 } 107 }
111 108
112 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698