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

Unified Diff: components/usb_service/usb_device.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/usb_service/usb_device.h ('k') | components/usb_service/usb_device_handle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/usb_service/usb_device.cc
diff --git a/chrome/browser/usb/usb_device.cc b/components/usb_service/usb_device.cc
similarity index 81%
rename from chrome/browser/usb/usb_device.cc
rename to components/usb_service/usb_device.cc
index 8f71d507ef6e8509736db8fed5342e224470a9cd..1bdf8899dfd0036c535cc0ff00035966ccc2a1e2 100644
--- a/chrome/browser/usb/usb_device.cc
+++ b/components/usb_service/usb_device.cc
@@ -2,13 +2,13 @@
// 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_device.h"
+#include "components/usb_service/usb_device.h"
#include <algorithm>
#include "base/stl_util.h"
-#include "chrome/browser/usb/usb_context.h"
-#include "chrome/browser/usb/usb_device_handle.h"
+#include "components/usb_service/usb_context.h"
+#include "components/usb_service/usb_device_handle.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/libusb/src/libusb/libusb.h"
@@ -26,19 +26,20 @@ namespace {
void OnRequestUsbAccessReplied(
const base::Callback<void(bool success)>& callback,
bool success) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- base::Bind(callback, success));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE, base::Bind(callback, success));
}
#endif // defined(OS_CHROMEOS)
} // namespace
-UsbDevice::UsbDevice(
- scoped_refptr<UsbContext> context,
- PlatformUsbDevice platform_device,
- uint16 vendor_id,
- uint16 product_id,
- uint32 unique_id)
+namespace usb_service {
+
+UsbDevice::UsbDevice(scoped_refptr<UsbContext> context,
+ PlatformUsbDevice platform_device,
+ uint16 vendor_id,
+ uint16 product_id,
+ uint32 unique_id)
: platform_device_(platform_device),
vendor_id_(vendor_id),
product_id_(product_id),
@@ -58,9 +59,8 @@ UsbDevice::UsbDevice()
UsbDevice::~UsbDevice() {
DCHECK(thread_checker_.CalledOnValidThread());
- for (HandlesVector::iterator it = handles_.begin();
- it != handles_.end();
- ++it) {
+ for (HandlesVector::iterator it = handles_.begin(); it != handles_.end();
+ ++it) {
(*it)->InternalClose();
}
STLClearObject(&handles_);
@@ -86,7 +86,8 @@ void UsbDevice::RequestUsbAcess(
}
BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
+ BrowserThread::UI,
+ FROM_HERE,
base::Bind(&chromeos::PermissionBrokerClient::RequestUsbAccess,
base::Unretained(client),
this->vendor_id_,
@@ -117,9 +118,8 @@ scoped_refptr<UsbDeviceHandle> UsbDevice::Open() {
bool UsbDevice::Close(scoped_refptr<UsbDeviceHandle> handle) {
DCHECK(thread_checker_.CalledOnValidThread());
- for (HandlesVector::iterator it = handles_.begin();
- it != handles_.end();
- ++it) {
+ for (HandlesVector::iterator it = handles_.begin(); it != handles_.end();
+ ++it) {
if (*it == handle) {
(*it)->InternalClose();
handles_.erase(it);
@@ -146,9 +146,11 @@ void UsbDevice::OnDisconnect() {
HandlesVector handles;
swap(handles, handles_);
for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it =
- handles.begin();
- it != handles.end();
- ++it) {
+ handles.begin();
+ it != handles.end();
+ ++it) {
(*it)->InternalClose();
}
}
+
+} // namespace usb_service
« no previous file with comments | « components/usb_service/usb_device.h ('k') | components/usb_service/usb_device_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698