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

Side by Side Diff: cc/single_thread_proxy.h

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments 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
« no previous file with comments | « cc/scrollbar_layer_unittest.cc ('k') | cc/single_thread_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CC_SINGLE_THREAD_PROXY_H_ 5 #ifndef CC_SINGLE_THREAD_PROXY_H_
6 #define CC_SINGLE_THREAD_PROXY_H_ 6 #define CC_SINGLE_THREAD_PROXY_H_
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 bool m_nextFrameIsNewlyCommittedFrame; 84 bool m_nextFrameIsNewlyCommittedFrame;
85 85
86 base::TimeDelta m_totalCommitTime; 86 base::TimeDelta m_totalCommitTime;
87 size_t m_totalCommitCount; 87 size_t m_totalCommitCount;
88 }; 88 };
89 89
90 // For use in the single-threaded case. In debug builds, it pretends that the 90 // For use in the single-threaded case. In debug builds, it pretends that the
91 // code is running on the impl thread to satisfy assertion checks. 91 // code is running on the impl thread to satisfy assertion checks.
92 class DebugScopedSetImplThread { 92 class DebugScopedSetImplThread {
93 public: 93 public:
94 DebugScopedSetImplThread() 94 explicit DebugScopedSetImplThread(Proxy* proxy)
95 : m_proxy(proxy)
95 { 96 {
96 #ifndef NDEBUG 97 #ifndef NDEBUG
97 Proxy::setCurrentThreadIsImplThread(true); 98 m_previousValue = m_proxy->m_implThreadIsOverridden;
99 m_proxy->setCurrentThreadIsImplThread(true);
98 #endif 100 #endif
99 } 101 }
100 ~DebugScopedSetImplThread() 102 ~DebugScopedSetImplThread()
101 { 103 {
102 #ifndef NDEBUG 104 #ifndef NDEBUG
103 Proxy::setCurrentThreadIsImplThread(false); 105 m_proxy->setCurrentThreadIsImplThread(m_previousValue);
104 #endif 106 #endif
105 } 107 }
108 private:
109 bool m_previousValue;
110 Proxy* m_proxy;
106 }; 111 };
107 112
108 // For use in the single-threaded case. In debug builds, it pretends that the 113 // For use in the single-threaded case. In debug builds, it pretends that the
109 // code is running on the main thread to satisfy assertion checks. 114 // code is running on the main thread to satisfy assertion checks.
110 class DebugScopedSetMainThread { 115 class DebugScopedSetMainThread {
111 public: 116 public:
112 DebugScopedSetMainThread() 117 explicit DebugScopedSetMainThread(Proxy* proxy)
118 : m_proxy(proxy)
113 { 119 {
114 #ifndef NDEBUG 120 #ifndef NDEBUG
115 Proxy::setCurrentThreadIsImplThread(false); 121 m_previousValue = m_proxy->m_implThreadIsOverridden;
122 m_proxy->setCurrentThreadIsImplThread(false);
116 #endif 123 #endif
117 } 124 }
118 ~DebugScopedSetMainThread() 125 ~DebugScopedSetMainThread()
119 { 126 {
120 #ifndef NDEBUG 127 #ifndef NDEBUG
121 Proxy::setCurrentThreadIsImplThread(true); 128 m_proxy->setCurrentThreadIsImplThread(m_previousValue);
122 #endif 129 #endif
123 } 130 }
131 private:
132 bool m_previousValue;
133 Proxy* m_proxy;
124 }; 134 };
125 135
126 // For use in the single-threaded case. In debug builds, it pretends that the 136 // For use in the single-threaded case. In debug builds, it pretends that the
127 // code is running on the impl thread and that the main thread is blocked to 137 // code is running on the impl thread and that the main thread is blocked to
128 // satisfy assertion checks 138 // satisfy assertion checks
129 class DebugScopedSetImplThreadAndMainThreadBlocked { 139 class DebugScopedSetImplThreadAndMainThreadBlocked {
140 public:
141 explicit DebugScopedSetImplThreadAndMainThreadBlocked(Proxy* proxy)
142 : m_implThread(proxy)
143 , m_mainThreadBlocked(proxy)
144 {
145 }
130 private: 146 private:
131 DebugScopedSetImplThread m_implThread; 147 DebugScopedSetImplThread m_implThread;
132 DebugScopedSetMainThreadBlocked m_mainThreadBlocked; 148 DebugScopedSetMainThreadBlocked m_mainThreadBlocked;
133 }; 149 };
134 150
135 } // namespace cc 151 } // namespace cc
136 152
137 #endif // CC_SINGLE_THREAD_PROXY_H_ 153 #endif // CC_SINGLE_THREAD_PROXY_H_
OLDNEW
« no previous file with comments | « cc/scrollbar_layer_unittest.cc ('k') | cc/single_thread_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698