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

Side by Side Diff: base/thread_restrictions.cc

Issue 3872002: Thread IO safety: file_util annotated, IO thread blocked from doing IO (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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 void ThreadRestrictions::SetIOAllowed(bool allowed) { 24 bool ThreadRestrictions::SetIOAllowed(bool allowed) {
25 bool previous_allowed = g_io_disallowed.Get().Get();
25 g_io_disallowed.Get().Set(!allowed); 26 g_io_disallowed.Get().Set(!allowed);
27 return !previous_allowed;
26 } 28 }
27 29
28 // static 30 // static
29 void ThreadRestrictions::AssertIOAllowed() { 31 void ThreadRestrictions::AssertIOAllowed() {
30 if (g_io_disallowed.Get().Get()) { 32 if (g_io_disallowed.Get().Get()) {
31 LOG(FATAL) << 33 LOG(FATAL) <<
32 "Function marked as IO-only was called from a thread that " 34 "Function marked as IO-only was called from a thread that "
33 "disallows IO! If this thread really should be allowed to " 35 "disallows IO! If this thread really should be allowed to "
34 "make IO calls, adjust the call to " 36 "make IO calls, adjust the call to "
35 "base::ThreadRestrictions::SetIOAllowed() in this thread's " 37 "base::ThreadRestrictions::SetIOAllowed() in this thread's "
36 "startup."; 38 "startup.";
37 } 39 }
38 } 40 }
39 41
40 } // namespace base 42 } // namespace base
41 43
42 #endif // NDEBUG 44 #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