Attempting to resolve a race condition with PowerMonitor.

ThreadSanitizer caught multiple instances where PowerMonitor::Get or PowerMonitor::Add/RemoveObserver were being called concurrently with the PowerMonitor constructor in the main thread. These functions access a process-global PowerMontior instance (g_power_monitor), which was not thread safe.

This change adds locks around PowerMonitor creation and deletion, and forces Add/RemoveObserver to be called in a threadsafe manner. It also removes the need to call PowerMonitor::Get.

BUG=268924

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262018 0039d316-1c4b-4281-b951-d872f2087c98


CrOS-Libchrome-Original-Commit: f65e97e447b789af3a8dc653d8801e8c6f24f935
6 files changed
tree: 23ed9b33f7086b8b607461fc7999ce4e226befec
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/