OLD | NEW |
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_storage_util.h" | 5 #include "components/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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // static | 109 // static |
110 bool MediaStorageUtil::CanCreateFileSystem(const std::string& device_id, | 110 bool MediaStorageUtil::CanCreateFileSystem(const std::string& device_id, |
111 const base::FilePath& path) { | 111 const base::FilePath& path) { |
112 StorageInfo::Type type; | 112 StorageInfo::Type type; |
113 if (!StorageInfo::CrackDeviceId(device_id, &type, NULL)) | 113 if (!StorageInfo::CrackDeviceId(device_id, &type, NULL)) |
114 return false; | 114 return false; |
115 | 115 |
116 if (type == StorageInfo::MAC_IMAGE_CAPTURE) | 116 if (type == StorageInfo::MAC_IMAGE_CAPTURE) |
117 return true; | 117 return true; |
118 | 118 |
119 return path.IsAbsolute() && !path.ReferencesParent(); | 119 return !path.empty() && path.IsAbsolute() && !path.ReferencesParent(); |
120 } | 120 } |
121 | 121 |
122 // static | 122 // static |
123 void MediaStorageUtil::FilterAttachedDevices(DeviceIdSet* devices, | 123 void MediaStorageUtil::FilterAttachedDevices(DeviceIdSet* devices, |
124 const base::Closure& done) { | 124 const base::Closure& done) { |
125 if (BrowserThread::CurrentlyOn(BrowserThread::FILE)) { | 125 if (BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
126 FilterAttachedDevicesOnFileThread(devices); | 126 FilterAttachedDevicesOnFileThread(devices); |
127 done.Run(); | 127 done.Run(); |
128 return; | 128 return; |
129 } | 129 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 StorageMonitor::GetInstance()->GetAllAvailableStorages(); | 241 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
242 for (StorageInfoList::const_iterator it = devices.begin(); | 242 for (StorageInfoList::const_iterator it = devices.begin(); |
243 it != devices.end(); ++it) { | 243 it != devices.end(); ++it) { |
244 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) | 244 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) |
245 return true; | 245 return true; |
246 } | 246 } |
247 return false; | 247 return false; |
248 } | 248 } |
249 | 249 |
250 } // namespace storage_monitor | 250 } // namespace storage_monitor |
OLD | NEW |