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

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

Issue 10882039: Make the Linux System Monitor implementation track all devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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 // chrome::MediaStorageUtil implementation. 5 // chrome::MediaStorageUtil implementation.
6 6
7 #include "chrome/browser/media_gallery/media_storage_util.h" 7 #include "chrome/browser/media_gallery/media_storage_util.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return; 147 return;
148 } 148 }
149 149
150 switch (type) { 150 switch (type) {
151 case USB_MTP: // Fall through 151 case USB_MTP: // Fall through
152 case USB_MASS_STORAGE_WITH_DCIM: 152 case USB_MASS_STORAGE_WITH_DCIM:
153 // We should be able to find media devices in SystemMonitor. 153 // We should be able to find media devices in SystemMonitor.
154 callback.Run(!FindMediaDeviceLocationById(device_id).empty()); 154 callback.Run(!FindMediaDeviceLocationById(device_id).empty());
155 break; 155 break;
156 case USB_MASS_STORAGE_NO_DCIM: 156 case USB_MASS_STORAGE_NO_DCIM:
157 FindUSBDeviceById(unique_id, 157 FindUSBDeviceById(device_id,
158 base::Bind(&EmptyPathIsFalseCallback, callback)); 158 base::Bind(&EmptyPathIsFalseCallback, callback));
159 break; 159 break;
160 case OTHER_MASS_STORAGE: 160 case OTHER_MASS_STORAGE:
161 // For this type, the unique_id is the path. 161 // For this type, the unique_id is the path.
162 BrowserThread::PostTask( 162 BrowserThread::PostTask(
163 BrowserThread::FILE, FROM_HERE, 163 BrowserThread::FILE, FROM_HERE,
164 base::Bind(&ValidatePathOnFileThread, 164 base::Bind(&ValidatePathOnFileThread,
165 FilePath::FromUTF8Unsafe(unique_id), 165 FilePath::FromUTF8Unsafe(unique_id),
166 base::Bind(&EmptyPathIsFalseCallback, callback))); 166 base::Bind(&EmptyPathIsFalseCallback, callback)));
167 break; 167 break;
(...skipping 25 matching lines...) Expand all
193 Type type; 193 Type type;
194 std::string unique_id; 194 std::string unique_id;
195 if (!CrackDeviceId(device_id, &type, &unique_id)) 195 if (!CrackDeviceId(device_id, &type, &unique_id))
196 callback.Run(FilePath()); 196 callback.Run(FilePath());
197 197
198 switch (type) { 198 switch (type) {
199 case USB_MTP: 199 case USB_MTP:
200 callback.Run(FilePath()); 200 callback.Run(FilePath());
201 break; 201 break;
202 case USB_MASS_STORAGE_NO_DCIM: 202 case USB_MASS_STORAGE_NO_DCIM:
203 FindUSBDeviceById(unique_id, callback); 203 FindUSBDeviceById(device_id, callback);
204 break; 204 break;
205 case OTHER_MASS_STORAGE: 205 case OTHER_MASS_STORAGE:
206 // For this type, the unique_id is the path. 206 // For this type, the unique_id is the path.
207 BrowserThread::PostTask( 207 BrowserThread::PostTask(
208 BrowserThread::FILE, FROM_HERE, 208 BrowserThread::FILE, FROM_HERE,
209 base::Bind(&ValidatePathOnFileThread, 209 base::Bind(&ValidatePathOnFileThread,
210 FilePath::FromUTF8Unsafe(unique_id), callback)); 210 FilePath::FromUTF8Unsafe(unique_id), callback));
211 break; 211 break;
212 case USB_MASS_STORAGE_WITH_DCIM: 212 case USB_MASS_STORAGE_WITH_DCIM:
213 callback.Run(FilePath(FindMediaDeviceLocationById(device_id))); 213 callback.Run(FilePath(FindMediaDeviceLocationById(device_id)));
214 break; 214 break;
215 } 215 }
216 NOTREACHED(); 216 NOTREACHED();
217 callback.Run(FilePath()); 217 callback.Run(FilePath());
218 } 218 }
219 219
220 MediaStorageUtil::MediaStorageUtil() {} 220 MediaStorageUtil::MediaStorageUtil() {}
221 221
222 // static 222 // static
223 void MediaStorageUtil::FindUSBDeviceById(const std::string& unique_id, 223 void MediaStorageUtil::FindUSBDeviceById(const std::string& device_id,
224 const FilePathCallback& callback) { 224 const FilePathCallback& callback) {
225 // TODO(vandebo) This needs to be implemented per platform. 225 // TODO(vandebo) This needs to be implemented per platform.
226 // Type is USB_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted 226 // Type is USB_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted
227 // somewhere... 227 // somewhere...
228 NOTREACHED(); 228 NOTREACHED();
229 callback.Run(FilePath()); 229 callback.Run(FilePath());
230 } 230 }
231 231
232 } // namespace chrome 232 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698