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); |
}; |