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

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

Issue 10780023: Change base::SystemMonitor's media device functions to take a type and string16 instead of a FilePa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix win Created 8 years, 5 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
OLDNEW
1 // Copyright (c) 2012 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 <utility> 7 #include <utility>
8 8
9 #include "base/file_path.h"
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/message_loop.h" 10 #include "base/message_loop.h"
12 #include "base/time.h" 11 #include "base/time.h"
12 #include "base/utf_string_conversions.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 static SystemMonitor* g_system_monitor = NULL; 16 static SystemMonitor* g_system_monitor = NULL;
17 17
18 #if defined(ENABLE_BATTERY_MONITORING) 18 #if defined(ENABLE_BATTERY_MONITORING)
19 // The amount of time (in ms) to wait before running the initial 19 // The amount of time (in ms) to wait before running the initial
20 // battery check. 20 // battery check.
21 static int kDelayedBatteryCheckMs = 10 * 1000; 21 static int kDelayedBatteryCheckMs = 10 * 1000;
22 #endif // defined(ENABLE_BATTERY_MONITORING) 22 #endif // defined(ENABLE_BATTERY_MONITORING)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 break; 81 break;
82 } 82 }
83 } 83 }
84 84
85 void SystemMonitor::ProcessDevicesChanged() { 85 void SystemMonitor::ProcessDevicesChanged() {
86 NotifyDevicesChanged(); 86 NotifyDevicesChanged();
87 } 87 }
88 88
89 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id, 89 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id,
90 const std::string& name, 90 const std::string& name,
91 const FilePath& path) { 91 MediaDeviceType type,
92 media_device_map_.insert(std::make_pair(id, MakeTuple(id, name, path))); 92 const string16& data) {
93 NotifyMediaDeviceAttached(id, name, path); 93 media_device_map_.insert(std::make_pair(id, MakeTuple(id, name, type, data)));
94 NotifyMediaDeviceAttached(id, name, type, data);
94 } 95 }
95 96
97 #if defined(OS_POSIX)
98 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id,
99 const std::string& name,
100 MediaDeviceType type,
101 const std::string& data) {
102 string16 data16 = UTF8ToUTF16(data);
103 media_device_map_.insert(
vandebo (ex-Chrome) 2012/07/19 19:05:20 Call the other ProcessMediaDeviceAttach with the c
Lei Zhang 2012/07/19 23:07:25 I removed this since we switched to FilePath::Stri
104 std::make_pair(id, MakeTuple(id, name, type, data16)));
105 NotifyMediaDeviceAttached(id, name, type, data16);
106 }
107 #endif
108
96 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) { 109 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) {
97 MediaDeviceMap::iterator it = media_device_map_.find(id); 110 MediaDeviceMap::iterator it = media_device_map_.find(id);
98 if (it != media_device_map_.end()) 111 if (it != media_device_map_.end())
99 media_device_map_.erase(it); 112 media_device_map_.erase(it);
100 NotifyMediaDeviceDetached(id); 113 NotifyMediaDeviceDetached(id);
101 } 114 }
102 115
103 std::vector<SystemMonitor::MediaDeviceInfo> 116 std::vector<SystemMonitor::MediaDeviceInfo>
104 SystemMonitor::GetAttachedMediaDevices() const { 117 SystemMonitor::GetAttachedMediaDevices() const {
105 std::vector<MediaDeviceInfo> results; 118 std::vector<MediaDeviceInfo> results;
(...skipping 22 matching lines...) Expand all
128 } 141 }
129 142
130 void SystemMonitor::NotifyDevicesChanged() { 143 void SystemMonitor::NotifyDevicesChanged() {
131 DVLOG(1) << "DevicesChanged"; 144 DVLOG(1) << "DevicesChanged";
132 devices_changed_observer_list_->Notify( 145 devices_changed_observer_list_->Notify(
133 &DevicesChangedObserver::OnDevicesChanged); 146 &DevicesChangedObserver::OnDevicesChanged);
134 } 147 }
135 148
136 void SystemMonitor::NotifyMediaDeviceAttached(const DeviceIdType& id, 149 void SystemMonitor::NotifyMediaDeviceAttached(const DeviceIdType& id,
137 const std::string& name, 150 const std::string& name,
138 const FilePath& path) { 151 MediaDeviceType type,
152 const string16& data) {
139 DVLOG(1) << "MediaDeviceAttached with name " << name << " and id " << id; 153 DVLOG(1) << "MediaDeviceAttached with name " << name << " and id " << id;
140 devices_changed_observer_list_->Notify( 154 devices_changed_observer_list_->Notify(
141 &DevicesChangedObserver::OnMediaDeviceAttached, id, name, path); 155 &DevicesChangedObserver::OnMediaDeviceAttached, id, name, type, data);
142 } 156 }
143 157
144 void SystemMonitor::NotifyMediaDeviceDetached(const DeviceIdType& id) { 158 void SystemMonitor::NotifyMediaDeviceDetached(const DeviceIdType& id) {
145 DVLOG(1) << "MediaDeviceDetached for id " << id; 159 DVLOG(1) << "MediaDeviceDetached for id " << id;
146 devices_changed_observer_list_->Notify( 160 devices_changed_observer_list_->Notify(
147 &DevicesChangedObserver::OnMediaDeviceDetached, id); 161 &DevicesChangedObserver::OnMediaDeviceDetached, id);
148 } 162 }
149 163
150 void SystemMonitor::NotifyPowerStateChange() { 164 void SystemMonitor::NotifyPowerStateChange() {
151 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off") 165 DVLOG(1) << "PowerStateChange: " << (BatteryPower() ? "On" : "Off")
(...skipping 10 matching lines...) Expand all
162 void SystemMonitor::NotifyResume() { 176 void SystemMonitor::NotifyResume() {
163 DVLOG(1) << "Power Resuming"; 177 DVLOG(1) << "Power Resuming";
164 power_observer_list_->Notify(&PowerObserver::OnResume); 178 power_observer_list_->Notify(&PowerObserver::OnResume);
165 } 179 }
166 180
167 void SystemMonitor::BatteryCheck() { 181 void SystemMonitor::BatteryCheck() {
168 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); 182 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
169 } 183 }
170 184
171 } // namespace base 185 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698