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 19 matching lines...) Expand all Loading... |
30 MTP_STORAGE_DEVICE_UUID_MISSING, | 30 MTP_STORAGE_DEVICE_UUID_MISSING, |
31 MTP_STORAGE_DEVICE_NAME_MISSING, | 31 MTP_STORAGE_DEVICE_NAME_MISSING, |
32 MTP_STORAGE_DEVICE_NAME_AND_UUID_MISSING, | 32 MTP_STORAGE_DEVICE_NAME_AND_UUID_MISSING, |
33 DEVICE_INFO_BUCKET_BOUNDARY | 33 DEVICE_INFO_BUCKET_BOUNDARY |
34 }; | 34 }; |
35 | 35 |
36 #if !defined(OS_WIN) | 36 #if !defined(OS_WIN) |
37 const char kRootPath[] = "/"; | 37 const char kRootPath[] = "/"; |
38 #endif | 38 #endif |
39 | 39 |
40 void ValidatePathOnFileThread( | |
41 const base::FilePath& path, | |
42 const base::Callback<void(bool)>& callback) { | |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
44 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | |
45 base::Bind(callback, base::PathExists(path))); | |
46 } | |
47 | |
48 typedef std::vector<StorageInfo> StorageInfoList; | 40 typedef std::vector<StorageInfo> StorageInfoList; |
49 | 41 |
50 base::FilePath::StringType FindRemovableStorageLocationById( | 42 base::FilePath::StringType FindRemovableStorageLocationById( |
51 const std::string& device_id) { | 43 const std::string& device_id) { |
52 StorageInfoList devices = | 44 StorageInfoList devices = |
53 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 45 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
54 for (StorageInfoList::const_iterator it = devices.begin(); | 46 for (StorageInfoList::const_iterator it = devices.begin(); |
55 it != devices.end(); ++it) { | 47 it != devices.end(); ++it) { |
56 if (it->device_id() == device_id | 48 if (it->device_id() == device_id |
57 && StorageInfo::IsRemovableDevice(device_id)) | 49 && StorageInfo::IsRemovableDevice(device_id)) |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 bool MediaStorageUtil::IsRemovableStorageAttached(const std::string& id) { | 236 bool MediaStorageUtil::IsRemovableStorageAttached(const std::string& id) { |
245 StorageInfoList devices = | 237 StorageInfoList devices = |
246 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 238 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
247 for (StorageInfoList::const_iterator it = devices.begin(); | 239 for (StorageInfoList::const_iterator it = devices.begin(); |
248 it != devices.end(); ++it) { | 240 it != devices.end(); ++it) { |
249 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) | 241 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) |
250 return true; | 242 return true; |
251 } | 243 } |
252 return false; | 244 return false; |
253 } | 245 } |
OLD | NEW |