| 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/storage_monitor/storage_monitor_mac.h" | 5 #include "chrome/browser/storage_monitor/storage_monitor_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 303 } |
| 304 | 304 |
| 305 EjectDiskOptions* options = new EjectDiskOptions; | 305 EjectDiskOptions* options = new EjectDiskOptions; |
| 306 options->bsd_name = bsd_name; | 306 options->bsd_name = bsd_name; |
| 307 options->callback = callback; | 307 options->callback = callback; |
| 308 options->disk.reset(disk.release()); | 308 options->disk.reset(disk.release()); |
| 309 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 309 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 310 base::Bind(EjectDisk, options)); | 310 base::Bind(EjectDisk, options)); |
| 311 } | 311 } |
| 312 | 312 |
| 313 std::vector<StorageInfo> StorageMonitorMac::GetAllAvailableStorages() const { |
| 314 std::vector<StorageInfo> results; |
| 315 |
| 316 std::map<std::string, StorageInfo>::const_iterator it; |
| 317 for (it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) |
| 318 results.push_back(it->second); |
| 319 |
| 320 return results; |
| 321 } |
| 322 |
| 313 // static | 323 // static |
| 314 void StorageMonitorMac::DiskAppearedCallback(DADiskRef disk, void* context) { | 324 void StorageMonitorMac::DiskAppearedCallback(DADiskRef disk, void* context) { |
| 315 StorageMonitorMac* monitor = static_cast<StorageMonitorMac*>(context); | 325 StorageMonitorMac* monitor = static_cast<StorageMonitorMac*>(context); |
| 316 monitor->GetDiskInfoAndUpdate(disk, UPDATE_DEVICE_ADDED); | 326 monitor->GetDiskInfoAndUpdate(disk, UPDATE_DEVICE_ADDED); |
| 317 } | 327 } |
| 318 | 328 |
| 319 // static | 329 // static |
| 320 void StorageMonitorMac::DiskDisappearedCallback(DADiskRef disk, void* context) { | 330 void StorageMonitorMac::DiskDisappearedCallback(DADiskRef disk, void* context) { |
| 321 StorageMonitorMac* monitor = static_cast<StorageMonitorMac*>(context); | 331 StorageMonitorMac* monitor = static_cast<StorageMonitorMac*>(context); |
| 322 monitor->GetDiskInfoAndUpdate(disk, UPDATE_DEVICE_REMOVED); | 332 monitor->GetDiskInfoAndUpdate(disk, UPDATE_DEVICE_REMOVED); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { | 374 it = disk_info_map_.begin(); it != disk_info_map_.end(); ++it) { |
| 365 if (it->second.location() == mount_point.value()) { | 375 if (it->second.location() == mount_point.value()) { |
| 366 *info = it->second; | 376 *info = it->second; |
| 367 return true; | 377 return true; |
| 368 } | 378 } |
| 369 } | 379 } |
| 370 return false; | 380 return false; |
| 371 } | 381 } |
| 372 | 382 |
| 373 } // namespace chrome | 383 } // namespace chrome |
| OLD | NEW |