Chromium Code Reviews| 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/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" | 14 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| 16 #include "chrome/browser/system_monitor/media_storage_util.h" | 15 #include "chrome/browser/system_monitor/media_storage_util.h" |
| 16 #include "chrome/browser/system_monitor/removable_device_notifications_histogram .h" | |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Returns true if the requested device is valid, else false. On success, fills | 23 // Returns true if the requested device is valid, else false. On success, fills |
| 24 // in |unique_id| and |device_label| | 24 // in |unique_id| and |device_label| |
| 25 bool GetDeviceInfo(const std::string& source_path, std::string* unique_id, | 25 bool GetDeviceInfo(const std::string& source_path, std::string* unique_id, |
| 26 string16* device_label) { | 26 string16* device_label) { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 NOTREACHED(); | 141 NOTREACHED(); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // Get the media device uuid and label if exists. | 145 // Get the media device uuid and label if exists. |
| 146 std::string unique_id; | 146 std::string unique_id; |
| 147 string16 device_label; | 147 string16 device_label; |
| 148 if (!GetDeviceInfo(mount_info.source_path, &unique_id, &device_label)) | 148 if (!GetDeviceInfo(mount_info.source_path, &unique_id, &device_label)) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 // Keep track of device uuid, to see how often we receive empty uuid values. | |
| 152 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.DeviceUUIDAvailable", | |
| 153 !unique_id.empty()); | |
| 154 if (unique_id.empty()) | |
| 155 return; | |
| 156 | |
| 157 chrome::MediaStorageUtil::Type type = has_dcim ? | 151 chrome::MediaStorageUtil::Type type = has_dcim ? |
| 158 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM : | 152 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM : |
| 159 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; | 153 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; |
| 160 | 154 |
| 155 // Keep track of device uuid, to see how often we receive empty uuid values. | |
|
vandebo (ex-Chrome)
2012/09/16 22:27:46
update comment.
kmadhusu
2012/09/17 18:29:07
Done.
| |
| 156 RecordDeviceInfoHistogram(type, unique_id, device_label); | |
| 157 if (unique_id.empty() || device_label.empty()) | |
| 158 return; | |
| 159 | |
| 161 std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type, | 160 std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type, |
| 162 unique_id); | 161 unique_id); |
| 163 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); | 162 mount_map_.insert(std::make_pair(mount_info.mount_path, device_id)); |
| 164 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( | 163 base::SystemMonitor::Get()->ProcessRemovableStorageAttached( |
| 165 device_id, | 164 device_id, |
| 166 device_label, | 165 device_label, |
| 167 mount_info.mount_path); | 166 mount_info.mount_path); |
| 168 } | 167 } |
| 169 | 168 |
| 170 } // namespace chrome | 169 } // namespace chrome |
| OLD | NEW |