Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: chrome/browser/storage_monitor/media_storage_util.cc

Issue 16186002: Refine StorageMonitor storage device getter (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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()->GetAttachedRemovableStorages();
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 (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()->GetAttachedRemovableStorages();
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)
68 return it->location(); 70 return it->location();
69 } 71 }
70 return base::FilePath::StringType(); 72 return base::FilePath::StringType();
71 } 73 }
72 74
73 void FilterAttachedDevicesOnFileThread(MediaStorageUtil::DeviceIdSet* devices) { 75 void FilterAttachedDevicesOnFileThread(MediaStorageUtil::DeviceIdSet* devices) {
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 static_cast<enum DeviceInfoHistogramBuckets>(event_number); 245 static_cast<enum DeviceInfoHistogramBuckets>(event_number);
244 if (event >= DEVICE_INFO_BUCKET_BOUNDARY) { 246 if (event >= DEVICE_INFO_BUCKET_BOUNDARY) {
245 NOTREACHED(); 247 NOTREACHED();
246 return; 248 return;
247 } 249 }
248 UMA_HISTOGRAM_ENUMERATION("MediaDeviceNotifications.DeviceInfo", event, 250 UMA_HISTOGRAM_ENUMERATION("MediaDeviceNotifications.DeviceInfo", event,
249 DEVICE_INFO_BUCKET_BOUNDARY); 251 DEVICE_INFO_BUCKET_BOUNDARY);
250 } 252 }
251 253
252 } // namespace chrome 254 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698