Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: base/system_monitor/system_monitor.cc

Issue 9580018: Add media device attach notification mechanism. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Set 1 again Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/system_monitor/system_monitor.h ('k') | base/system_monitor/system_monitor_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/system_monitor/system_monitor.h" 5 #include "base/system_monitor/system_monitor.h"
6 6
7 #include "base/file_path.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/message_loop.h" 9 #include "base/message_loop.h"
9 #include "base/time.h" 10 #include "base/time.h"
10 11
11 namespace base { 12 namespace base {
12 13
13 static SystemMonitor* g_system_monitor = NULL; 14 static SystemMonitor* g_system_monitor = NULL;
14 15
15 #if defined(ENABLE_BATTERY_MONITORING) 16 #if defined(ENABLE_BATTERY_MONITORING)
16 // The amount of time (in ms) to wait before running the initial 17 // The amount of time (in ms) to wait before running the initial
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 NotifySuspend(); 77 NotifySuspend();
77 } 78 }
78 break; 79 break;
79 } 80 }
80 } 81 }
81 82
82 void SystemMonitor::ProcessDevicesChanged() { 83 void SystemMonitor::ProcessDevicesChanged() {
83 NotifyDevicesChanged(); 84 NotifyDevicesChanged();
84 } 85 }
85 86
87 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id,
88 const std::string& name,
89 const FilePath& path) {
90 NotifyMediaDeviceAttached(id, name, path);
91 }
92
93 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) {
94 NotifyMediaDeviceDetached(id);
95 }
96
86 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { 97 void SystemMonitor::AddPowerObserver(PowerObserver* obs) {
87 power_observer_list_->AddObserver(obs); 98 power_observer_list_->AddObserver(obs);
88 } 99 }
89 100
90 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { 101 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) {
91 power_observer_list_->RemoveObserver(obs); 102 power_observer_list_->RemoveObserver(obs);
92 } 103 }
93 104
94 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { 105 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) {
95 devices_changed_observer_list_->AddObserver(obs); 106 devices_changed_observer_list_->AddObserver(obs);
96 } 107 }
97 108
98 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) { 109 void SystemMonitor::RemoveDevicesChangedObserver(DevicesChangedObserver* obs) {
99 devices_changed_observer_list_->RemoveObserver(obs); 110 devices_changed_observer_list_->RemoveObserver(obs);
100 } 111 }
101 112
102 void SystemMonitor::NotifyDevicesChanged() { 113 void SystemMonitor::NotifyDevicesChanged() {
103 DVLOG(1) << "DevicesChanged"; 114 DVLOG(1) << "DevicesChanged";
104 devices_changed_observer_list_->Notify( 115 devices_changed_observer_list_->Notify(
105 &DevicesChangedObserver::OnDevicesChanged); 116 &DevicesChangedObserver::OnDevicesChanged);
106 } 117 }
107 118
119 void SystemMonitor::NotifyMediaDeviceAttached(const DeviceIdType& id,
120 const std::string& name,
121 const FilePath& path) {
122 DVLOG(1) << "MediaDeviceAttached with name " << name << " and id " << id;
123 devices_changed_observer_list_->Notify(
124 &DevicesChangedObserver::OnMediaDeviceAttached, id, name, path);
125 }
126
127 void SystemMonitor::NotifyMediaDeviceDetached(const DeviceIdType& id) {
128 DVLOG(1) << "MediaDeviceDetached for id " << id;
129 devices_changed_observer_list_->Notify(
130 &DevicesChangedObserver::OnMediaDeviceDetached, id);
131 }
132
108 void SystemMonitor::NotifyPowerStateChange() { 133 void SystemMonitor::NotifyPowerStateChange() {
109 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") 134 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off")
110 << " battery"; 135 << " battery";
111 power_observer_list_->Notify(&PowerObserver::OnPowerStateChange, 136 power_observer_list_->Notify(&PowerObserver::OnPowerStateChange,
112 BatteryPower()); 137 BatteryPower());
113 } 138 }
114 139
115 void SystemMonitor::NotifySuspend() { 140 void SystemMonitor::NotifySuspend() {
116 DVLOG(1) << "Power Suspending"; 141 DVLOG(1) << "Power Suspending";
117 power_observer_list_->Notify(&PowerObserver::OnSuspend); 142 power_observer_list_->Notify(&PowerObserver::OnSuspend);
118 } 143 }
119 144
120 void SystemMonitor::NotifyResume() { 145 void SystemMonitor::NotifyResume() {
121 DVLOG(1) << "Power Resuming"; 146 DVLOG(1) << "Power Resuming";
122 power_observer_list_->Notify(&PowerObserver::OnResume); 147 power_observer_list_->Notify(&PowerObserver::OnResume);
123 } 148 }
124 149
125 void SystemMonitor::BatteryCheck() { 150 void SystemMonitor::BatteryCheck() {
126 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); 151 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
127 } 152 }
128 153
129 } // namespace base 154 } // namespace base
OLDNEW
« no previous file with comments | « base/system_monitor/system_monitor.h ('k') | base/system_monitor/system_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698