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

Side by Side Diff: base/threading/thread_restrictions.cc

Issue 2173903002: Update AssertSingletonAllowed log message to reflect new restrictions w.r.t. CONTINUE_ON_SHUTDOWN t… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: further improve message by suggesting a solution to detected problem Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | 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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 bool previous_disallowed = g_singleton_disallowed.Get().Get(); 49 bool previous_disallowed = g_singleton_disallowed.Get().Get();
50 g_singleton_disallowed.Get().Set(!allowed); 50 g_singleton_disallowed.Get().Set(!allowed);
51 return !previous_disallowed; 51 return !previous_disallowed;
52 } 52 }
53 53
54 // static 54 // static
55 void ThreadRestrictions::AssertSingletonAllowed() { 55 void ThreadRestrictions::AssertSingletonAllowed() {
56 if (g_singleton_disallowed.Get().Get()) { 56 if (g_singleton_disallowed.Get().Get()) {
57 LOG(FATAL) << "LazyInstance/Singleton is not allowed to be used on this " 57 LOG(FATAL) << "LazyInstance/Singleton is not allowed to be used on this "
58 << "thread. Most likely it's because this thread is not " 58 << "thread. Most likely it's because this thread is not "
59 << "joinable, so AtExitManager may have deleted the object " 59 << "joinable (or the current task is running with "
60 << "on shutdown, leading to a potential shutdown crash."; 60 << "TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN semantics), so "
61 << "AtExitManager may have deleted the object on shutdown, "
62 << "leading to a potential shutdown crash. If you need to use "
63 << "the object from this context, it'll have to be updated to "
64 << "use Leaky traits.";
61 } 65 }
62 } 66 }
63 67
64 // static 68 // static
65 void ThreadRestrictions::DisallowWaiting() { 69 void ThreadRestrictions::DisallowWaiting() {
66 g_wait_disallowed.Get().Set(true); 70 g_wait_disallowed.Get().Set(true);
67 } 71 }
68 72
69 // static 73 // static
70 void ThreadRestrictions::AssertWaitAllowed() { 74 void ThreadRestrictions::AssertWaitAllowed() {
71 if (g_wait_disallowed.Get().Get()) { 75 if (g_wait_disallowed.Get().Get()) {
72 LOG(FATAL) << "Waiting is not allowed to be used on this thread to prevent " 76 LOG(FATAL) << "Waiting is not allowed to be used on this thread to prevent "
73 << "jank and deadlock."; 77 << "jank and deadlock.";
74 } 78 }
75 } 79 }
76 80
77 bool ThreadRestrictions::SetWaitAllowed(bool allowed) { 81 bool ThreadRestrictions::SetWaitAllowed(bool allowed) {
78 bool previous_disallowed = g_wait_disallowed.Get().Get(); 82 bool previous_disallowed = g_wait_disallowed.Get().Get();
79 g_wait_disallowed.Get().Set(!allowed); 83 g_wait_disallowed.Get().Set(!allowed);
80 return !previous_disallowed; 84 return !previous_disallowed;
81 } 85 }
82 86
83 } // namespace base 87 } // namespace base
84 88
85 #endif // ENABLE_THREAD_RESTRICTIONS 89 #endif // ENABLE_THREAD_RESTRICTIONS
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698