Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/storage_monitor/media_transfer_protocol_device_observer_lin ux.h" | 5 #include "components/storage_monitor/media_transfer_protocol_device_observer_lin ux.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 | 183 |
| 184 // device::MediaTransferProtocolManager::Observer override. | 184 // device::MediaTransferProtocolManager::Observer override. |
| 185 void MediaTransferProtocolDeviceObserverLinux::StorageChanged( | 185 void MediaTransferProtocolDeviceObserverLinux::StorageChanged( |
| 186 bool is_attached, | 186 bool is_attached, |
| 187 const std::string& storage_name) { | 187 const std::string& storage_name) { |
| 188 DCHECK(!storage_name.empty()); | 188 DCHECK(!storage_name.empty()); |
| 189 | 189 |
| 190 // New storage is attached. | 190 // New storage is attached. |
| 191 if (is_attached) { | 191 if (is_attached) { |
| 192 std::string device_id; | 192 std::string device_id; |
| 193 base::string16 device_name; | 193 base::string16 device_name; |
|
vandebo (ex-Chrome)
2014/03/03 19:58:31
nit: this is already called label in GetStorageInf
Haojian Wu
2014/03/04 05:00:12
Done.
| |
| 194 std::string location; | 194 std::string location; |
| 195 get_storage_info_func_(storage_name, mtp_manager_, | 195 get_storage_info_func_(storage_name, mtp_manager_, |
| 196 &device_id, &device_name, &location); | 196 &device_id, &device_name, &location); |
| 197 | 197 |
| 198 // Keep track of device id and device name to see how often we receive | 198 // Keep track of device id and device name to see how often we receive |
| 199 // empty values. | 199 // empty values. |
| 200 MediaStorageUtil::RecordDeviceInfoHistogram(false, device_id, device_name); | 200 MediaStorageUtil::RecordDeviceInfoHistogram(false, device_id, device_name); |
| 201 if (device_id.empty() || device_name.empty()) | 201 if (device_id.empty() || device_name.empty()) |
| 202 return; | 202 return; |
| 203 | 203 |
| 204 DCHECK(!ContainsKey(storage_map_, location)); | 204 DCHECK(!ContainsKey(storage_map_, location)); |
| 205 | 205 |
| 206 StorageInfo storage_info(device_id, device_name, location, device_name, | 206 StorageInfo storage_info(device_id, location, device_name, base::string16(), |
| 207 base::string16(), base::string16(), 0); | 207 0); |
|
vandebo (ex-Chrome)
2014/03/03 19:58:31
Not enough args.
Haojian Wu
2014/03/04 05:00:12
Done.
| |
| 208 storage_map_[location] = storage_info; | 208 storage_map_[location] = storage_info; |
| 209 notifications_->ProcessAttach(storage_info); | 209 notifications_->ProcessAttach(storage_info); |
| 210 } else { | 210 } else { |
| 211 // Existing storage is detached. | 211 // Existing storage is detached. |
| 212 StorageLocationToInfoMap::iterator it = | 212 StorageLocationToInfoMap::iterator it = |
| 213 storage_map_.find(GetDeviceLocationFromStorageName(storage_name)); | 213 storage_map_.find(GetDeviceLocationFromStorageName(storage_name)); |
| 214 if (it == storage_map_.end()) | 214 if (it == storage_map_.end()) |
| 215 return; | 215 return; |
| 216 notifications_->ProcessDetach(it->second.device_id()); | 216 notifications_->ProcessDetach(it->second.device_id()); |
| 217 storage_map_.erase(it); | 217 storage_map_.erase(it); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 234 if (it->second.device_id() == device_id) { | 234 if (it->second.device_id() == device_id) { |
| 235 *location = it->first; | 235 *location = it->first; |
| 236 return true; | 236 return true; |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 return false; | 240 return false; |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace storage_monitor | 243 } // namespace storage_monitor |
| OLD | NEW |