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

Side by Side Diff: base/threading/thread_checker.cc

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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 | « base/threading/thread_checker.h ('k') | base/threading/thread_checker_unittest.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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/thread_checker.h" 5 #include "base/threading/thread_checker.h"
6 6
7 // This code is only done in debug builds. 7 // This code is only done in debug builds.
8 #ifndef NDEBUG 8 #ifndef NDEBUG
9 9
10 namespace base {
11
10 ThreadChecker::ThreadChecker() : valid_thread_id_(kInvalidThreadId) { 12 ThreadChecker::ThreadChecker() : valid_thread_id_(kInvalidThreadId) {
11 EnsureThreadIdAssigned(); 13 EnsureThreadIdAssigned();
12 } 14 }
13 15
14 ThreadChecker::~ThreadChecker() {} 16 ThreadChecker::~ThreadChecker() {}
15 17
16 bool ThreadChecker::CalledOnValidThread() const { 18 bool ThreadChecker::CalledOnValidThread() const {
17 EnsureThreadIdAssigned(); 19 EnsureThreadIdAssigned();
18 AutoLock auto_lock(lock_); 20 AutoLock auto_lock(lock_);
19 return valid_thread_id_ == PlatformThread::CurrentId(); 21 return valid_thread_id_ == PlatformThread::CurrentId();
20 } 22 }
21 23
22 void ThreadChecker::DetachFromThread() { 24 void ThreadChecker::DetachFromThread() {
23 AutoLock auto_lock(lock_); 25 AutoLock auto_lock(lock_);
24 valid_thread_id_ = kInvalidThreadId; 26 valid_thread_id_ = kInvalidThreadId;
25 } 27 }
26 28
27 void ThreadChecker::EnsureThreadIdAssigned() const { 29 void ThreadChecker::EnsureThreadIdAssigned() const {
28 AutoLock auto_lock(lock_); 30 AutoLock auto_lock(lock_);
29 if (valid_thread_id_ != kInvalidThreadId) 31 if (valid_thread_id_ != kInvalidThreadId)
30 return; 32 return;
31 valid_thread_id_ = PlatformThread::CurrentId(); 33 valid_thread_id_ = PlatformThread::CurrentId();
32 } 34 }
33 35
36 } // namespace base
37
34 #endif // NDEBUG 38 #endif // NDEBUG
OLDNEW
« no previous file with comments | « base/threading/thread_checker.h ('k') | base/threading/thread_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698