OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/usb/usb_device_handle.h" | 5 #include "chrome/browser/usb/usb_device_handle.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 int size = libusb_get_string_descriptor( | 369 int size = libusb_get_string_descriptor( |
370 handle_, 0, 0, | 370 handle_, 0, 0, |
371 reinterpret_cast<unsigned char*>(&langid[0]), sizeof(langid)); | 371 reinterpret_cast<unsigned char*>(&langid[0]), sizeof(langid)); |
372 if (size < 0) | 372 if (size < 0) |
373 return false; | 373 return false; |
374 | 374 |
375 int language_count = (size - 2) / 2; | 375 int language_count = (size - 2) / 2; |
376 | 376 |
377 for (int i = 1; i <= language_count; ++i) { | 377 for (int i = 1; i <= language_count; ++i) { |
378 // Get the string using language ID. | 378 // Get the string using language ID. |
379 char16 text[256] = { 0 }; | 379 base::char16 text[256] = { 0 }; |
380 size = libusb_get_string_descriptor( | 380 size = libusb_get_string_descriptor( |
381 handle_, desc.iSerialNumber, langid[i], | 381 handle_, desc.iSerialNumber, langid[i], |
382 reinterpret_cast<unsigned char*>(&text[0]), sizeof(text)); | 382 reinterpret_cast<unsigned char*>(&text[0]), sizeof(text)); |
383 if (size <= 2) | 383 if (size <= 2) |
384 continue; | 384 continue; |
385 if ((text[0] >> 8) != LIBUSB_DT_STRING) | 385 if ((text[0] >> 8) != LIBUSB_DT_STRING) |
386 continue; | 386 continue; |
387 if ((text[0] & 255) > size) | 387 if ((text[0] & 255) > size) |
388 continue; | 388 continue; |
389 | 389 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 } | 594 } |
595 | 595 |
596 // Attempt-release all the interfaces. | 596 // Attempt-release all the interfaces. |
597 // It will be retained until the transfer cancellation is finished. | 597 // It will be retained until the transfer cancellation is finished. |
598 claimed_interfaces_.clear(); | 598 claimed_interfaces_.clear(); |
599 | 599 |
600 // Cannot close device handle here. Need to wait for libusb_cancel_transfer to | 600 // Cannot close device handle here. Need to wait for libusb_cancel_transfer to |
601 // finish. | 601 // finish. |
602 device_ = NULL; | 602 device_ = NULL; |
603 } | 603 } |
OLD | NEW |