| 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/media_storage_util.h" | 5 #include "chrome/browser/storage_monitor/media_storage_util.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 #if !defined(OS_WIN) | 38 #if !defined(OS_WIN) |
| 39 const char kRootPath[] = "/"; | 39 const char kRootPath[] = "/"; |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 void ValidatePathOnFileThread( | 42 void ValidatePathOnFileThread( |
| 43 const base::FilePath& path, | 43 const base::FilePath& path, |
| 44 const base::Callback<void(bool)>& callback) { | 44 const base::Callback<void(bool)>& callback) { |
| 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 46 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 46 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 47 base::Bind(callback, file_util::PathExists(path))); | 47 base::Bind(callback, base::PathExists(path))); |
| 48 } | 48 } |
| 49 | 49 |
| 50 typedef std::vector<StorageInfo> StorageInfoList; | 50 typedef std::vector<StorageInfo> StorageInfoList; |
| 51 | 51 |
| 52 base::FilePath::StringType FindRemovableStorageLocationById( | 52 base::FilePath::StringType FindRemovableStorageLocationById( |
| 53 const std::string& device_id) { | 53 const std::string& device_id) { |
| 54 StorageInfoList devices = | 54 StorageInfoList devices = |
| 55 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 55 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
| 56 for (StorageInfoList::const_iterator it = devices.begin(); | 56 for (StorageInfoList::const_iterator it = devices.begin(); |
| 57 it != devices.end(); ++it) { | 57 it != devices.end(); ++it) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 72 StorageInfo::Type type; | 72 StorageInfo::Type type; |
| 73 std::string unique_id; | 73 std::string unique_id; |
| 74 if (!StorageInfo::CrackDeviceId(*it, &type, &unique_id)) { | 74 if (!StorageInfo::CrackDeviceId(*it, &type, &unique_id)) { |
| 75 missing_devices.insert(*it); | 75 missing_devices.insert(*it); |
| 76 continue; | 76 continue; |
| 77 } | 77 } |
| 78 | 78 |
| 79 if (type == StorageInfo::FIXED_MASS_STORAGE || | 79 if (type == StorageInfo::FIXED_MASS_STORAGE || |
| 80 type == StorageInfo::ITUNES || | 80 type == StorageInfo::ITUNES || |
| 81 type == StorageInfo::PICASA) { | 81 type == StorageInfo::PICASA) { |
| 82 if (!file_util::PathExists(base::FilePath::FromUTF8Unsafe(unique_id))) | 82 if (!base::PathExists(base::FilePath::FromUTF8Unsafe(unique_id))) |
| 83 missing_devices.insert(*it); | 83 missing_devices.insert(*it); |
| 84 continue; | 84 continue; |
| 85 } | 85 } |
| 86 | 86 |
| 87 if (!MediaStorageUtil::IsRemovableStorageAttached(*it)) | 87 if (!MediaStorageUtil::IsRemovableStorageAttached(*it)) |
| 88 missing_devices.insert(*it); | 88 missing_devices.insert(*it); |
| 89 } | 89 } |
| 90 | 90 |
| 91 for (MediaStorageUtil::DeviceIdSet::const_iterator it = | 91 for (MediaStorageUtil::DeviceIdSet::const_iterator it = |
| 92 missing_devices.begin(); | 92 missing_devices.begin(); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 246 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
| 247 for (StorageInfoList::const_iterator it = devices.begin(); | 247 for (StorageInfoList::const_iterator it = devices.begin(); |
| 248 it != devices.end(); ++it) { | 248 it != devices.end(); ++it) { |
| 249 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) | 249 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) |
| 250 return true; | 250 return true; |
| 251 } | 251 } |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace chrome | 255 } // namespace chrome |
| OLD | NEW |