[upgrade_detector] React to changes in the installation.

Historically, in-use updates for desktop Chrome (Win, Mac, Linux) have
been detected by a periodic task that runs every two hours. In this CL,
desktop browsers now use an InstalledVersionMonitor to observe changes
to the installation. Any change schedules a poll ten seconds in the
future. The result of this is that observers of the BuildState will be
notified of an update closer to the actual time of the update.

On Windows, InstalledVersionMonitor reacts to changes in the browser's
"Clients" registry key. On macOS and Linux, InstalledVersionMonitor
reacts to changes in the browser's installation directory.

The UpgradeDetector.PollType UMA metric is reported in response to the
first poll that detects a version change. This will be used to determine
if the new monitor-based strategy is sufficiently reliable to retire the
periodic polling.

BUG=1099386

Change-Id: Ifcd130b8330b733a3f248ec058dc7af7093ef425
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464922
Commit-Queue: Greg Thompson <[email protected]>
Auto-Submit: Greg Thompson <[email protected]>
Reviewed-by: Mark Pearson <[email protected]>
Reviewed-by: Yann Dago <[email protected]>
Cr-Commit-Position: refs/heads/master@{#817445}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index fb2f314..0fc6632 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -4507,6 +4507,8 @@
       "themes/theme_helper_win.cc",
       "themes/theme_helper_win.h",
       "upgrade_detector/get_installed_version_win.cc",
+      "upgrade_detector/registry_monitor.cc",
+      "upgrade_detector/registry_monitor.h",
       "webshare/win/show_share_ui_for_window_operation.cc",
       "webshare/win/show_share_ui_for_window_operation.h",
       "win/app_icon.cc",
@@ -4752,6 +4754,8 @@
       "renderer_host/chrome_render_widget_host_view_mac_history_swiper.h",
       "renderer_host/chrome_render_widget_host_view_mac_history_swiper.mm",
       "shell_integration_mac.mm",
+      "upgrade_detector/directory_monitor.cc",
+      "upgrade_detector/directory_monitor.h",
       "upgrade_detector/get_installed_version_mac.mm",
     ]
     deps += [
@@ -4829,6 +4833,8 @@
       "shell_integration_linux.h",
       "themes/theme_service_aura_linux.cc",
       "themes/theme_service_aura_linux.h",
+      "upgrade_detector/directory_monitor.cc",
+      "upgrade_detector/directory_monitor.h",
       "upgrade_detector/get_installed_version_linux.cc",
     ]
     deps += [ "//chrome/app/theme:chrome_unscaled_resources_grit" ]
@@ -5002,6 +5008,7 @@
       "signin/signin_global_error_factory.h",
       "upgrade_detector/get_installed_version.cc",
       "upgrade_detector/get_installed_version.h",
+      "upgrade_detector/installed_version_monitor.h",
       "upgrade_detector/installed_version_poller.cc",
       "upgrade_detector/installed_version_poller.h",
       "upgrade_detector/upgrade_detector_impl.cc",