| OLD | NEW |
| 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 // chromeos::RemovableDeviceNotificationsCros implementation. | 5 // chromeos::RemovableDeviceNotificationsCros implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos.
h" | 7 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos.
h" |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | |
| 12 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 13 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
| 14 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 15 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" | 15 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| 17 #include "chrome/browser/system_monitor/media_storage_util.h" | 16 #include "chrome/browser/system_monitor/media_storage_util.h" |
| 18 #include "chrome/browser/system_monitor/removable_device_constants.h" | 17 #include "chrome/browser/system_monitor/removable_device_constants.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 | 19 |
| 21 namespace chromeos { | 20 namespace chromeos { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (unique_id) | 72 if (unique_id) |
| 74 *unique_id = MakeDeviceUniqueId(*disk); | 73 *unique_id = MakeDeviceUniqueId(*disk); |
| 75 | 74 |
| 76 if (device_label) | 75 if (device_label) |
| 77 *device_label = GetDeviceName(*disk); | 76 *device_label = GetDeviceName(*disk); |
| 78 return true; | 77 return true; |
| 79 } | 78 } |
| 80 | 79 |
| 81 } // namespace | 80 } // namespace |
| 82 | 81 |
| 82 using chrome::MediaStorageUtil; |
| 83 using content::BrowserThread; | 83 using content::BrowserThread; |
| 84 | 84 |
| 85 RemovableDeviceNotificationsCros::RemovableDeviceNotificationsCros() { | 85 RemovableDeviceNotificationsCros::RemovableDeviceNotificationsCros() { |
| 86 DCHECK(disks::DiskMountManager::GetInstance()); | 86 DCHECK(disks::DiskMountManager::GetInstance()); |
| 87 disks::DiskMountManager::GetInstance()->AddObserver(this); | 87 disks::DiskMountManager::GetInstance()->AddObserver(this); |
| 88 CheckExistingMountPointsOnUIThread(); | 88 CheckExistingMountPointsOnUIThread(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 RemovableDeviceNotificationsCros::~RemovableDeviceNotificationsCros() { | 91 RemovableDeviceNotificationsCros::~RemovableDeviceNotificationsCros() { |
| 92 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); | 92 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 NOTREACHED(); | 179 NOTREACHED(); |
| 180 return; | 180 return; |
| 181 } | 181 } |
| 182 | 182 |
| 183 // Get the media device uuid and label if exists. | 183 // Get the media device uuid and label if exists. |
| 184 std::string unique_id; | 184 std::string unique_id; |
| 185 string16 device_label; | 185 string16 device_label; |
| 186 if (!GetDeviceInfo(mount_info.source_path, &unique_id, &device_label)) | 186 if (!GetDeviceInfo(mount_info.source_path, &unique_id, &device_label)) |
| 187 return; | 187 return; |
| 188 | 188 |
| 189 // Keep track of device uuid, to see how often we receive empty uuid values. | 189 // Keep track of device uuid and label, to see how often we receive empty |
| 190 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.DeviceUUIDAvailable", | 190 // values. |
| 191 !unique_id.empty()); | 191 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, device_label); |
| 192 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.DeviceNameAvailable", | |
| 193 !device_label.empty()); | |
| 194 if (unique_id.empty() || device_label.empty()) | 192 if (unique_id.empty() || device_label.empty()) |
| 195 return; | 193 return; |
| 196 | 194 |
| 197 chrome::MediaStorageUtil::Type type = has_dcim ? | 195 MediaStorageUtil::Type type = has_dcim ? |
| 198 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM : | 196 MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM : |
| 199 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; | 197 MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; |
| 200 | 198 |
| 201 std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type, | 199 std::string device_id = MediaStorageUtil::MakeDeviceId(type, unique_id); |
| 202 unique_id); | |
| 203 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); | 200 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); |
| 204 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( | 201 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( |
| 205 device_id, | 202 device_id, |
| 206 device_label, | 203 device_label, |
| 207 mount_info.mount_path); | 204 mount_info.mount_path); |
| 208 } | 205 } |
| 209 | 206 |
| 210 } // namespace chrome | 207 } // namespace chrome |
| OLD | NEW |