| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/system_monitor/system_monitor.h" | |
| 6 | |
| 7 #include <utility> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/message_loop/message_loop.h" | |
| 11 #include "base/time/time.h" | |
| 12 | |
| 13 namespace base { | |
| 14 | |
| 15 static SystemMonitor* g_system_monitor = NULL; | |
| 16 | |
| 17 SystemMonitor::SystemMonitor() | |
| 18 : devices_changed_observer_list_( | |
| 19 new ObserverListThreadSafe<DevicesChangedObserver>()) { | |
| 20 DCHECK(!g_system_monitor); | |
| 21 g_system_monitor = this; | |
| 22 } | |
| 23 | |
| 24 SystemMonitor::~SystemMonitor() { | |
| 25 DCHECK_EQ(this, g_system_monitor); | |
| 26 g_system_monitor = NULL; | |
| 27 } | |
| 28 | |
| 29 // static | |
| 30 SystemMonitor* SystemMonitor::Get() { | |
| 31 return g_system_monitor; | |
| 32 } | |
| 33 | |
| 34 void SystemMonitor::ProcessDevicesChanged(DeviceType device_type) { | |
| 35 NotifyDevicesChanged(device_type); | |
| 36 } | |
| 37 | |
| 38 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { | |
| 39 devices_changed_observer_list_->AddObserver(obs); | |
| 40 } | |
| 41 | |
| 42 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { | |
| 43 devices_changed_observer_list_->RemoveObserver(obs); | |
| 44 } | |
| 45 | |
| 46 void SystemMonitor::NotifyDevicesChanged(DeviceType device_type) { | |
| 47 DVLOG(1) << "DevicesChanged with device type " << device_type; | |
| 48 devices_changed_observer_list_->Notify( | |
| 49 FROM_HERE, &DevicesChangedObserver::OnDevicesChanged, device_type); | |
| 50 } | |
| 51 | |
| 52 } // namespace base | |
| OLD | NEW |