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

Side by Side Diff: base/thread_checker.cc

Issue 3743001: FBTF: Fix more ctor/dtors found by clang plugin. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Rebase to pick up mac fix on ToT Created 10 years, 2 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/thread_checker.h ('k') | chrome/browser/extensions/default_apps.h » ('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/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 ThreadChecker::ThreadChecker() { 10 ThreadChecker::ThreadChecker() {
11 EnsureThreadIdAssigned(); 11 EnsureThreadIdAssigned();
12 } 12 }
13 13
14 ThreadChecker::~ThreadChecker() {}
15
14 bool ThreadChecker::CalledOnValidThread() const { 16 bool ThreadChecker::CalledOnValidThread() const {
15 EnsureThreadIdAssigned(); 17 EnsureThreadIdAssigned();
16 return *valid_thread_id_ == PlatformThread::CurrentId(); 18 return *valid_thread_id_ == PlatformThread::CurrentId();
17 } 19 }
18 20
19 void ThreadChecker::DetachFromThread() { 21 void ThreadChecker::DetachFromThread() {
20 valid_thread_id_.reset(); 22 valid_thread_id_.reset();
21 } 23 }
22 24
23 void ThreadChecker::EnsureThreadIdAssigned() const { 25 void ThreadChecker::EnsureThreadIdAssigned() const {
24 if (valid_thread_id_.get()) 26 if (valid_thread_id_.get())
25 return; 27 return;
26 valid_thread_id_.reset(new PlatformThreadId(PlatformThread::CurrentId())); 28 valid_thread_id_.reset(new PlatformThreadId(PlatformThread::CurrentId()));
27 } 29 }
28 30
29 #endif // NDEBUG 31 #endif // NDEBUG
OLDNEW
« no previous file with comments | « base/thread_checker.h ('k') | chrome/browser/extensions/default_apps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698