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

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: nits 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return std::string(kUsbMtpPrefix) + unique_id; 95 return std::string(kUsbMtpPrefix) + unique_id;
96 } 96 }
97 NOTREACHED(); 97 NOTREACHED();
98 return std::string(); 98 return std::string();
99 } 99 }
100 100
101 // static 101 // static
102 bool MediaStorageUtil::CrackDeviceId(const std::string& device_id, 102 bool MediaStorageUtil::CrackDeviceId(const std::string& device_id,
103 Type* type, std::string* unique_id) { 103 Type* type, std::string* unique_id) {
104 size_t prefix_length = device_id.find_first_of(':'); 104 size_t prefix_length = device_id.find_first_of(':');
105 std::string prefix = device_id.substr(0, prefix_length); 105 std::string prefix = device_id.substr(0, prefix_length + 1);
Lei Zhang 2012/08/27 23:17:15 You'll need to sync past r153569 and resolve this.
vandebo (ex-Chrome) 2012/08/27 23:31:11 Done.
106 106
107 Type found_type; 107 Type found_type;
108 if (prefix == kUsbMassStorageWithDCIMPrefix) { 108 if (prefix == kUsbMassStorageWithDCIMPrefix) {
109 found_type = USB_MASS_STORAGE_WITH_DCIM; 109 found_type = USB_MASS_STORAGE_WITH_DCIM;
110 } else if (prefix == kUsbMassStorageNoDCIMPrefix) { 110 } else if (prefix == kUsbMassStorageNoDCIMPrefix) {
111 found_type = USB_MASS_STORAGE_NO_DCIM; 111 found_type = USB_MASS_STORAGE_NO_DCIM;
112 } else if (prefix == kOtherMassStoragePrefix) { 112 } else if (prefix == kOtherMassStoragePrefix) {
113 found_type = OTHER_MASS_STORAGE; 113 found_type = OTHER_MASS_STORAGE;
114 } else if (prefix == kUsbMtpPrefix) { 114 } else if (prefix == kUsbMtpPrefix) {
115 found_type = USB_MTP; 115 found_type = USB_MTP;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return; 148 return;
149 } 149 }
150 150
151 switch (type) { 151 switch (type) {
152 case USB_MTP: // Fall through 152 case USB_MTP: // Fall through
153 case USB_MASS_STORAGE_WITH_DCIM: 153 case USB_MASS_STORAGE_WITH_DCIM:
154 // We should be able to find media devices in SystemMonitor. 154 // We should be able to find media devices in SystemMonitor.
155 callback.Run(!FindRemovableStorageLocationById(device_id).empty()); 155 callback.Run(!FindRemovableStorageLocationById(device_id).empty());
156 break; 156 break;
157 case USB_MASS_STORAGE_NO_DCIM: 157 case USB_MASS_STORAGE_NO_DCIM:
158 FindUSBDeviceById(unique_id, 158 FindUSBDeviceById(device_id,
159 base::Bind(&EmptyPathIsFalseCallback, callback)); 159 base::Bind(&EmptyPathIsFalseCallback, callback));
160 break; 160 break;
161 case OTHER_MASS_STORAGE: 161 case OTHER_MASS_STORAGE:
162 // For this type, the unique_id is the path. 162 // For this type, the unique_id is the path.
163 BrowserThread::PostTask( 163 BrowserThread::PostTask(
164 BrowserThread::FILE, FROM_HERE, 164 BrowserThread::FILE, FROM_HERE,
165 base::Bind(&ValidatePathOnFileThread, 165 base::Bind(&ValidatePathOnFileThread,
166 FilePath::FromUTF8Unsafe(unique_id), 166 FilePath::FromUTF8Unsafe(unique_id),
167 base::Bind(&EmptyPathIsFalseCallback, callback))); 167 base::Bind(&EmptyPathIsFalseCallback, callback)));
168 break; 168 break;
(...skipping 25 matching lines...) Expand all
194 Type type; 194 Type type;
195 std::string unique_id; 195 std::string unique_id;
196 if (!CrackDeviceId(device_id, &type, &unique_id)) 196 if (!CrackDeviceId(device_id, &type, &unique_id))
197 callback.Run(FilePath()); 197 callback.Run(FilePath());
198 198
199 switch (type) { 199 switch (type) {
200 case USB_MTP: 200 case USB_MTP:
201 callback.Run(FilePath()); 201 callback.Run(FilePath());
202 break; 202 break;
203 case USB_MASS_STORAGE_NO_DCIM: 203 case USB_MASS_STORAGE_NO_DCIM:
204 FindUSBDeviceById(unique_id, callback); 204 FindUSBDeviceById(device_id, callback);
205 break; 205 break;
206 case OTHER_MASS_STORAGE: 206 case OTHER_MASS_STORAGE:
207 // For this type, the unique_id is the path. 207 // For this type, the unique_id is the path.
208 BrowserThread::PostTask( 208 BrowserThread::PostTask(
209 BrowserThread::FILE, FROM_HERE, 209 BrowserThread::FILE, FROM_HERE,
210 base::Bind(&ValidatePathOnFileThread, 210 base::Bind(&ValidatePathOnFileThread,
211 FilePath::FromUTF8Unsafe(unique_id), callback)); 211 FilePath::FromUTF8Unsafe(unique_id), callback));
212 break; 212 break;
213 case USB_MASS_STORAGE_WITH_DCIM: 213 case USB_MASS_STORAGE_WITH_DCIM:
214 callback.Run(FilePath(FindRemovableStorageLocationById(device_id))); 214 callback.Run(FilePath(FindRemovableStorageLocationById(device_id)));
215 break; 215 break;
216 } 216 }
217 NOTREACHED(); 217 NOTREACHED();
218 callback.Run(FilePath()); 218 callback.Run(FilePath());
219 } 219 }
220 220
221 MediaStorageUtil::MediaStorageUtil() {} 221 MediaStorageUtil::MediaStorageUtil() {}
222 222
223 // static 223 // static
224 void MediaStorageUtil::FindUSBDeviceById(const std::string& unique_id, 224 void MediaStorageUtil::FindUSBDeviceById(const std::string& device_id,
225 const FilePathCallback& callback) { 225 const FilePathCallback& callback) {
226 // TODO(vandebo) This needs to be implemented per platform. 226 // TODO(vandebo) This needs to be implemented per platform.
227 // Type is USB_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted 227 // Type is USB_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted
228 // somewhere... 228 // somewhere...
229 NOTREACHED(); 229 NOTREACHED();
230 callback.Run(FilePath()); 230 callback.Run(FilePath());
231 } 231 }
232 232
233 } // namespace chrome 233 } // 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