Prefer ScopedNestableTaskAllower over manual save/restore

Cleanup.  Changes various calls sites to use the
ScopedNestableTaskAllower class to save/restore nestable task
state.

BUG=None
TEST=Existing unit tests
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]

Review URL: https://chromiumcodereview.appspot.com/9384024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121914 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc
index 74d9744..be8315cd 100644
--- a/ipc/ipc_sync_channel.cc
+++ b/ipc/ipc_sync_channel.cc
@@ -506,11 +506,11 @@
   sync_msg_queue->set_top_send_done_watcher(&send_done_watcher);
 
   send_done_watcher.StartWatching(context->GetSendDoneEvent(), context);
-  bool old_state = MessageLoop::current()->NestableTasksAllowed();
 
-  MessageLoop::current()->SetNestableTasksAllowed(true);
-  MessageLoop::current()->Run();
-  MessageLoop::current()->SetNestableTasksAllowed(old_state);
+  {
+    MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
+    MessageLoop::current()->Run();
+  }
 
   sync_msg_queue->set_top_send_done_watcher(old_send_done_event_watcher);
   if (old_send_done_event_watcher && old_event) {