| 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 "components/usb_service/usb_interface.h" | 5 #include "components/usb_service/usb_interface.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/libusb/src/libusb/libusb.h" | 8 #include "third_party/libusb/src/libusb/libusb.h" |
| 9 | 9 |
| 10 namespace usb_service { | 10 namespace usb_service { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 scoped_refptr<const UsbInterfaceAltSettingDescriptor> | 142 scoped_refptr<const UsbInterfaceAltSettingDescriptor> |
| 143 UsbInterfaceDescriptor::GetAltSetting(size_t index) const { | 143 UsbInterfaceDescriptor::GetAltSetting(size_t index) const { |
| 144 return new UsbInterfaceAltSettingDescriptor(config_, | 144 return new UsbInterfaceAltSettingDescriptor(config_, |
| 145 &interface_->altsetting[index]); | 145 &interface_->altsetting[index]); |
| 146 } | 146 } |
| 147 | 147 |
| 148 UsbConfigDescriptor::UsbConfigDescriptor(PlatformUsbConfigDescriptor config) | 148 UsbConfigDescriptor::UsbConfigDescriptor(PlatformUsbConfigDescriptor config) |
| 149 : config_(config) { | 149 : config_(config) { |
| 150 } | 150 } |
| 151 | 151 |
| 152 // TODO(zvorygin): Used for tests only. Should be removed when |
| 153 // all interfaces are extracted properly. |
| 154 UsbConfigDescriptor::UsbConfigDescriptor() { |
| 155 } |
| 156 |
| 152 UsbConfigDescriptor::~UsbConfigDescriptor() { | 157 UsbConfigDescriptor::~UsbConfigDescriptor() { |
| 153 if (config_ != NULL) { | 158 if (config_ != NULL) { |
| 154 libusb_free_config_descriptor(config_); | 159 libusb_free_config_descriptor(config_); |
| 155 config_ = NULL; | 160 config_ = NULL; |
| 156 } | 161 } |
| 157 } | 162 } |
| 158 | 163 |
| 159 size_t UsbConfigDescriptor::GetNumInterfaces() const { | 164 size_t UsbConfigDescriptor::GetNumInterfaces() const { |
| 160 return config_->bNumInterfaces; | 165 return config_->bNumInterfaces; |
| 161 } | 166 } |
| 162 | 167 |
| 163 scoped_refptr<const UsbInterfaceDescriptor> UsbConfigDescriptor::GetInterface( | 168 scoped_refptr<const UsbInterfaceDescriptor> UsbConfigDescriptor::GetInterface( |
| 164 size_t index) const { | 169 size_t index) const { |
| 165 return new UsbInterfaceDescriptor(this, &config_->interface[index]); | 170 return new UsbInterfaceDescriptor(this, &config_->interface[index]); |
| 166 } | 171 } |
| 167 | 172 |
| 168 } // namespace usb_service | 173 } // namespace usb_service |
| OLD | NEW |