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

Unified Diff: chrome/browser/media_gallery/media_device_notifications_chromeos.cc

Issue 10830003: Extract and dispatch device uuid in media device attached notification message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' 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: chrome/browser/media_gallery/media_device_notifications_chromeos.cc
diff --git a/chrome/browser/media_gallery/media_device_notifications_chromeos.cc b/chrome/browser/media_gallery/media_device_notifications_chromeos.cc
index ae45d1563fb26fa80438c33ca086cd80a1332b80..252ca8f7561eda42b0af711ac002f0636db3702f 100644
--- a/chrome/browser/media_gallery/media_device_notifications_chromeos.cc
+++ b/chrome/browser/media_gallery/media_device_notifications_chromeos.cc
@@ -8,6 +8,7 @@
#include "base/file_path.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
@@ -16,10 +17,26 @@
namespace chromeos {
+namespace {
+
+std::string GetDeviceUuid(const std::string& source_path) {
+ // Get the media device uuid if exists.
+ const disks::DiskMountManager::DiskMap& disks =
+ disks::DiskMountManager::GetInstance()->disks();
+ disks::DiskMountManager::DiskMap::const_iterator it = disks.find(source_path);
+ std::string device_id;
Lei Zhang 2012/07/26 18:34:31 you can further simplify lines 27-32 to: return
kmadhusu 2012/07/26 18:44:50 Done.
+ if (it != disks.end()) {
+ const disks::DiskMountManager::Disk& disk = *it->second;
+ device_id = disk.fs_uuid();
Ben Chan 2012/07/26 17:56:03 this may be simpler: if (it != disks.end()) dev
kmadhusu 2012/07/26 18:44:50 done.
+ }
+ return device_id;
+}
+
+} // namespace
+
using content::BrowserThread;
-MediaDeviceNotifications::MediaDeviceNotifications()
- : current_device_id_(0) {
+MediaDeviceNotifications::MediaDeviceNotifications() {
DCHECK(disks::DiskMountManager::GetInstance());
disks::DiskMountManager::GetInstance()->AddObserver(this);
}
@@ -101,7 +118,21 @@ void MediaDeviceNotifications::AddMountedPathOnUIThread(
NOTREACHED();
return;
}
- const std::string device_id_str = base::IntToString(current_device_id_++);
+
+ // Get the media device uuid if exists.
+ std::string device_id_str = GetDeviceUuid(mount_info.source_path);
+
+ // Keep track of device uuid, to see how often we receive empty uuid values.
+ static base::Histogram* media_device_uuid_available(NULL);
Lei Zhang 2012/07/26 18:34:31 I see some Histogram code that uses a static Histo
+ if (!media_device_uuid_available) {
+ media_device_uuid_available = base::BooleanHistogram::FactoryGet(
+ "MediaDeviceNotification.device_uuid_available",
+ base::Histogram::kUmaTargetedHistogramFlag);
+ }
+ media_device_uuid_available->AddBoolean(!device_id_str.empty());
+ if (device_id_str.empty())
+ return;
+
mount_map_.insert(std::make_pair(mount_info.mount_path, device_id_str));
base::SystemMonitor::Get()->ProcessMediaDeviceAttached(
device_id_str,
« no previous file with comments | « chrome/browser/media_gallery/media_device_notifications_chromeos.h ('k') | chromeos/dbus/cros_disks_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698