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

Unified Diff: base/message_loop/message_loop.h

Issue 2407313002: Disallow nesting on some BrowserThreads. (Closed)
Patch Set: self-review Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/message_loop/message_loop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_loop.h
diff --git a/base/message_loop/message_loop.h b/base/message_loop/message_loop.h
index 4f3250c3b7f1b164d984dc0e4dcee28866092015..8388f59da6d0ab1ea67f99ca4a0ceb8c30e0e269 100644
--- a/base/message_loop/message_loop.h
+++ b/base/message_loop/message_loop.h
@@ -316,6 +316,10 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
// Runs the specified PendingTask.
void RunTask(const PendingTask& pending_task);
+ // Disallow nesting. After this is called, running a nested RunLoop or calling
+ // Add/RemoveNestingObserver() on this MessageLoop will crash.
+ void DisallowNesting() { allow_nesting_ = false; }
+
//----------------------------------------------------------------------------
protected:
std::unique_ptr<MessagePump> pump_;
@@ -451,6 +455,9 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate {
// MessageLoop is bound to its thread and constant forever after.
PlatformThreadId thread_id_;
+ // Whether nesting is allowed.
+ bool allow_nesting_ = true;
+
DISALLOW_COPY_AND_ASSIGN(MessageLoop);
};
« no previous file with comments | « no previous file | base/message_loop/message_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698