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..970a6c0cc21fd6f5fbc368e6e6a2f8546930e40f 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,21 @@ |
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); |
+ return it == disks.end() ? std::string() : it->second->fs_uuid(); |
+} |
+ |
+} // namespace |
+ |
using content::BrowserThread; |
-MediaDeviceNotifications::MediaDeviceNotifications() |
- : current_device_id_(0) { |
+MediaDeviceNotifications::MediaDeviceNotifications() { |
DCHECK(disks::DiskMountManager::GetInstance()); |
disks::DiskMountManager::GetInstance()->AddObserver(this); |
} |
@@ -101,7 +113,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); |
jar (doing other things)
2012/07/27 17:48:48
Why didn't you use the UMA_HISTOGRAM_BOOLEAN() mac
kmadhusu
2012/07/27 18:30:31
I saw a couple of sample code doing this. So I tho
|
+ 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, |