Creating a framework for suppressing pollution of the profiler data and applying for know cases of pollution.
See the bug.

The CL introduces TaskStopwatch that has to be used to measure run time for tasks. It takes care of double-counting
run time in the nested-tasks case by subtracting run time of nested tasks from their parents. TaskStopwatch can be
also used for subtracting other nested intervals, such as the time while a nested message pump runs. ThreadData::TallyADeath
now takes a stopwatch parameter instead of start_time and end_time. This helps avoid mistakes when the interval passed up to
the parent for exclusion is different from the interval for the current task duration.

BUG=401560

Review URL: https://codereview.chromium.org/445413003

Cr-Commit-Position: refs/heads/master@{#294865}
diff --git a/base/run_loop.cc b/base/run_loop.cc
index 8344aa4..e92e110f 100644
--- a/base/run_loop.cc
+++ b/base/run_loop.cc
@@ -5,6 +5,7 @@
 #include "base/run_loop.h"
 
 #include "base/bind.h"
+#include "base/tracked_objects.h"
 
 #if defined(OS_WIN)
 #include "base/message_loop/message_pump_dispatcher.h"
@@ -46,7 +47,13 @@
 void RunLoop::Run() {
   if (!BeforeRun())
     return;
+
+  // Use task stopwatch to exclude the loop run time from the current task, if
+  // any.
+  tracked_objects::TaskStopwatch stopwatch;
   loop_->RunHandler();
+  stopwatch.Stop();
+
   AfterRun();
 }