OLD | NEW |
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 #include "base/threading/thread_restrictions.h" | 5 #include "base/threading/thread_restrictions.h" |
6 | 6 |
7 #if ENABLE_THREAD_RESTRICTIONS | 7 #if ENABLE_THREAD_RESTRICTIONS |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // static | 28 // static |
29 bool ThreadRestrictions::SetIOAllowed(bool allowed) { | 29 bool ThreadRestrictions::SetIOAllowed(bool allowed) { |
30 bool previous_disallowed = g_io_disallowed.Get().Get(); | 30 bool previous_disallowed = g_io_disallowed.Get().Get(); |
31 g_io_disallowed.Get().Set(!allowed); | 31 g_io_disallowed.Get().Set(!allowed); |
32 return !previous_disallowed; | 32 return !previous_disallowed; |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 void ThreadRestrictions::AssertIOAllowed() { | 36 void ThreadRestrictions::AssertIOAllowed() { |
37 if (g_io_disallowed.Get().Get()) { | 37 if (g_io_disallowed.Get().Get()) { |
38 LOG(FATAL) << | 38 LOG(ERROR) << |
39 "Function marked as IO-only was called from a thread that " | 39 "Function marked as IO-only was called from a thread that " |
40 "disallows IO! If this thread really should be allowed to " | 40 "disallows IO! If this thread really should be allowed to " |
41 "make IO calls, adjust the call to " | 41 "make IO calls, adjust the call to " |
42 "base::ThreadRestrictions::SetIOAllowed() in this thread's " | 42 "base::ThreadRestrictions::SetIOAllowed() in this thread's " |
43 "startup."; | 43 "startup."; |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 // static | 47 // static |
48 bool ThreadRestrictions::SetSingletonAllowed(bool allowed) { | 48 bool ThreadRestrictions::SetSingletonAllowed(bool allowed) { |
(...skipping 27 matching lines...) Expand all Loading... |
76 | 76 |
77 bool ThreadRestrictions::SetWaitAllowed(bool allowed) { | 77 bool ThreadRestrictions::SetWaitAllowed(bool allowed) { |
78 bool previous_disallowed = g_wait_disallowed.Get().Get(); | 78 bool previous_disallowed = g_wait_disallowed.Get().Get(); |
79 g_wait_disallowed.Get().Set(!allowed); | 79 g_wait_disallowed.Get().Set(!allowed); |
80 return !previous_disallowed; | 80 return !previous_disallowed; |
81 } | 81 } |
82 | 82 |
83 } // namespace base | 83 } // namespace base |
84 | 84 |
85 #endif // ENABLE_THREAD_RESTRICTIONS | 85 #endif // ENABLE_THREAD_RESTRICTIONS |
OLD | NEW |