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

Side by Side Diff: chrome/browser/devtools/adb/android_usb_device.cc

Issue 18593002: Usb backend refactor step 2: Separate Usb Device Handle and Usb Device (deprecate) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Separate Usb Device Handle and Usb Device Created 7 years, 5 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
OLDNEW
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/devtools/adb/android_usb_device.h" 5 #include "chrome/browser/devtools/adb/android_usb_device.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/devtools/adb/android_rsa.h" 10 #include "chrome/browser/devtools/adb/android_rsa.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 AdbMessage::~AdbMessage() { 197 AdbMessage::~AdbMessage() {
198 } 198 }
199 199
200 // static 200 // static
201 void AndroidUsbDevice::Enumerate(Profile* profile, Devices* devices) { 201 void AndroidUsbDevice::Enumerate(Profile* profile, Devices* devices) {
202 UsbService* service = 202 UsbService* service =
203 UsbServiceFactory::GetInstance()->GetForProfile(profile); 203 UsbServiceFactory::GetInstance()->GetForProfile(profile);
204 204
205 // Enumerate usb devices. 205 // Enumerate usb devices.
206 std::vector<scoped_refptr<UsbDevice> > usb_devices; 206 std::vector<int> usb_devices;
207 service->EnumerateDevices(&usb_devices); 207 service->GetDevices(&usb_devices);
208 for (size_t i = 0; i < usb_devices.size(); ++i) { 208 for (size_t i = 0; i < usb_devices.size(); ++i) {
209 scoped_refptr<UsbDevice> usb_device = usb_devices[i]; 209 int usb_device_id = usb_devices[i];
210 210 scoped_refptr<UsbDevice> usb_device = service->OpenDevice(usb_device_id);
211 // Enumerate device interfaces. 211 // Enumerate device interfaces.
212 scoped_refptr<UsbConfigDescriptor> config = new UsbConfigDescriptor(); 212 scoped_refptr<UsbConfigDescriptor> config = new UsbConfigDescriptor();
213 usb_device->ListInterfaces(config.get(), base::Bind(&BoolNoop)); 213 usb_device->ListInterfaces(config.get(), base::Bind(&BoolNoop));
214 for (size_t i = 0; i < config->GetNumInterfaces(); ++i) 214 for (size_t i = 0; i < config->GetNumInterfaces(); ++i)
215 ClaimInterface(profile, usb_device, config->GetInterface(i), devices); 215 ClaimInterface(profile, usb_device, config->GetInterface(i), devices);
216 } 216 }
217 } 217 }
218 218
219 AndroidUsbDevice::AndroidUsbDevice(Profile* profile, 219 AndroidUsbDevice::AndroidUsbDevice(Profile* profile,
220 scoped_refptr<UsbDevice> usb_device, 220 scoped_refptr<UsbDevice> usb_device,
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 it != sockets_.end(); ++it) { 468 it != sockets_.end(); ++it) {
469 it->second->Terminated(); 469 it->second->Terminated();
470 } 470 }
471 usb_device_->ReleaseInterface(1, base::Bind(&BoolNoop)); 471 usb_device_->ReleaseInterface(1, base::Bind(&BoolNoop));
472 usb_device_->Close(base::Bind(&Noop)); 472 usb_device_->Close(base::Bind(&Noop));
473 } 473 }
474 474
475 void AndroidUsbDevice::SocketDeleted(uint32 socket_id) { 475 void AndroidUsbDevice::SocketDeleted(uint32 socket_id) {
476 sockets_.erase(socket_id); 476 sockets_.erase(socket_id);
477 } 477 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/usb/usb_api.h » ('j') | chrome/browser/usb/usb_device.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698