Add base::RunLoop::NestingObserver::OnExitNestedRunLoop().

This method is called when a nested loop is done running work.
It will help simplify the TaskQueueManager code.

Use case:
The blink scheduler needs to adjust the time domain
when there is a transition between a nested/non-nested scope.
https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc?l=2302&rcl=614a67e2c14cf8bb9a06f4fe8da7625cbf1ea7d7
Currently, it checks base::RunLoop::IsNestedOnCurrentThread()
every time a task completes to detect transitions between
a nested/non-nested scope. Code would be simpler with
an explicit notification.

Bug: 783309
Change-Id: I9748c287ad8418831598d84f45a518e4138c5e1b
Reviewed-on: https://chromium-review.googlesource.com/766388
Reviewed-by: Gabriel Charette <[email protected]>
Reviewed-by: Alexander Timin <[email protected]>
Commit-Queue: François Doray <[email protected]>
Cr-Commit-Position: refs/heads/master@{#527112}
diff --git a/base/run_loop.cc b/base/run_loop.cc
index 3cda1cb0..3b7bfde 100644
--- a/base/run_loop.cc
+++ b/base/run_loop.cc
@@ -321,6 +321,11 @@
   RunLoop* previous_run_loop =
       active_run_loops_.empty() ? nullptr : active_run_loops_.top();
 
+  if (previous_run_loop) {
+    for (auto& observer : delegate_->nesting_observers_)
+      observer.OnExitNestedRunLoop();
+  }
+
   // Execute deferred Quit, if any:
   if (previous_run_loop && previous_run_loop->quit_called_)
     delegate_->Quit();