| 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_
     linux.h" | 5 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_
     linux.h" | 
| 6 | 6 | 
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" | 
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" | 
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" | 
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 106 | 106 | 
| 107   if (!storage_info) | 107   if (!storage_info) | 
| 108     return; | 108     return; | 
| 109 | 109 | 
| 110   if (id) | 110   if (id) | 
| 111     *id = GetDeviceIdFromStorageInfo(*storage_info); | 111     *id = GetDeviceIdFromStorageInfo(*storage_info); | 
| 112 | 112 | 
| 113   if (label) | 113   if (label) | 
| 114     *label = GetDeviceLabelFromStorageInfo(*storage_info); | 114     *label = GetDeviceLabelFromStorageInfo(*storage_info); | 
| 115 | 115 | 
| 116 |  | 
| 117   if (location) | 116   if (location) | 
| 118     *location = GetDeviceLocationFromStorageName(storage_name); | 117     *location = GetDeviceLocationFromStorageName(storage_name); | 
| 119 } | 118 } | 
| 120 | 119 | 
| 121 }  // namespace | 120 }  // namespace | 
| 122 | 121 | 
| 123 MediaTransferProtocolDeviceObserverLinux:: | 122 MediaTransferProtocolDeviceObserverLinux:: | 
| 124 MediaTransferProtocolDeviceObserverLinux() | 123 MediaTransferProtocolDeviceObserverLinux() | 
| 125     : get_storage_info_func_(&GetStorageInfo) { | 124     : get_storage_info_func_(&GetStorageInfo) { | 
| 126   DCHECK(!g_mtp_device_observer); | 125   DCHECK(!g_mtp_device_observer); | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 207     // Keep track of device id and device name to see how often we receive | 206     // Keep track of device id and device name to see how often we receive | 
| 208     // empty values. | 207     // empty values. | 
| 209     MediaStorageUtil::RecordDeviceInfoHistogram(false, device_id, device_name); | 208     MediaStorageUtil::RecordDeviceInfoHistogram(false, device_id, device_name); | 
| 210     if (device_id.empty() || device_name.empty()) | 209     if (device_id.empty() || device_name.empty()) | 
| 211       return; | 210       return; | 
| 212 | 211 | 
| 213     DCHECK(!ContainsKey(storage_map_, location)); | 212     DCHECK(!ContainsKey(storage_map_, location)); | 
| 214 | 213 | 
| 215     RemovableStorageNotifications::StorageInfo storage_info( | 214     RemovableStorageNotifications::StorageInfo storage_info( | 
| 216         device_id, device_name, location); | 215         device_id, device_name, location); | 
|  | 216     storage_info.storage_label = device_name; | 
| 217     storage_map_[location] = storage_info; | 217     storage_map_[location] = storage_info; | 
| 218     notifications_->ProcessAttach(device_id, device_name, location); | 218     notifications_->ProcessAttach(storage_info); | 
| 219   } else { | 219   } else { | 
| 220     // Existing storage is detached. | 220     // Existing storage is detached. | 
| 221     StorageLocationToInfoMap::iterator it = | 221     StorageLocationToInfoMap::iterator it = | 
| 222         storage_map_.find(GetDeviceLocationFromStorageName(storage_name)); | 222         storage_map_.find(GetDeviceLocationFromStorageName(storage_name)); | 
| 223     if (it == storage_map_.end()) | 223     if (it == storage_map_.end()) | 
| 224       return; | 224       return; | 
| 225     notifications_->ProcessDetach(it->second.device_id); | 225     notifications_->ProcessDetach(it->second.device_id); | 
| 226     storage_map_.erase(it); | 226     storage_map_.erase(it); | 
| 227   } | 227   } | 
| 228 } | 228 } | 
| 229 | 229 | 
| 230 void MediaTransferProtocolDeviceObserverLinux::EnumerateStorages() { | 230 void MediaTransferProtocolDeviceObserverLinux::EnumerateStorages() { | 
| 231   typedef std::vector<std::string> StorageList; | 231   typedef std::vector<std::string> StorageList; | 
| 232   device::MediaTransferProtocolManager* mtp_manager = | 232   device::MediaTransferProtocolManager* mtp_manager = | 
| 233       device::MediaTransferProtocolManager::GetInstance(); | 233       device::MediaTransferProtocolManager::GetInstance(); | 
| 234   StorageList storages = mtp_manager->GetStorages(); | 234   StorageList storages = mtp_manager->GetStorages(); | 
| 235   for (StorageList::const_iterator storage_iter = storages.begin(); | 235   for (StorageList::const_iterator storage_iter = storages.begin(); | 
| 236        storage_iter != storages.end(); ++storage_iter) { | 236        storage_iter != storages.end(); ++storage_iter) { | 
| 237     StorageChanged(true, *storage_iter); | 237     StorageChanged(true, *storage_iter); | 
| 238   } | 238   } | 
| 239 } | 239 } | 
| 240 | 240 | 
| 241 }  // namespace chrome | 241 }  // namespace chrome | 
| OLD | NEW | 
|---|