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