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

Unified 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 cros 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 side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698