Chromium Code Reviews| Index: chrome/browser/system_monitor/media_storage_util.cc |
| diff --git a/chrome/browser/system_monitor/media_storage_util.cc b/chrome/browser/system_monitor/media_storage_util.cc |
| index c6a03ed6c1b057450d8aa2ff3bc0b9c237412a72..78c3ceecd8b8665bd22faa96b1e940a059a9e397 100644 |
| --- a/chrome/browser/system_monitor/media_storage_util.cc |
| +++ b/chrome/browser/system_monitor/media_storage_util.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/callback.h" |
| #include "base/file_util.h" |
| #include "base/logging.h" |
| +#include "base/metrics/histogram.h" |
| #include "base/system_monitor/system_monitor.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -34,6 +35,19 @@ namespace { |
| typedef std::vector<SystemMonitor::RemovableStorageInfo> RemovableStorageInfo; |
| +// MediaDeviceNotification.DeviceInfo histogram values. |
| +enum DeviceInfoHistogramBuckets { |
| + MASS_STORAGE_DEVICE_NAME_AND_UUID_AVAILABLE, |
| + MASS_STORAGE_DEVICE_UUID_MISSING, |
| + MASS_STORAGE_DEVICE_NAME_MISSING, |
| + MASS_STORAGE_DEVICE_NAME_AND_UUID_MISSING, |
| + MTP_STORAGE_DEVICE_NAME_AND_UUID_AVAILABLE, |
| + MTP_STORAGE_DEVICE_UUID_MISSING, |
| + MTP_STORAGE_DEVICE_NAME_MISSING, |
| + MTP_STORAGE_DEVICE_NAME_AND_UUID_MISSING, |
| + DEVICE_INFO_BUCKET_BOUNDARY |
| +}; |
| + |
| // Prefix constants for different device id spaces. |
| const char kRemovableMassStorageWithDCIMPrefix[] = "dcim:"; |
| const char kRemovableMassStorageNoDCIMPrefix[] = "nodcim:"; |
| @@ -276,6 +290,29 @@ FilePath MediaStorageUtil::FindDevicePathById(const std::string& device_id) { |
| } |
| // static |
| +void MediaStorageUtil::RecordDeviceInfoHistogram(bool mass_storage, |
| + const std::string& device_uuid, |
| + const string16& device_name) { |
| + int event_number = 0; |
|
Lei Zhang
2012/09/17 20:46:01
unsigned int? otherwise you'd also want to check f
Lei Zhang
2012/09/17 20:46:01
I think the numbers are a bit hard to read, but I
kmadhusu
2012/09/17 21:52:20
Done.
|
| + if (!mass_storage) |
| + event_number = 4; |
| + |
| + if (device_name.empty()) |
| + event_number += 2; |
| + |
| + if (device_uuid.empty()) |
| + event_number += 1; |
| + enum DeviceInfoHistogramBuckets event = |
| + static_cast<enum DeviceInfoHistogramBuckets>(event_number); |
| + if (event >= DEVICE_INFO_BUCKET_BOUNDARY) { |
| + NOTREACHED(); |
| + return; |
| + } |
| + UMA_HISTOGRAM_ENUMERATION("MediaDeviceNotifications.DeviceInfo", event, |
| + DEVICE_INFO_BUCKET_BOUNDARY); |
| +} |
| + |
| +// static |
| void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( |
| GetDeviceInfoFromPathFunction function) { |
| g_test_get_device_info_from_path_function = function; |