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

Side by Side Diff: chrome/browser/system_monitor/media_storage_util.cc

Issue 10933114: Combine boolean MediaDeviceNotifications histograms to an enumerated histogram. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix style nit Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // chrome::MediaStorageUtil implementation. 5 // chrome::MediaStorageUtil implementation.
6 6
7 #include "chrome/browser/system_monitor/media_storage_util.h" 7 #include "chrome/browser/system_monitor/media_storage_util.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/histogram.h"
14 #include "base/system_monitor/system_monitor.h" 15 #include "base/system_monitor/system_monitor.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 17
17 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
18 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_ chromeos.h" 19 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_ chromeos.h"
19 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h" 20 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h"
20 #elif defined(OS_LINUX) 21 #elif defined(OS_LINUX)
21 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" 22 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h"
22 #elif defined(OS_MACOSX) 23 #elif defined(OS_MACOSX)
23 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" 24 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h"
24 #elif defined(OS_WIN) 25 #elif defined(OS_WIN)
25 #include "chrome/browser/system_monitor/removable_device_notifications_window_wi n.h" 26 #include "chrome/browser/system_monitor/removable_device_notifications_window_wi n.h"
26 #endif 27 #endif
27 28
28 using base::SystemMonitor; 29 using base::SystemMonitor;
29 using content::BrowserThread; 30 using content::BrowserThread;
30 31
31 namespace chrome { 32 namespace chrome {
32 33
33 namespace { 34 namespace {
34 35
35 typedef std::vector<SystemMonitor::RemovableStorageInfo> RemovableStorageInfo; 36 typedef std::vector<SystemMonitor::RemovableStorageInfo> RemovableStorageInfo;
36 37
38 // MediaDeviceNotification.DeviceInfo histogram values.
39 enum DeviceInfoHistogramBuckets {
40 MASS_STORAGE_DEVICE_NAME_AND_UUID_AVAILABLE,
41 MASS_STORAGE_DEVICE_UUID_MISSING,
42 MASS_STORAGE_DEVICE_NAME_MISSING,
43 MASS_STORAGE_DEVICE_NAME_AND_UUID_MISSING,
44 MTP_STORAGE_DEVICE_NAME_AND_UUID_AVAILABLE,
45 MTP_STORAGE_DEVICE_UUID_MISSING,
46 MTP_STORAGE_DEVICE_NAME_MISSING,
47 MTP_STORAGE_DEVICE_NAME_AND_UUID_MISSING,
48 DEVICE_INFO_BUCKET_BOUNDARY
49 };
50
37 // Prefix constants for different device id spaces. 51 // Prefix constants for different device id spaces.
38 const char kRemovableMassStorageWithDCIMPrefix[] = "dcim:"; 52 const char kRemovableMassStorageWithDCIMPrefix[] = "dcim:";
39 const char kRemovableMassStorageNoDCIMPrefix[] = "nodcim:"; 53 const char kRemovableMassStorageNoDCIMPrefix[] = "nodcim:";
40 const char kFixedMassStoragePrefix[] = "path:"; 54 const char kFixedMassStoragePrefix[] = "path:";
41 const char kMtpPtpPrefix[] = "mtp:"; 55 const char kMtpPtpPrefix[] = "mtp:";
42 56
43 static bool (*g_test_get_device_info_from_path_function)( 57 static bool (*g_test_get_device_info_from_path_function)(
44 const FilePath& path, std::string* device_id, string16* device_name, 58 const FilePath& path, std::string* device_id, string16* device_name,
45 FilePath* relative_path) = NULL; 59 FilePath* relative_path) = NULL;
46 60
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return FilePath::FromUTF8Unsafe(unique_id); 283 return FilePath::FromUTF8Unsafe(unique_id);
270 } 284 }
271 285
272 DCHECK(type == MTP_OR_PTP || 286 DCHECK(type == MTP_OR_PTP ||
273 type == REMOVABLE_MASS_STORAGE_WITH_DCIM || 287 type == REMOVABLE_MASS_STORAGE_WITH_DCIM ||
274 type == REMOVABLE_MASS_STORAGE_NO_DCIM); 288 type == REMOVABLE_MASS_STORAGE_NO_DCIM);
275 return FilePath(FindRemovableStorageLocationById(device_id)); 289 return FilePath(FindRemovableStorageLocationById(device_id));
276 } 290 }
277 291
278 // static 292 // static
293 void MediaStorageUtil::RecordDeviceInfoHistogram(bool mass_storage,
294 const std::string& device_uuid,
295 const string16& device_name) {
296 int event_number = mass_storage ? 0 : 4;
vandebo (ex-Chrome) 2012/09/17 18:40:07 nit: Remove the trinary operator.
Lei Zhang 2012/09/17 18:46:54 Why even use integers? Why not just use the enums?
kmadhusu 2012/09/17 19:32:49 Done.
kmadhusu 2012/09/17 19:32:49 I think this function is simple and easier to unde
Lei Zhang 2012/09/17 19:48:27 I'm not sure it is. Every time |event_number| chan
297 if (device_name.empty())
298 event_number += 2;
299
300 if (device_uuid.empty())
301 event_number += 1;
302 enum DeviceInfoHistogramBuckets event =
303 static_cast<enum DeviceInfoHistogramBuckets>(event_number);
304 if (event >= DEVICE_INFO_BUCKET_BOUNDARY) {
305 NOTREACHED();
306 return;
307 }
308 UMA_HISTOGRAM_ENUMERATION("MediaDeviceNotifications.DeviceInfo", event,
309 DEVICE_INFO_BUCKET_BOUNDARY);
310 }
311
312 // static
279 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting( 313 void MediaStorageUtil::SetGetDeviceInfoFromPathFunctionForTesting(
280 GetDeviceInfoFromPathFunction function) { 314 GetDeviceInfoFromPathFunction function) {
281 g_test_get_device_info_from_path_function = function; 315 g_test_get_device_info_from_path_function = function;
282 } 316 }
283 317
284 MediaStorageUtil::MediaStorageUtil() {} 318 MediaStorageUtil::MediaStorageUtil() {}
285 319
286 } // namespace chrome 320 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698