Chromium Code Reviews| 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 // 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 case USB_MTP: | 94 case USB_MTP: |
| 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 // The device ID is always generated by MakeDeviceId, so we should always | |
|
James Hawkins
2012/08/29 22:46:51
nit: Don't use pronouns (we) in comments; pronouns
thorogood
2012/08/30 01:36:28
Thanks, although this has been fixed by another pa
| |
| 105 // be able to find a valid prefix delimited by ':'. | |
| 104 size_t prefix_length = device_id.find_first_of(':'); | 106 size_t prefix_length = device_id.find_first_of(':'); |
| 105 std::string prefix = device_id.substr(0, prefix_length); | 107 DCHECK(prefix_length != std::string::npos); |
| 108 std::string prefix = device_id.substr(0, prefix_length + 1); | |
|
James Hawkins
2012/08/29 22:46:51
What this a bug previously?
thorogood
2012/08/30 01:36:28
Yes. It's been fixed by another patch, so you can
| |
| 106 | 109 |
| 107 Type found_type; | 110 Type found_type; |
| 108 if (prefix == kUsbMassStorageWithDCIMPrefix) { | 111 if (prefix == kUsbMassStorageWithDCIMPrefix) { |
| 109 found_type = USB_MASS_STORAGE_WITH_DCIM; | 112 found_type = USB_MASS_STORAGE_WITH_DCIM; |
| 110 } else if (prefix == kUsbMassStorageNoDCIMPrefix) { | 113 } else if (prefix == kUsbMassStorageNoDCIMPrefix) { |
| 111 found_type = USB_MASS_STORAGE_NO_DCIM; | 114 found_type = USB_MASS_STORAGE_NO_DCIM; |
| 112 } else if (prefix == kOtherMassStoragePrefix) { | 115 } else if (prefix == kOtherMassStoragePrefix) { |
| 113 found_type = OTHER_MASS_STORAGE; | 116 found_type = OTHER_MASS_STORAGE; |
| 114 } else if (prefix == kUsbMtpPrefix) { | 117 } else if (prefix == kUsbMtpPrefix) { |
| 115 found_type = USB_MTP; | 118 found_type = USB_MTP; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 void MediaStorageUtil::FindUSBDeviceById(const std::string& unique_id, | 227 void MediaStorageUtil::FindUSBDeviceById(const std::string& unique_id, |
| 225 const FilePathCallback& callback) { | 228 const FilePathCallback& callback) { |
| 226 // TODO(vandebo) This needs to be implemented per platform. | 229 // TODO(vandebo) This needs to be implemented per platform. |
| 227 // Type is USB_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted | 230 // Type is USB_MASS_STORAGE_NO_DCIM, so it's a device possibly mounted |
| 228 // somewhere... | 231 // somewhere... |
| 229 NOTREACHED(); | 232 NOTREACHED(); |
| 230 callback.Run(FilePath()); | 233 callback.Run(FilePath()); |
| 231 } | 234 } |
| 232 | 235 |
| 233 } // namespace chrome | 236 } // namespace chrome |
| OLD | NEW |