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

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

Issue 6599004: Modify ThreadChecker and NonThreadSafe so that their functionality is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update copyright year for new/moved files Created 9 years, 9 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_impl.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) 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 "base/threading/thread_checker.h" 5 #include "base/threading/thread_checker_impl.h"
6
7 // This code is only done in debug builds.
8 #ifndef NDEBUG
9 6
10 namespace base { 7 namespace base {
11 8
12 ThreadChecker::ThreadChecker() : valid_thread_id_(kInvalidThreadId) { 9 ThreadCheckerImpl::ThreadCheckerImpl()
10 : valid_thread_id_(kInvalidThreadId) {
13 EnsureThreadIdAssigned(); 11 EnsureThreadIdAssigned();
14 } 12 }
15 13
16 ThreadChecker::~ThreadChecker() {} 14 ThreadCheckerImpl::~ThreadCheckerImpl() {}
17 15
18 bool ThreadChecker::CalledOnValidThread() const { 16 bool ThreadCheckerImpl::CalledOnValidThread() const {
19 EnsureThreadIdAssigned(); 17 EnsureThreadIdAssigned();
20 AutoLock auto_lock(lock_); 18 AutoLock auto_lock(lock_);
21 return valid_thread_id_ == PlatformThread::CurrentId(); 19 return valid_thread_id_ == PlatformThread::CurrentId();
22 } 20 }
23 21
24 void ThreadChecker::DetachFromThread() { 22 void ThreadCheckerImpl::DetachFromThread() {
25 AutoLock auto_lock(lock_); 23 AutoLock auto_lock(lock_);
26 valid_thread_id_ = kInvalidThreadId; 24 valid_thread_id_ = kInvalidThreadId;
27 } 25 }
28 26
29 void ThreadChecker::EnsureThreadIdAssigned() const { 27 void ThreadCheckerImpl::EnsureThreadIdAssigned() const {
30 AutoLock auto_lock(lock_); 28 AutoLock auto_lock(lock_);
31 if (valid_thread_id_ != kInvalidThreadId) 29 if (valid_thread_id_ != kInvalidThreadId)
32 return; 30 return;
33 valid_thread_id_ = PlatformThread::CurrentId(); 31 valid_thread_id_ = PlatformThread::CurrentId();
34 } 32 }
35 33
36 } // namespace base 34 } // namespace base
37
38 #endif // NDEBUG
OLDNEW
« no previous file with comments | « base/threading/thread_checker_impl.h ('k') | base/threading/thread_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698