OLD | NEW |
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/storage_monitor_chromeos.h" | 5 #include "components/storage_monitor/storage_monitor_chromeos.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 StorageInfo* info) { | 50 StorageInfo* info) { |
51 DCHECK(info); | 51 DCHECK(info); |
52 std::string source_path = mount_info.source_path; | 52 std::string source_path = mount_info.source_path; |
53 | 53 |
54 const DiskMountManager::Disk* disk = | 54 const DiskMountManager::Disk* disk = |
55 DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); | 55 DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); |
56 if (!disk || disk->device_type() == chromeos::DEVICE_TYPE_UNKNOWN) | 56 if (!disk || disk->device_type() == chromeos::DEVICE_TYPE_UNKNOWN) |
57 return false; | 57 return false; |
58 | 58 |
59 std::string unique_id = MakeDeviceUniqueId(*disk); | 59 std::string unique_id = MakeDeviceUniqueId(*disk); |
60 // Keep track of device uuid and label, to see how often we receive empty | |
61 // values. | |
62 base::string16 device_label = base::UTF8ToUTF16(disk->device_label()); | |
63 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, device_label); | |
64 if (unique_id.empty()) | 60 if (unique_id.empty()) |
65 return false; | 61 return false; |
66 | 62 |
67 StorageInfo::Type type = has_dcim ? | 63 StorageInfo::Type type = has_dcim ? |
68 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM : | 64 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM : |
69 StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; | 65 StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; |
70 | 66 |
71 *info = StorageInfo(StorageInfo::MakeDeviceId(type, unique_id), | 67 *info = StorageInfo( |
72 mount_info.mount_path, | 68 StorageInfo::MakeDeviceId(type, unique_id), mount_info.mount_path, |
73 device_label, | 69 base::UTF8ToUTF16(disk->device_label()), |
74 base::UTF8ToUTF16(disk->vendor_name()), | 70 base::UTF8ToUTF16(disk->vendor_name()), |
75 base::UTF8ToUTF16(disk->product_name()), | 71 base::UTF8ToUTF16(disk->product_name()), disk->total_size_in_bytes()); |
76 disk->total_size_in_bytes()); | |
77 return true; | 72 return true; |
78 } | 73 } |
79 | 74 |
80 // Returns whether the mount point in |mount_info| is a media device or not. | 75 // Returns whether the mount point in |mount_info| is a media device or not. |
81 bool CheckMountedPathOnFileThread( | 76 bool CheckMountedPathOnFileThread( |
82 const DiskMountManager::MountPointInfo& mount_info) { | 77 const DiskMountManager::MountPointInfo& mount_info) { |
83 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 78 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
84 return MediaStorageUtil::HasDcim(base::FilePath(mount_info.mount_path)); | 79 return MediaStorageUtil::HasDcim(base::FilePath(mount_info.mount_path)); |
85 } | 80 } |
86 | 81 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 mount_map_.insert(std::make_pair(mount_info.mount_path, info)); | 293 mount_map_.insert(std::make_pair(mount_info.mount_path, info)); |
299 | 294 |
300 receiver()->ProcessAttach(info); | 295 receiver()->ProcessAttach(info); |
301 } | 296 } |
302 | 297 |
303 StorageMonitor* StorageMonitor::CreateInternal() { | 298 StorageMonitor* StorageMonitor::CreateInternal() { |
304 return new StorageMonitorCros(); | 299 return new StorageMonitorCros(); |
305 } | 300 } |
306 | 301 |
307 } // namespace storage_monitor | 302 } // namespace storage_monitor |
OLD | NEW |