summaryrefslogtreecommitdiffstats
path: root/chrome/browser/usb/usb_context.cc
diff options
context:
space:
mode:
authornhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 04:14:54 +0000
committernhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-02 04:14:54 +0000
commit62a021e79265ca4bd522bef4e8cf193dd4c100d4 (patch)
treef9f40195a34a600247bc8977ba9e3581749143e1 /chrome/browser/usb/usb_context.cc
parente6bf5ebe6e6038d1e997407e7737d76ca1a8e831 (diff)
downloadchromium_src-62a021e79265ca4bd522bef4e8cf193dd4c100d4.zip
chromium_src-62a021e79265ca4bd522bef4e8cf193dd4c100d4.tar.gz
chromium_src-62a021e79265ca4bd522bef4e8cf193dd4c100d4.tar.bz2
Revert 215174 "Create a refcounted usb context wrapper."
Probably this causes UsbContextTest.GracefulShutdown failure on some bots. http://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%283%29/builds/23652 http://build.chromium.org/p/chromium.mac/builders/Mac10.6%20Tests%20%282%29/builds/41018 > Create a refcounted usb context wrapper. > This will be also used when we introduce UsbDevice. > > BUG=223817 > > Review URL: https://chromiumcodereview.appspot.com/20012002 TBR=ikarienator@chromium.org Review URL: https://codereview.chromium.org/21720002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215199 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/usb/usb_context.cc')
-rw-r--r--chrome/browser/usb/usb_context.cc73
1 files changed, 0 insertions, 73 deletions
diff --git a/chrome/browser/usb/usb_context.cc b/chrome/browser/usb/usb_context.cc
deleted file mode 100644
index 3b0811a..0000000
--- a/chrome/browser/usb/usb_context.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/usb/usb_context.h"
-
-#include "base/logging.h"
-#include "base/synchronization/waitable_event.h"
-#include "base/threading/platform_thread.h"
-#include "content/public/browser/browser_thread.h"
-#include "third_party/libusb/src/libusb/interrupt.h"
-#include "third_party/libusb/src/libusb/libusb.h"
-
-// The UsbEventHandler works around a design flaw in the libusb interface. There
-// is currently no way to signal to libusb that any caller into one of the event
-// handler calls should return without handling any events.
-class UsbContext::UsbEventHandler : public base::PlatformThread::Delegate {
- public:
- explicit UsbEventHandler(libusb_context* context);
- virtual ~UsbEventHandler();
-
- // base::PlatformThread::Delegate
- virtual void ThreadMain() OVERRIDE;
-
- private:
- volatile bool running_;
- libusb_context* context_;
- base::PlatformThreadHandle thread_handle_;
- base::WaitableEvent start_polling_;
- DISALLOW_COPY_AND_ASSIGN(UsbEventHandler);
-};
-
-UsbContext::UsbEventHandler::UsbEventHandler(libusb_context* context)
- : running_(true),
- context_(context),
- thread_handle_(0),
- start_polling_(false, false) {
- DCHECK(base::PlatformThread::Create(0, this, &thread_handle_)) <<
- "Failed to create USB IO handling thread.";
- start_polling_.Wait();
-}
-
-UsbContext::UsbEventHandler::~UsbEventHandler() {
- running_ = false;
- // Spreading running_ to the UsbEventHandler thread.
- base::subtle::MemoryBarrier();
- libusb_interrupt_handle_event(context_);
- base::PlatformThread::Join(thread_handle_);
-}
-
-void UsbContext::UsbEventHandler::ThreadMain() {
- base::PlatformThread::SetName("UsbEventHandler");
- VLOG(1) << "UsbEventHandler started.";
- if (running_) {
- start_polling_.Signal();
- libusb_handle_events(context_);
- }
- while (running_)
- libusb_handle_events(context_);
- VLOG(1) << "UsbEventHandler shutting down.";
-}
-
-UsbContext::UsbContext() : context_(NULL) {
- CHECK_EQ(0, libusb_init(&context_)) << "Cannot initialize libusb";
- event_handler_.reset(new UsbEventHandler(context_));
-}
-
-UsbContext::~UsbContext() {
- // destruction of UsbEventHandler is a blocking operation.
- CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
- event_handler_.reset(NULL);
- libusb_exit(context_);
-}