Fix shutdown histograms on browser closing.

Shutdown histograms were not properly written because of several issues:
1) There is an incorrect calculation of current open browsers which
have not yet started to close. This leads to the fact that
browser_shutdown::OnShutdownStarting() is not called in case of
several browsers shutdown.
2) During the closure of the browser we are trying to find if there is any
background Chrome applications with help of KeepAliveRegistry::IsKeepingAlive()
function call, which is actually tracking running Browsers also (i.e. it can
return true even if there is no background application). So it is needed to
introduce new function to track background applications only.

[email protected]
BUG=707147
BUG=707144

Change-Id: If4f7c080965c95e2c0b810817e94a09f3a52ba51
Reviewed-on: https://chromium-review.googlesource.com/760356
Commit-Queue: Lei Zhang <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Nicolas Dossou-Gbété <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Cr-Commit-Position: refs/heads/master@{#519810}
diff --git a/components/keep_alive_registry/keep_alive_registry.cc b/components/keep_alive_registry/keep_alive_registry.cc
index e29e94c0..a01e103 100644
--- a/components/keep_alive_registry/keep_alive_registry.cc
+++ b/components/keep_alive_registry/keep_alive_registry.cc
@@ -26,6 +26,14 @@
   return registered_count_ > 0;
 }
 
+bool KeepAliveRegistry::IsKeepingAliveOnlyByBrowserOrigin() const {
+  for (const auto& value : registered_keep_alives_) {
+    if (value.first != KeepAliveOrigin::BROWSER)
+      return false;
+  }
+  return true;
+}
+
 bool KeepAliveRegistry::IsRestartAllowed() const {
   return registered_count_ == restart_allowed_count_;
 }