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

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

Issue 10332190: Add SystemMonitor::GetMediaDevices() (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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) 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>
8
7 #include "base/file_path.h" 9 #include "base/file_path.h"
8 #include "base/logging.h" 10 #include "base/logging.h"
9 #include "base/message_loop.h" 11 #include "base/message_loop.h"
10 #include "base/time.h" 12 #include "base/time.h"
11 13
12 namespace base { 14 namespace base {
13 15
14 static SystemMonitor* g_system_monitor = NULL; 16 static SystemMonitor* g_system_monitor = NULL;
15 17
16 #if defined(ENABLE_BATTERY_MONITORING) 18 #if defined(ENABLE_BATTERY_MONITORING)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 82 }
81 } 83 }
82 84
83 void SystemMonitor::ProcessDevicesChanged() { 85 void SystemMonitor::ProcessDevicesChanged() {
84 NotifyDevicesChanged(); 86 NotifyDevicesChanged();
85 } 87 }
86 88
87 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id, 89 void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id,
88 const std::string& name, 90 const std::string& name,
89 const FilePath& path) { 91 const FilePath& path) {
92 media_device_map_.insert(std::make_pair(id, MakeTuple(id, name, path)));
90 NotifyMediaDeviceAttached(id, name, path); 93 NotifyMediaDeviceAttached(id, name, path);
91 } 94 }
92 95
93 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) { 96 void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) {
97 MediaDeviceMap::iterator it = media_device_map_.find(id);
98 if (it != media_device_map_.end())
99 media_device_map_.erase(it);
94 NotifyMediaDeviceDetached(id); 100 NotifyMediaDeviceDetached(id);
95 } 101 }
96 102
103 std::vector<SystemMonitor::MediaDeviceInfo>*
104 SystemMonitor::GetAttachedMediaDevices() const {
105 std::vector<MediaDeviceInfo>* results = new std::vector<MediaDeviceInfo>;
106 for (MediaDeviceMap::const_iterator it = media_device_map_.begin();
107 it != media_device_map_.end();
108 ++it) {
109 results->push_back(it->second);
110 }
111 return results;
112 }
113
97 void SystemMonitor::AddPowerObserver(PowerObserver* obs) { 114 void SystemMonitor::AddPowerObserver(PowerObserver* obs) {
98 power_observer_list_->AddObserver(obs); 115 power_observer_list_->AddObserver(obs);
99 } 116 }
100 117
101 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) { 118 void SystemMonitor::RemovePowerObserver(PowerObserver* obs) {
102 power_observer_list_->RemoveObserver(obs); 119 power_observer_list_->RemoveObserver(obs);
103 } 120 }
104 121
105 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) { 122 void SystemMonitor::AddDevicesChangedObserver(DevicesChangedObserver* obs) {
106 devices_changed_observer_list_->AddObserver(obs); 123 devices_changed_observer_list_->AddObserver(obs);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 void SystemMonitor::NotifyResume() { 162 void SystemMonitor::NotifyResume() {
146 DVLOG(1) << "Power Resuming"; 163 DVLOG(1) << "Power Resuming";
147 power_observer_list_->Notify(&PowerObserver::OnResume); 164 power_observer_list_->Notify(&PowerObserver::OnResume);
148 } 165 }
149 166
150 void SystemMonitor::BatteryCheck() { 167 void SystemMonitor::BatteryCheck() {
151 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT); 168 ProcessPowerMessage(SystemMonitor::POWER_STATE_EVENT);
152 } 169 }
153 170
154 } // namespace base 171 } // 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