| 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 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_
chromeos.h" | 5 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_
chromeos.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | |
| 8 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 9 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 10 #include "base/string_split.h" | 9 #include "base/string_split.h" |
| 11 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 12 #include "base/system_monitor/system_monitor.h" | 11 #include "base/system_monitor/system_monitor.h" |
| 13 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h" | 13 #include "chrome/browser/chromeos/mtp/media_transfer_protocol_manager.h" |
| 14 #include "chrome/browser/system_monitor/media_storage_util.h" |
| 15 #include "chrome/browser/system_monitor/removable_device_constants.h" | 15 #include "chrome/browser/system_monitor/removable_device_constants.h" |
| 16 #include "chrome/browser/system_monitor/media_storage_util.h" | 16 #include "chrome/browser/system_monitor/removable_device_notifications_histogram
.h" |
| 17 #include "chromeos/dbus/mtp_storage_info.pb.h" | 17 #include "chromeos/dbus/mtp_storage_info.pb.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 namespace mtp { | 20 namespace mtp { |
| 21 | 21 |
| 22 using chrome::MediaStorageUtil; | 22 using chrome::MediaStorageUtil; |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Device root path constant. | 26 // Device root path constant. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 // New storage is attached. | 146 // New storage is attached. |
| 147 if (is_attached) { | 147 if (is_attached) { |
| 148 std::string device_id; | 148 std::string device_id; |
| 149 string16 device_name; | 149 string16 device_name; |
| 150 std::string location; | 150 std::string location; |
| 151 get_storage_info_func_(storage_name, &device_id, &device_name, &location); | 151 get_storage_info_func_(storage_name, &device_id, &device_name, &location); |
| 152 | 152 |
| 153 // Keep track of device id and device name to see how often we receive | 153 // Keep track of device id and device name to see how often we receive |
| 154 // empty values. | 154 // empty values. |
| 155 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.MTPDeviceUUIDAvailable", | 155 RecordDeviceInfoHistogram(MediaStorageUtil::MTP_OR_PTP, device_id, |
| 156 !device_id.empty()); | 156 device_name); |
| 157 UMA_HISTOGRAM_BOOLEAN("MediaDeviceNotification.MTPDeviceNameAvailable", | |
| 158 !device_name.empty()); | |
| 159 | |
| 160 if (device_id.empty() || device_name.empty()) | 157 if (device_id.empty() || device_name.empty()) |
| 161 return; | 158 return; |
| 162 | 159 |
| 163 DCHECK(!ContainsKey(storage_map_, storage_name)); | 160 DCHECK(!ContainsKey(storage_map_, storage_name)); |
| 164 storage_map_[storage_name] = device_id; | 161 storage_map_[storage_name] = device_id; |
| 165 system_monitor->ProcessRemovableStorageAttached(device_id, device_name, | 162 system_monitor->ProcessRemovableStorageAttached(device_id, device_name, |
| 166 location); | 163 location); |
| 167 } else { | 164 } else { |
| 168 // Existing storage is detached. | 165 // Existing storage is detached. |
| 169 StorageNameToIdMap::iterator it = storage_map_.find(storage_name); | 166 StorageNameToIdMap::iterator it = storage_map_.find(storage_name); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 181 DCHECK(mtp_manager); | 178 DCHECK(mtp_manager); |
| 182 StorageList storages = mtp_manager->GetStorages(); | 179 StorageList storages = mtp_manager->GetStorages(); |
| 183 for (StorageList::const_iterator storage_iter = storages.begin(); | 180 for (StorageList::const_iterator storage_iter = storages.begin(); |
| 184 storage_iter != storages.end(); ++storage_iter) { | 181 storage_iter != storages.end(); ++storage_iter) { |
| 185 StorageChanged(true, *storage_iter); | 182 StorageChanged(true, *storage_iter); |
| 186 } | 183 } |
| 187 } | 184 } |
| 188 | 185 |
| 189 } // namespace mtp | 186 } // namespace mtp |
| 190 } // namespace chromeos | 187 } // namespace chromeos |
| OLD | NEW |