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

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

Issue 236203019: Move UsbService to its own component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move usb_service component symbols into usb_service namespace Created 6 years, 8 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_context.h ('k') | components/usb_service/usb_context_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_context.h" 5 #include "components/usb_service/usb_context.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "third_party/libusb/src/libusb/interrupt.h" 10 #include "third_party/libusb/src/libusb/interrupt.h"
11 #include "third_party/libusb/src/libusb/libusb.h" 11 #include "third_party/libusb/src/libusb/libusb.h"
12 12
13 namespace usb_service {
14
13 // The UsbEventHandler works around a design flaw in the libusb interface. There 15 // The UsbEventHandler works around a design flaw in the libusb interface. There
14 // is currently no way to signal to libusb that any caller into one of the event 16 // is currently no way to signal to libusb that any caller into one of the event
15 // handler calls should return without handling any events. 17 // handler calls should return without handling any events.
16 class UsbContext::UsbEventHandler : public base::PlatformThread::Delegate { 18 class UsbContext::UsbEventHandler : public base::PlatformThread::Delegate {
17 public: 19 public:
18 explicit UsbEventHandler(libusb_context* context); 20 explicit UsbEventHandler(libusb_context* context);
19 virtual ~UsbEventHandler(); 21 virtual ~UsbEventHandler();
20 22
21 // base::PlatformThread::Delegate 23 // base::PlatformThread::Delegate
22 virtual void ThreadMain() OVERRIDE; 24 virtual void ThreadMain() OVERRIDE;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 event_handler_ = new UsbEventHandler(context_); 66 event_handler_ = new UsbEventHandler(context_);
65 } 67 }
66 68
67 UsbContext::~UsbContext() { 69 UsbContext::~UsbContext() {
68 // destruction of UsbEventHandler is a blocking operation. 70 // destruction of UsbEventHandler is a blocking operation.
69 DCHECK(thread_checker_.CalledOnValidThread()); 71 DCHECK(thread_checker_.CalledOnValidThread());
70 delete event_handler_; 72 delete event_handler_;
71 event_handler_ = NULL; 73 event_handler_ = NULL;
72 libusb_exit(context_); 74 libusb_exit(context_);
73 } 75 }
76
77 } // namespace usb_service
OLDNEW
« no previous file with comments | « components/usb_service/usb_context.h ('k') | components/usb_service/usb_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698