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

Side by Side Diff: components/usb_service/usb_interface.cc

Issue 258783002: Extracted UsbService as interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed chromeos issue. Created 6 years, 7 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
« no previous file with comments | « components/usb_service/usb_interface.h ('k') | components/usb_service/usb_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 config_ = NULL;
156 }
157
152 UsbConfigDescriptor::~UsbConfigDescriptor() { 158 UsbConfigDescriptor::~UsbConfigDescriptor() {
153 if (config_ != NULL) { 159 if (config_ != NULL) {
154 libusb_free_config_descriptor(config_); 160 libusb_free_config_descriptor(config_);
155 config_ = NULL; 161 config_ = NULL;
156 } 162 }
157 } 163 }
158 164
159 size_t UsbConfigDescriptor::GetNumInterfaces() const { 165 size_t UsbConfigDescriptor::GetNumInterfaces() const {
160 return config_->bNumInterfaces; 166 return config_->bNumInterfaces;
161 } 167 }
162 168
163 scoped_refptr<const UsbInterfaceDescriptor> UsbConfigDescriptor::GetInterface( 169 scoped_refptr<const UsbInterfaceDescriptor> UsbConfigDescriptor::GetInterface(
164 size_t index) const { 170 size_t index) const {
165 return new UsbInterfaceDescriptor(this, &config_->interface[index]); 171 return new UsbInterfaceDescriptor(this, &config_->interface[index]);
166 } 172 }
167 173
168 } // namespace usb_service 174 } // namespace usb_service
OLDNEW
« no previous file with comments | « components/usb_service/usb_interface.h ('k') | components/usb_service/usb_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698