| OLD | NEW |
| 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/synchronization/lock.h" |
| 6 #include "base/threading/platform_thread.h" |
| 5 #include "base/threading/thread_checker.h" | 7 #include "base/threading/thread_checker.h" |
| 6 | 8 |
| 7 // This code is only done in debug builds. | 9 // This code is only done in debug builds. |
| 8 #ifndef NDEBUG | 10 #ifndef NDEBUG |
| 9 | 11 |
| 10 namespace base { | 12 namespace base { |
| 11 | 13 |
| 12 ThreadChecker::ThreadChecker() : valid_thread_id_(kInvalidThreadId) { | 14 ThreadChecker::ThreadChecker() : valid_thread_id_(kInvalidThreadId) { |
| 13 EnsureThreadIdAssigned(); | 15 EnsureThreadIdAssigned(); |
| 14 } | 16 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 29 void ThreadChecker::EnsureThreadIdAssigned() const { | 31 void ThreadChecker::EnsureThreadIdAssigned() const { |
| 30 AutoLock auto_lock(lock_); | 32 AutoLock auto_lock(lock_); |
| 31 if (valid_thread_id_ != kInvalidThreadId) | 33 if (valid_thread_id_ != kInvalidThreadId) |
| 32 return; | 34 return; |
| 33 valid_thread_id_ = PlatformThread::CurrentId(); | 35 valid_thread_id_ = PlatformThread::CurrentId(); |
| 34 } | 36 } |
| 35 | 37 |
| 36 } // namespace base | 38 } // namespace base |
| 37 | 39 |
| 38 #endif // NDEBUG | 40 #endif // NDEBUG |
| OLD | NEW |