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

Side by Side Diff: components/storage_monitor/media_storage_util.cc

Issue 2834703003: Remove unmapped media galleries histograms. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/storage_monitor/media_storage_util.h" 5 #include "components/storage_monitor/media_storage_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "build/build_config.h" 14 #include "build/build_config.h"
16 #include "components/storage_monitor/removable_device_constants.h" 15 #include "components/storage_monitor/removable_device_constants.h"
17 #include "components/storage_monitor/storage_monitor.h" 16 #include "components/storage_monitor/storage_monitor.h"
18 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
19 18
20 using content::BrowserThread; 19 using content::BrowserThread;
21 20
22 namespace storage_monitor { 21 namespace storage_monitor {
23 22
24 namespace { 23 namespace {
25 24
26 // MediaDeviceNotification.DeviceInfo histogram values.
27 enum DeviceInfoHistogramBuckets {
28 MASS_STORAGE_DEVICE_NAME_AND_UUID_AVAILABLE,
29 MASS_STORAGE_DEVICE_UUID_MISSING,
30 MASS_STORAGE_DEVICE_NAME_MISSING,
31 MASS_STORAGE_DEVICE_NAME_AND_UUID_MISSING,
32 MTP_STORAGE_DEVICE_NAME_AND_UUID_AVAILABLE,
33 MTP_STORAGE_DEVICE_UUID_MISSING,
34 MTP_STORAGE_DEVICE_NAME_MISSING,
35 MTP_STORAGE_DEVICE_NAME_AND_UUID_MISSING,
36 DEVICE_INFO_BUCKET_BOUNDARY
37 };
38
39 #if !defined(OS_WIN) 25 #if !defined(OS_WIN)
40 const char kRootPath[] = "/"; 26 const char kRootPath[] = "/";
41 #endif 27 #endif
42 28
43 typedef std::vector<StorageInfo> StorageInfoList; 29 typedef std::vector<StorageInfo> StorageInfoList;
44 30
45 base::FilePath::StringType FindRemovableStorageLocationById( 31 base::FilePath::StringType FindRemovableStorageLocationById(
46 const std::string& device_id) { 32 const std::string& device_id) {
47 StorageInfoList devices = 33 StorageInfoList devices =
48 StorageMonitor::GetInstance()->GetAllAvailableStorages(); 34 StorageMonitor::GetInstance()->GetAllAvailableStorages();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 #endif 192 #endif
207 } 193 }
208 194
209 DCHECK(type == StorageInfo::MTP_OR_PTP || 195 DCHECK(type == StorageInfo::MTP_OR_PTP ||
210 type == StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM || 196 type == StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM ||
211 type == StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM); 197 type == StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM);
212 return base::FilePath(FindRemovableStorageLocationById(device_id)); 198 return base::FilePath(FindRemovableStorageLocationById(device_id));
213 } 199 }
214 200
215 // static 201 // static
216 void MediaStorageUtil::RecordDeviceInfoHistogram(
217 bool mass_storage,
218 const std::string& device_uuid,
219 const base::string16& device_label) {
220 unsigned int event_number = 0;
221 if (!mass_storage)
222 event_number = 4;
223
224 if (device_label.empty())
225 event_number += 2;
226
227 if (device_uuid.empty())
228 event_number += 1;
229 enum DeviceInfoHistogramBuckets event =
230 static_cast<enum DeviceInfoHistogramBuckets>(event_number);
231 if (event >= DEVICE_INFO_BUCKET_BOUNDARY) {
232 NOTREACHED();
233 return;
234 }
235 UMA_HISTOGRAM_ENUMERATION("MediaDeviceNotifications.DeviceInfo", event,
236 DEVICE_INFO_BUCKET_BOUNDARY);
237 }
238
239 // static
240 bool MediaStorageUtil::IsRemovableStorageAttached(const std::string& id) { 202 bool MediaStorageUtil::IsRemovableStorageAttached(const std::string& id) {
241 StorageMonitor* monitor = StorageMonitor::GetInstance(); 203 StorageMonitor* monitor = StorageMonitor::GetInstance();
242 if (!monitor) 204 if (!monitor)
243 return false; 205 return false;
244 206
245 StorageInfoList devices = monitor->GetAllAvailableStorages(); 207 StorageInfoList devices = monitor->GetAllAvailableStorages();
246 for (const auto& device : devices) { 208 for (const auto& device : devices) {
247 if (StorageInfo::IsRemovableDevice(id) && device.device_id() == id) 209 if (StorageInfo::IsRemovableDevice(id) && device.device_id() == id)
248 return true; 210 return true;
249 } 211 }
250 return false; 212 return false;
251 } 213 }
252 214
253 } // namespace storage_monitor 215 } // namespace storage_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698