| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_service.h" | 5 #include "chrome/browser/usb/usb_service.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
| 25 // handler calls should return without handling any events. | 25 // handler calls should return without handling any events. | 
| 26 class UsbEventHandler : public base::PlatformThread::Delegate { | 26 class UsbEventHandler : public base::PlatformThread::Delegate { | 
| 27  public: | 27  public: | 
| 28   explicit UsbEventHandler(PlatformUsbContext context) | 28   explicit UsbEventHandler(PlatformUsbContext context) | 
| 29       : running_(true), context_(context) { | 29       : running_(true), context_(context) { | 
| 30     base::PlatformThread::CreateNonJoinable(0, this); | 30     base::PlatformThread::CreateNonJoinable(0, this); | 
| 31   } | 31   } | 
| 32 | 32 | 
| 33   virtual ~UsbEventHandler() {} | 33   virtual ~UsbEventHandler() {} | 
| 34 | 34 | 
| 35   virtual void ThreadMain() { | 35   virtual void ThreadMain() OVERRIDE { | 
| 36     base::PlatformThread::SetName("UsbEventHandler"); | 36     base::PlatformThread::SetName("UsbEventHandler"); | 
| 37 | 37 | 
| 38     DLOG(INFO) << "UsbEventHandler started."; | 38     DLOG(INFO) << "UsbEventHandler started."; | 
| 39     while (running_) { | 39     while (running_) { | 
| 40       libusb_handle_events(context_); | 40       libusb_handle_events(context_); | 
| 41     } | 41     } | 
| 42     DLOG(INFO) << "UsbEventHandler shutting down."; | 42     DLOG(INFO) << "UsbEventHandler shutting down."; | 
| 43     libusb_exit(context_); | 43     libusb_exit(context_); | 
| 44 | 44 | 
| 45     delete this; | 45     delete this; | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 180     if (libusb_open(device, &handle)) { | 180     if (libusb_open(device, &handle)) { | 
| 181       LOG(WARNING) << "Could not open device."; | 181       LOG(WARNING) << "Could not open device."; | 
| 182       return NULL; | 182       return NULL; | 
| 183     } | 183     } | 
| 184 | 184 | 
| 185     UsbDevice* wrapper = new UsbDevice(this, handle); | 185     UsbDevice* wrapper = new UsbDevice(this, handle); | 
| 186     devices_[device] = wrapper; | 186     devices_[device] = wrapper; | 
| 187   } | 187   } | 
| 188   return devices_[device]; | 188   return devices_[device]; | 
| 189 } | 189 } | 
| OLD | NEW | 
|---|