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

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: Fix CrOS build 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return; 149 return;
150 } 150 }
151 151
152 switch (type) { 152 switch (type) {
153 case MTP_OR_PTP: // Fall through 153 case MTP_OR_PTP: // Fall through
154 case REMOVABLE_MASS_STORAGE_WITH_DCIM: 154 case REMOVABLE_MASS_STORAGE_WITH_DCIM:
155 // We should be able to find media devices in SystemMonitor. 155 // We should be able to find media devices in SystemMonitor.
156 callback.Run(!FindRemovableStorageLocationById(device_id).empty()); 156 callback.Run(!FindRemovableStorageLocationById(device_id).empty());
157 break; 157 break;
158 case REMOVABLE_MASS_STORAGE_NO_DCIM: 158 case REMOVABLE_MASS_STORAGE_NO_DCIM:
159 FindUSBDeviceById(unique_id, 159 FindUSBDeviceById(device_id,
160 base::Bind(&EmptyPathIsFalseCallback, callback)); 160 base::Bind(&EmptyPathIsFalseCallback, callback));
161 break; 161 break;
162 case FIXED_MASS_STORAGE: 162 case FIXED_MASS_STORAGE:
163 // For this type, the unique_id is the path. 163 // For this type, the unique_id is the path.
164 BrowserThread::PostTask( 164 BrowserThread::PostTask(
165 BrowserThread::FILE, FROM_HERE, 165 BrowserThread::FILE, FROM_HERE,
166 base::Bind(&ValidatePathOnFileThread, 166 base::Bind(&ValidatePathOnFileThread,
167 FilePath::FromUTF8Unsafe(unique_id), 167 FilePath::FromUTF8Unsafe(unique_id),
168 base::Bind(&EmptyPathIsFalseCallback, callback))); 168 base::Bind(&EmptyPathIsFalseCallback, callback)));
169 break; 169 break;
(...skipping 25 matching lines...) Expand all
195 Type type; 195 Type type;
196 std::string unique_id; 196 std::string unique_id;
197 if (!CrackDeviceId(device_id, &type, &unique_id)) 197 if (!CrackDeviceId(device_id, &type, &unique_id))
198 callback.Run(FilePath()); 198 callback.Run(FilePath());
199 199
200 switch (type) { 200 switch (type) {
201 case MTP_OR_PTP: 201 case MTP_OR_PTP:
202 callback.Run(FilePath()); 202 callback.Run(FilePath());
203 break; 203 break;
204 case REMOVABLE_MASS_STORAGE_NO_DCIM: 204 case REMOVABLE_MASS_STORAGE_NO_DCIM:
205 FindUSBDeviceById(unique_id, callback); 205 FindUSBDeviceById(device_id, callback);
206 break; 206 break;
207 case FIXED_MASS_STORAGE: 207 case FIXED_MASS_STORAGE:
208 // For this type, the unique_id is the path. 208 // For this type, the unique_id is the path.
209 BrowserThread::PostTask( 209 BrowserThread::PostTask(
210 BrowserThread::FILE, FROM_HERE, 210 BrowserThread::FILE, FROM_HERE,
211 base::Bind(&ValidatePathOnFileThread, 211 base::Bind(&ValidatePathOnFileThread,
212 FilePath::FromUTF8Unsafe(unique_id), callback)); 212 FilePath::FromUTF8Unsafe(unique_id), callback));
213 break; 213 break;
214 case REMOVABLE_MASS_STORAGE_WITH_DCIM: 214 case REMOVABLE_MASS_STORAGE_WITH_DCIM:
215 callback.Run(FilePath(FindRemovableStorageLocationById(device_id))); 215 callback.Run(FilePath(FindRemovableStorageLocationById(device_id)));
216 break; 216 break;
217 } 217 }
218 NOTREACHED(); 218 NOTREACHED();
219 callback.Run(FilePath()); 219 callback.Run(FilePath());
220 } 220 }
221 221
222 MediaStorageUtil::MediaStorageUtil() {} 222 MediaStorageUtil::MediaStorageUtil() {}
223 223
224 // static 224 // static
225 void MediaStorageUtil::FindUSBDeviceById(const std::string& unique_id, 225 void MediaStorageUtil::FindUSBDeviceById(const std::string& device_id,
226 const FilePathCallback& callback) { 226 const FilePathCallback& callback) {
227 // TODO(vandebo) This needs to be implemented per platform. 227 // TODO(vandebo) This needs to be implemented per platform.
228 // Type is REMOVABLE_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted 228 // Type is REMOVABLE_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted
229 // somewhere... 229 // somewhere...
230 NOTREACHED(); 230 NOTREACHED();
231 callback.Run(FilePath()); 231 callback.Run(FilePath());
232 } 232 }
233 233
234 } // namespace chrome 234 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/media_storage_util.h ('k') | chrome/browser/media_gallery/removable_device_notifications_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698