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

Side by Side Diff: base/thread_checker.h

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/process_util.cc ('k') | base/thread_checker.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 #ifndef BASE_THREAD_CHECKER_H_ 5 #ifndef BASE_THREAD_CHECKER_H_
6 #define BASE_THREAD_CHECKER_H_ 6 #define BASE_THREAD_CHECKER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/platform_thread.h" 9 #include "base/platform_thread.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 17 matching lines...) Expand all
28 // ... (do stuff) ... 28 // ... (do stuff) ...
29 // } 29 // }
30 // } 30 // }
31 // 31 //
32 // In Release mode, CalledOnValidThread will always return true. 32 // In Release mode, CalledOnValidThread will always return true.
33 // 33 //
34 #ifndef NDEBUG 34 #ifndef NDEBUG
35 class ThreadChecker { 35 class ThreadChecker {
36 public: 36 public:
37 ThreadChecker(); 37 ThreadChecker();
38 ~ThreadChecker();
38 39
39 bool CalledOnValidThread() const; 40 bool CalledOnValidThread() const;
40 41
41 // Changes the thread that is checked for in CalledOnValidThread. This may 42 // Changes the thread that is checked for in CalledOnValidThread. This may
42 // be useful when an object may be created on one thread and then used 43 // be useful when an object may be created on one thread and then used
43 // exclusively on another thread. 44 // exclusively on another thread.
44 void DetachFromThread(); 45 void DetachFromThread();
45 46
46 private: 47 private:
47 void EnsureThreadIdAssigned() const; 48 void EnsureThreadIdAssigned() const;
48 49
49 // This is mutable so that CalledOnValidThread can set it. 50 // This is mutable so that CalledOnValidThread can set it.
50 mutable scoped_ptr<PlatformThreadId> valid_thread_id_; 51 mutable scoped_ptr<PlatformThreadId> valid_thread_id_;
51 }; 52 };
52 #else 53 #else
53 // Do nothing in release mode. 54 // Do nothing in release mode.
54 class ThreadChecker { 55 class ThreadChecker {
55 public: 56 public:
56 bool CalledOnValidThread() const { 57 bool CalledOnValidThread() const {
57 return true; 58 return true;
58 } 59 }
59 60
60 void DetachFromThread() {} 61 void DetachFromThread() {}
61 }; 62 };
62 #endif // NDEBUG 63 #endif // NDEBUG
63 64
64 #endif // BASE_THREAD_CHECKER_H_ 65 #endif // BASE_THREAD_CHECKER_H_
OLDNEW
« no previous file with comments | « base/process_util.cc ('k') | base/thread_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698