Remove remaining calls to deprecated MessageLoop methods on Mac.

With this CL, there is no remaining call to these methods on Mac:
- MessageLoop::PostTask
- MessageLoop::PostDelayedTask
- MessageLoop::ReleaseSoon
- MessageLoop::DeleteSoon
- MessageLoop::Run
- MessageLoop::RunUntilIdle

Note that this CL also removes calls to these methods from files that
are not built on Mac.

These calls were not migrated by the clang-tidy script used previously
for various reasons (Objective-C code, templates, macros, header files,
std::unique_ptr<MessageLoop>...).

This CL was generated manually (with the help of a few regular
expressions).

BUG=616447
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel;tryserver.chromium.win:win_optional_gpu_tests_rel
[email protected] (for ios/'s trivial application of this refactoring)

Review-Url: https://codereview.chromium.org/2132593002
Cr-Commit-Position: refs/heads/master@{#406148}
diff --git a/ppapi/proxy/ppb_message_loop_proxy.cc b/ppapi/proxy/ppb_message_loop_proxy.cc
index 7f2fc337..ac78eb9 100644
--- a/ppapi/proxy/ppb_message_loop_proxy.cc
+++ b/ppapi/proxy/ppb_message_loop_proxy.cc
@@ -9,8 +9,9 @@
 #include <vector>
 
 #include "base/bind.h"
+#include "base/bind_helpers.h"
 #include "base/compiler_specific.h"
-#include "base/location.h"
+#include "base/logging.h"
 #include "base/threading/thread_task_runner_handle.h"
 #include "ppapi/c/pp_errors.h"
 #include "ppapi/c/ppb_message_loop.h"
@@ -109,11 +110,17 @@
   if (is_main_thread_loop_)
     return PP_ERROR_INPROGRESS;
 
+  base::RunLoop* previous_run_loop = run_loop_;
+  base::RunLoop run_loop;
+  run_loop_ = &run_loop;
+
   nested_invocations_++;
   CallWhileUnlocked(
-      base::Bind(&base::MessageLoop::Run, base::Unretained(loop_.get())));
+      base::Bind(&base::RunLoop::Run, base::Unretained(run_loop_)));
   nested_invocations_--;
 
+  run_loop_ = previous_run_loop;
+
   if (should_destroy_ && nested_invocations_ == 0) {
     task_runner_ = NULL;
     loop_.reset();
@@ -142,10 +149,13 @@
   if (PP_ToBool(should_destroy))
     should_destroy_ = true;
 
-  if (IsCurrent() && nested_invocations_ > 0)
-    loop_->QuitWhenIdle();
-  else
-    PostClosure(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure(), 0);
+  if (IsCurrent() && nested_invocations_ > 0) {
+    run_loop_->QuitWhenIdle();
+  } else {
+    PostClosure(FROM_HERE, base::Bind(&MessageLoopResource::QuitRunLoopWhenIdle,
+                                      Unretained(this)),
+                0);
+  }
   return PP_OK;
 }
 
@@ -201,6 +211,12 @@
   return currently_handling_blocking_message_;
 }
 
+void MessageLoopResource::QuitRunLoopWhenIdle() {
+  DCHECK(IsCurrent());
+  DCHECK(run_loop_);
+  run_loop_->QuitWhenIdle();
+}
+
 // static
 void MessageLoopResource::ReleaseMessageLoop(void* value) {
   static_cast<MessageLoopResource*>(value)->DetachFromThread();