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

Side by Side Diff: base/threading/non_thread_safe.h

Issue 2163023002: Unify usage of logging/assert macros in base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix base/android/build_info.cc compile Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_THREADING_NON_THREAD_SAFE_H_ 5 #ifndef BASE_THREADING_NON_THREAD_SAFE_H_
6 #define BASE_THREADING_NON_THREAD_SAFE_H_ 6 #define BASE_THREADING_NON_THREAD_SAFE_H_
7 7
8 // Classes deriving from NonThreadSafe may need to suppress MSVC warning 4275: 8 // Classes deriving from NonThreadSafe may need to suppress MSVC warning 4275:
9 // non dll-interface class 'Bar' used as base for dll-interface class 'Foo'. 9 // non dll-interface class 'Bar' used as base for dll-interface class 'Foo'.
10 // There is a specific macro to do it: NON_EXPORTED_BASE(), defined in 10 // There is a specific macro to do it: NON_EXPORTED_BASE(), defined in
11 // compiler_specific.h 11 // compiler_specific.h
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 13 #include "base/logging.h"
14 // See comment at top of thread_checker.h
15 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
16 #define ENABLE_NON_THREAD_SAFE 1
17 #else
18 #define ENABLE_NON_THREAD_SAFE 0
19 #endif
20
21 #include "base/threading/non_thread_safe_impl.h" 14 #include "base/threading/non_thread_safe_impl.h"
22 15
23 namespace base { 16 namespace base {
24 17
25 // Do nothing implementation of NonThreadSafe, for release mode. 18 // Do nothing implementation of NonThreadSafe, for release mode.
26 // 19 //
27 // Note: You should almost always use the NonThreadSafe class to get 20 // Note: You should almost always use the NonThreadSafe class to get
28 // the right version of the class for your build configuration. 21 // the right version of the class for your build configuration.
29 class NonThreadSafeDoNothing { 22 class NonThreadSafeDoNothing {
30 public: 23 public:
(...skipping 20 matching lines...) Expand all
51 // DCHECK(CalledOnValidThread()); 44 // DCHECK(CalledOnValidThread());
52 // ... (do stuff) ... 45 // ... (do stuff) ...
53 // } 46 // }
54 // } 47 // }
55 // 48 //
56 // Note that base::ThreadChecker offers identical functionality to 49 // Note that base::ThreadChecker offers identical functionality to
57 // NonThreadSafe, but does not require inheritance. In general, it is preferable 50 // NonThreadSafe, but does not require inheritance. In general, it is preferable
58 // to have a base::ThreadChecker as a member, rather than inherit from 51 // to have a base::ThreadChecker as a member, rather than inherit from
59 // NonThreadSafe. For more details about when to choose one over the other, see 52 // NonThreadSafe. For more details about when to choose one over the other, see
60 // the documentation for base::ThreadChecker. 53 // the documentation for base::ThreadChecker.
61 #if ENABLE_NON_THREAD_SAFE 54 #if DCHECK_IS_ON()
62 typedef NonThreadSafeImpl NonThreadSafe; 55 typedef NonThreadSafeImpl NonThreadSafe;
63 #else 56 #else
64 typedef NonThreadSafeDoNothing NonThreadSafe; 57 typedef NonThreadSafeDoNothing NonThreadSafe;
65 #endif // ENABLE_NON_THREAD_SAFE 58 #endif // DCHECK_IS_ON()
66
67 #undef ENABLE_NON_THREAD_SAFE
68 59
69 } // namespace base 60 } // namespace base
70 61
71 #endif // BASE_THREADING_NON_THREAD_SAFE_H_ 62 #endif // BASE_THREADING_NON_THREAD_SAFE_H_
OLDNEW
« no previous file with comments | « base/task_scheduler/task_scheduler_impl_unittest.cc ('k') | base/threading/non_thread_safe_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698