summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/message_loop.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/base/message_loop.h b/base/message_loop.h
index e45adde..fe28179 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -223,6 +223,23 @@ class MessageLoop : public base::MessagePump::Delegate {
void SetNestableTasksAllowed(bool allowed);
bool NestableTasksAllowed() const;
+ // Enables nestable tasks on |loop| while in scope.
+ class ScopedNestableTaskAllower {
+ public:
+ explicit ScopedNestableTaskAllower(MessageLoop* loop)
+ : loop_(loop),
+ old_state_(loop_->NestableTasksAllowed()) {
+ loop_->SetNestableTasksAllowed(true);
+ }
+ ~ScopedNestableTaskAllower() {
+ loop_->SetNestableTasksAllowed(old_state_);
+ }
+
+ private:
+ MessageLoop* loop_;
+ bool old_state_;
+ };
+
// Enables or disables the restoration during an exception of the unhandled
// exception filter that was active when Run() was called. This can happen
// if some third party code call SetUnhandledExceptionFilter() and never