OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "apps/saved_devices_service.h" | 5 #include "apps/saved_devices_service.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/saved_devices_service_factory.h" | 10 #include "apps/saved_devices_service_factory.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 persistent_devices_.begin(); | 151 persistent_devices_.begin(); |
152 it != persistent_devices_.end(); | 152 it != persistent_devices_.end(); |
153 ++it) { | 153 ++it) { |
154 if (it->vendor_id != device->vendor_id()) { | 154 if (it->vendor_id != device->vendor_id()) { |
155 continue; | 155 continue; |
156 } | 156 } |
157 if (it->product_id != device->product_id()) { | 157 if (it->product_id != device->product_id()) { |
158 continue; | 158 continue; |
159 } | 159 } |
160 if (!have_serial_number) { | 160 if (!have_serial_number) { |
161 scoped_refptr<UsbDeviceHandle> device_handle = device->Open(); | 161 if (!device->GetSerialNumber(&serial_number)) { |
162 if (!device_handle.get()) { | |
163 break; | |
164 } | |
165 if (!device_handle->GetSerial(&serial_number)) { | |
166 break; | 162 break; |
167 } | 163 } |
168 have_serial_number = true; | 164 have_serial_number = true; |
169 } | 165 } |
170 if (it->serial_number != serial_number) { | 166 if (it->serial_number != serial_number) { |
171 continue; | 167 continue; |
172 } | 168 } |
173 return true; | 169 return true; |
174 } | 170 } |
175 return false; | 171 return false; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 std::map<std::string, SavedDevices*>::const_iterator it = | 307 std::map<std::string, SavedDevices*>::const_iterator it = |
312 extension_id_to_saved_devices_.find(extension_id); | 308 extension_id_to_saved_devices_.find(extension_id); |
313 if (it != extension_id_to_saved_devices_.end()) { | 309 if (it != extension_id_to_saved_devices_.end()) { |
314 return it->second; | 310 return it->second; |
315 } | 311 } |
316 | 312 |
317 return NULL; | 313 return NULL; |
318 } | 314 } |
319 | 315 |
320 } // namespace apps | 316 } // namespace apps |
OLD | NEW |