Index: base/system_monitor/system_monitor.cc |
=================================================================== |
--- base/system_monitor/system_monitor.cc (revision 147551) |
+++ base/system_monitor/system_monitor.cc (working copy) |
@@ -6,10 +6,11 @@ |
#include <utility> |
-#include "base/file_path.h" |
#include "base/logging.h" |
#include "base/message_loop.h" |
+#include "base/stl_util.h" |
#include "base/time.h" |
+#include "base/utf_string_conversions.h" |
namespace base { |
@@ -86,14 +87,22 @@ |
NotifyDevicesChanged(); |
} |
-void SystemMonitor::ProcessMediaDeviceAttached(const DeviceIdType& id, |
- const std::string& name, |
- const FilePath& path) { |
- media_device_map_.insert(std::make_pair(id, MakeTuple(id, name, path))); |
- NotifyMediaDeviceAttached(id, name, path); |
+void SystemMonitor::ProcessMediaDeviceAttached( |
+ const std::string& id, |
+ const string16& name, |
+ MediaDeviceType type, |
+ const FilePath::StringType& location) { |
+ MediaDeviceInfo info(id, name, type, location); |
+ if (ContainsKey(media_device_map_, id)) { |
+ // This can happen if our unique id scheme fails. Ignore the incoming |
+ // non-unique attachment. |
+ return; |
+ } |
+ media_device_map_.insert(std::make_pair(id, info)); |
+ NotifyMediaDeviceAttached(id, name, type, location); |
} |
-void SystemMonitor::ProcessMediaDeviceDetached(const DeviceIdType& id) { |
+void SystemMonitor::ProcessMediaDeviceDetached(const std::string& id) { |
MediaDeviceMap::iterator it = media_device_map_.find(id); |
if (it != media_device_map_.end()) |
media_device_map_.erase(it); |
@@ -133,15 +142,18 @@ |
&DevicesChangedObserver::OnDevicesChanged); |
} |
-void SystemMonitor::NotifyMediaDeviceAttached(const DeviceIdType& id, |
- const std::string& name, |
- const FilePath& path) { |
- DVLOG(1) << "MediaDeviceAttached with name " << name << " and id " << id; |
+void SystemMonitor::NotifyMediaDeviceAttached( |
+ const std::string& id, |
+ const string16& name, |
+ MediaDeviceType type, |
+ const FilePath::StringType& location) { |
+ DVLOG(1) << "MediaDeviceAttached with name " << UTF16ToUTF8(name) |
+ << " and id " << id; |
devices_changed_observer_list_->Notify( |
- &DevicesChangedObserver::OnMediaDeviceAttached, id, name, path); |
+ &DevicesChangedObserver::OnMediaDeviceAttached, id, name, type, location); |
} |
-void SystemMonitor::NotifyMediaDeviceDetached(const DeviceIdType& id) { |
+void SystemMonitor::NotifyMediaDeviceDetached(const std::string& id) { |
DVLOG(1) << "MediaDeviceDetached for id " << id; |
devices_changed_observer_list_->Notify( |
&DevicesChangedObserver::OnMediaDeviceDetached, id); |