Chromium Code Reviews| 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 // chromeos::StorageMonitorCros implementation. | 5 // chromeos::StorageMonitorCros implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| 207 | 207 |
| 208 uint64 StorageMonitorCros::GetStorageSize( | 208 uint64 StorageMonitorCros::GetStorageSize( |
| 209 const std::string& device_location) const { | 209 const std::string& device_location) const { |
| 210 MountMap::const_iterator info_it = mount_map_.find(device_location); | 210 MountMap::const_iterator info_it = mount_map_.find(device_location); |
| 211 return (info_it != mount_map_.end()) ? | 211 return (info_it != mount_map_.end()) ? |
| 212 info_it->second.total_size_in_bytes : 0; | 212 info_it->second.total_size_in_bytes : 0; |
| 213 } | 213 } |
| 214 | 214 |
| 215 void NotifyEjectSuccess( | |
| 216 base::Callback<void(chrome::StorageMonitor::EjectStatus)> callback) { | |
| 217 callback.Run(chrome::StorageMonitor::EJECT_OK); | |
| 218 } | |
| 219 | |
| 220 void StorageMonitorCros::EjectDevice( | |
| 221 const std::string& device_id, | |
| 222 base::Callback<void(EjectStatus)> callback) { | |
| 223 std::string mount_path; | |
| 224 for (MountMap::const_iterator info_it = mount_map_.begin(); | |
| 225 info_it != mount_map_.end(); info_it++) { | |
|
Lei Zhang
2013/03/13 22:39:27
nit: ++info_it
Greg Billock
2013/03/18 19:38:40
Done.
| |
| 226 if (info_it->second.device_id == device_id) | |
| 227 mount_path = info_it->first; | |
| 228 } | |
| 229 | |
| 230 if (mount_path.empty()) { | |
| 231 callback.Run(EJECT_NO_SUCH_DEVICE); | |
| 232 return; | |
| 233 } | |
| 234 | |
| 235 disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); | |
| 236 if (!manager) { | |
| 237 callback.Run(EJECT_FAILURE); | |
| 238 return; | |
| 239 } | |
| 240 | |
| 241 manager->UnmountPath(mount_path, chromeos::UNMOUNT_OPTIONS_NONE); | |
|
tbarzic
2013/03/13 18:57:04
unmount path may actually fail, but the success/fa
Greg Billock
2013/03/18 19:38:40
Done.
| |
| 242 | |
| 243 BrowserThread::PostTask( | |
| 244 BrowserThread::UI, FROM_HERE, | |
| 245 base::Bind(&NotifyEjectSuccess, callback)); | |
|
Lei Zhang
2013/03/13 22:39:27
You probably don't need NotifyEjectSuccess().
Bro
Greg Billock
2013/03/18 19:38:40
Replaced with trampoline to convert parameter from
| |
| 246 } | |
| 247 | |
| 215 void StorageMonitorCros::CheckMountedPathOnFileThread( | 248 void StorageMonitorCros::CheckMountedPathOnFileThread( |
| 216 const disks::DiskMountManager::MountPointInfo& mount_info) { | 249 const disks::DiskMountManager::MountPointInfo& mount_info) { |
| 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 218 | 251 |
| 219 bool has_dcim = chrome::MediaStorageUtil::HasDcim(mount_info.mount_path); | 252 bool has_dcim = chrome::MediaStorageUtil::HasDcim(mount_info.mount_path); |
| 220 | 253 |
| 221 BrowserThread::PostTask( | 254 BrowserThread::PostTask( |
| 222 BrowserThread::UI, FROM_HERE, | 255 BrowserThread::UI, FROM_HERE, |
| 223 base::Bind(&StorageMonitorCros::AddMountedPathOnUIThread, this, | 256 base::Bind(&StorageMonitorCros::AddMountedPathOnUIThread, this, |
| 224 mount_info, has_dcim)); | 257 mount_info, has_dcim)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 vendor_name, | 303 vendor_name, |
| 271 model_name, | 304 model_name, |
| 272 storage_size_in_bytes); | 305 storage_size_in_bytes); |
| 273 | 306 |
| 274 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); | 307 mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); |
| 275 | 308 |
| 276 receiver()->ProcessAttach(object_info); | 309 receiver()->ProcessAttach(object_info); |
| 277 } | 310 } |
| 278 | 311 |
| 279 } // namespace chromeos | 312 } // namespace chromeos |
| OLD | NEW |