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

Side by Side Diff: base/thread_restrictions.cc

Issue 3983005: Revert 63600 - Thread IO safety: annotate file_util, and block IO thread from... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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_restrictions.h ('k') | chrome/browser/extensions/autoupdate_interceptor.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 #include "base/thread_restrictions.h" 5 #include "base/thread_restrictions.h"
6 6
7 // This entire file is compiled out in Release mode. 7 // This entire file is compiled out in Release mode.
8 #ifndef NDEBUG 8 #ifndef NDEBUG
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/thread_local.h" 12 #include "base/thread_local.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 namespace { 16 namespace {
17 17
18 LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> > 18 LazyInstance<ThreadLocalBoolean, LeakyLazyInstanceTraits<ThreadLocalBoolean> >
19 g_io_disallowed(LINKER_INITIALIZED); 19 g_io_disallowed(LINKER_INITIALIZED);
20 20
21 } // anonymous namespace 21 } // anonymous namespace
22 22
23 // static 23 // static
24 bool ThreadRestrictions::SetIOAllowed(bool allowed) { 24 void ThreadRestrictions::SetIOAllowed(bool allowed) {
25 bool previous_allowed = g_io_disallowed.Get().Get();
26 g_io_disallowed.Get().Set(!allowed); 25 g_io_disallowed.Get().Set(!allowed);
27 return !previous_allowed;
28 } 26 }
29 27
30 // static 28 // static
31 void ThreadRestrictions::AssertIOAllowed() { 29 void ThreadRestrictions::AssertIOAllowed() {
32 if (g_io_disallowed.Get().Get()) { 30 if (g_io_disallowed.Get().Get()) {
33 LOG(FATAL) << 31 LOG(FATAL) <<
34 "Function marked as IO-only was called from a thread that " 32 "Function marked as IO-only was called from a thread that "
35 "disallows IO! If this thread really should be allowed to " 33 "disallows IO! If this thread really should be allowed to "
36 "make IO calls, adjust the call to " 34 "make IO calls, adjust the call to "
37 "base::ThreadRestrictions::SetIOAllowed() in this thread's " 35 "base::ThreadRestrictions::SetIOAllowed() in this thread's "
38 "startup."; 36 "startup.";
39 } 37 }
40 } 38 }
41 39
42 } // namespace base 40 } // namespace base
43 41
44 #endif // NDEBUG 42 #endif // NDEBUG
OLDNEW
« no previous file with comments | « base/thread_restrictions.h ('k') | chrome/browser/extensions/autoupdate_interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698