Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: components/storage_monitor/media_transfer_protocol_device_observer_linux.cc

Issue 120303003: [StorageMonitor] Move gallery name generation to StorageInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittest build error on mac/linux/chromeos Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 storage_label;
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, &storage_label, &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,
201 if (device_id.empty() || device_name.empty()) 201 storage_label);
202 if (device_id.empty() || storage_label.empty())
202 return; 203 return;
203 204
204 DCHECK(!ContainsKey(storage_map_, location)); 205 DCHECK(!ContainsKey(storage_map_, location));
205 206
206 StorageInfo storage_info(device_id, device_name, location, device_name, 207 StorageInfo storage_info(device_id, location, storage_label,
207 base::string16(), base::string16(), 0); 208 base::string16(), base::string16(), 0);
208 storage_map_[location] = storage_info; 209 storage_map_[location] = storage_info;
209 notifications_->ProcessAttach(storage_info); 210 notifications_->ProcessAttach(storage_info);
210 } else { 211 } else {
211 // Existing storage is detached. 212 // Existing storage is detached.
212 StorageLocationToInfoMap::iterator it = 213 StorageLocationToInfoMap::iterator it =
213 storage_map_.find(GetDeviceLocationFromStorageName(storage_name)); 214 storage_map_.find(GetDeviceLocationFromStorageName(storage_name));
214 if (it == storage_map_.end()) 215 if (it == storage_map_.end())
215 return; 216 return;
216 notifications_->ProcessDetach(it->second.device_id()); 217 notifications_->ProcessDetach(it->second.device_id());
(...skipping 17 matching lines...) Expand all
234 if (it->second.device_id() == device_id) { 235 if (it->second.device_id() == device_id) {
235 *location = it->first; 236 *location = it->first;
236 return true; 237 return true;
237 } 238 }
238 } 239 }
239 240
240 return false; 241 return false;
241 } 242 }
242 243
243 } // namespace storage_monitor 244 } // namespace storage_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698