| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const base::FilePath& path, | 43 const base::FilePath& path, |
| 44 const MediaStorageUtil::BoolCallback& callback) { | 44 const MediaStorageUtil::BoolCallback& 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, file_util::PathExists(path))); |
| 48 } | 48 } |
| 49 | 49 |
| 50 typedef std::vector<StorageInfo> StorageInfoList; | 50 typedef std::vector<StorageInfo> StorageInfoList; |
| 51 | 51 |
| 52 bool IsRemovableStorageAttached(const std::string& id) { | 52 bool IsRemovableStorageAttached(const std::string& id) { |
| 53 StorageInfoList devices = StorageMonitor::GetInstance()->GetAttachedStorage(); | 53 StorageInfoList devices = |
| 54 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
| 54 for (StorageInfoList::const_iterator it = devices.begin(); | 55 for (StorageInfoList::const_iterator it = devices.begin(); |
| 55 it != devices.end(); ++it) { | 56 it != devices.end(); ++it) { |
| 56 if (it->device_id() == id) | 57 if (StorageInfo::IsRemovableDevice(id) && it->device_id() == id) |
| 57 return true; | 58 return true; |
| 58 } | 59 } |
| 59 return false; | 60 return false; |
| 60 } | 61 } |
| 61 | 62 |
| 62 base::FilePath::StringType FindRemovableStorageLocationById( | 63 base::FilePath::StringType FindRemovableStorageLocationById( |
| 63 const std::string& device_id) { | 64 const std::string& device_id) { |
| 64 StorageInfoList devices = StorageMonitor::GetInstance()->GetAttachedStorage(); | 65 StorageInfoList devices = |
| 66 StorageMonitor::GetInstance()->GetAllAvailableStorages(); |
| 65 for (StorageInfoList::const_iterator it = devices.begin(); | 67 for (StorageInfoList::const_iterator it = devices.begin(); |
| 66 it != devices.end(); ++it) { | 68 it != devices.end(); ++it) { |
| 67 if (it->device_id() == device_id) | 69 if (it->device_id() == device_id |
| 70 && StorageInfo::IsRemovableDevice(device_id)) |
| 68 return it->location(); | 71 return it->location(); |
| 69 } | 72 } |
| 70 return base::FilePath::StringType(); | 73 return base::FilePath::StringType(); |
| 71 } | 74 } |
| 72 | 75 |
| 73 void FilterAttachedDevicesOnFileThread(MediaStorageUtil::DeviceIdSet* devices) { | 76 void FilterAttachedDevicesOnFileThread(MediaStorageUtil::DeviceIdSet* devices) { |
| 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 75 MediaStorageUtil::DeviceIdSet missing_devices; | 78 MediaStorageUtil::DeviceIdSet missing_devices; |
| 76 | 79 |
| 77 for (MediaStorageUtil::DeviceIdSet::const_iterator it = devices->begin(); | 80 for (MediaStorageUtil::DeviceIdSet::const_iterator it = devices->begin(); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 static_cast<enum DeviceInfoHistogramBuckets>(event_number); | 246 static_cast<enum DeviceInfoHistogramBuckets>(event_number); |
| 244 if (event >= DEVICE_INFO_BUCKET_BOUNDARY) { | 247 if (event >= DEVICE_INFO_BUCKET_BOUNDARY) { |
| 245 NOTREACHED(); | 248 NOTREACHED(); |
| 246 return; | 249 return; |
| 247 } | 250 } |
| 248 UMA_HISTOGRAM_ENUMERATION("MediaDeviceNotifications.DeviceInfo", event, | 251 UMA_HISTOGRAM_ENUMERATION("MediaDeviceNotifications.DeviceInfo", event, |
| 249 DEVICE_INFO_BUCKET_BOUNDARY); | 252 DEVICE_INFO_BUCKET_BOUNDARY); |
| 250 } | 253 } |
| 251 | 254 |
| 252 } // namespace chrome | 255 } // namespace chrome |
| OLD | NEW |