summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreillyg <reillyg@chromium.org>2014-09-03 17:57:56 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-04 01:03:27 +0000
commitd77718de5c3963cf0fe31e59c27c3e2aebfb26cb (patch)
tree65a996cddf74653fa2b4d1c3d583110eaa8132cf
parent6b0fbe4cbbdd357a17c8a72f92535403fa50515a (diff)
downloadchromium_src-d77718de5c3963cf0fe31e59c27c3e2aebfb26cb.zip
chromium_src-d77718de5c3963cf0fe31e59c27c3e2aebfb26cb.tar.gz
chromium_src-d77718de5c3963cf0fe31e59c27c3e2aebfb26cb.tar.bz2
Merge components/usb_service into device/usb.
Unify these two parts of out USB device support. The //device tree is the cannonical location for hardware device APIs. BUG= Review URL: https://codereview.chromium.org/497363004 Cr-Commit-Position: refs/heads/master@{#293246}
-rw-r--r--BUILD.gn8
-rw-r--r--chrome/browser/BUILD.gn2
-rw-r--r--chrome/browser/DEPS2
-rw-r--r--chrome/browser/chrome_device_client.cc6
-rw-r--r--chrome/browser/chrome_device_client.h2
-rw-r--r--chrome/browser/devtools/device/usb/android_usb_browsertest.cc35
-rw-r--r--chrome/browser/devtools/device/usb/android_usb_device.cc49
-rw-r--r--chrome/browser/devtools/device/usb/android_usb_device.h22
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--components/BUILD.gn2
-rw-r--r--components/components.gyp1
-rw-r--r--components/components_tests.gyp12
-rw-r--r--components/usb_service.gypi56
-rw-r--r--components/usb_service/OWNERS3
-rw-r--r--components/usb_service/usb_service_export.h29
-rw-r--r--device/core/device_client.cc2
-rw-r--r--device/core/device_client.h8
-rw-r--r--device/device_tests.gyp3
-rw-r--r--device/test/DEPS1
-rw-r--r--device/test/usb_test_gadget.h8
-rw-r--r--device/test/usb_test_gadget_impl.cc9
-rw-r--r--device/usb/BUILD.gn25
-rw-r--r--device/usb/DEPS7
-rw-r--r--device/usb/OWNERS7
-rw-r--r--device/usb/usb.gyp32
-rw-r--r--device/usb/usb_context.cc (renamed from components/usb_service/usb_context.cc)15
-rw-r--r--device/usb/usb_context.h (renamed from components/usb_service/usb_context.h)14
-rw-r--r--device/usb/usb_context_unittest.cc (renamed from components/usb_service/usb_context_unittest.cc)7
-rw-r--r--device/usb/usb_device.h (renamed from components/usb_service/usb_device.h)14
-rw-r--r--device/usb/usb_device_filter.cc (renamed from components/usb_service/usb_device_filter.cc)10
-rw-r--r--device/usb/usb_device_filter.h (renamed from components/usb_service/usb_device_filter.h)13
-rw-r--r--device/usb/usb_device_filter_unittest.cc (renamed from components/usb_service/usb_device_filter_unittest.cc)22
-rw-r--r--device/usb/usb_device_handle.h (renamed from components/usb_service/usb_device_handle.h)16
-rw-r--r--device/usb/usb_device_handle_impl.cc (renamed from components/usb_service/usb_device_handle_impl.cc)47
-rw-r--r--device/usb/usb_device_handle_impl.h (renamed from components/usb_service/usb_device_handle_impl.h)14
-rw-r--r--device/usb/usb_device_impl.cc (renamed from components/usb_service/usb_device_impl.cc)19
-rw-r--r--device/usb/usb_device_impl.h (renamed from components/usb_service/usb_device_impl.h)12
-rw-r--r--device/usb/usb_error.cc (renamed from components/usb_service/usb_error.cc)8
-rw-r--r--device/usb/usb_error.h (renamed from components/usb_service/usb_error.h)12
-rw-r--r--device/usb/usb_interface.h (renamed from components/usb_service/usb_interface.h)20
-rw-r--r--device/usb/usb_interface_impl.cc (renamed from components/usb_service/usb_interface_impl.cc)12
-rw-r--r--device/usb/usb_interface_impl.h (renamed from components/usb_service/usb_interface_impl.h)15
-rw-r--r--device/usb/usb_service.h (renamed from components/usb_service/usb_service.h)13
-rw-r--r--device/usb/usb_service_impl.cc (renamed from components/usb_service/usb_service_impl.cc)26
-rw-r--r--device/usb/usb_service_unittest.cc6
-rw-r--r--extensions/browser/BUILD.gn2
-rw-r--r--extensions/browser/api/usb/DEPS4
-rw-r--r--extensions/browser/api/usb/usb_api.cc85
-rw-r--r--extensions/browser/api/usb/usb_api.h42
-rw-r--r--extensions/browser/api/usb/usb_apitest.cc58
-rw-r--r--extensions/browser/api/usb/usb_device_resource.cc4
-rw-r--r--extensions/browser/api/usb/usb_device_resource.h8
-rw-r--r--extensions/browser/api/usb_private/DEPS1
-rw-r--r--extensions/browser/api/usb_private/usb_private_api.cc14
-rw-r--r--extensions/extensions.gyp2
-rw-r--r--extensions/shell/browser/DEPS2
-rw-r--r--extensions/shell/browser/shell_device_client.cc6
-rw-r--r--extensions/shell/browser/shell_device_client.h2
58 files changed, 410 insertions, 468 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 574f539..b15f69e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -36,7 +36,6 @@ group("root") {
"//crypto",
"//device/bluetooth",
"//device/nfc",
- "//device/usb",
"//extensions/browser",
"//extensions/common",
"//extensions/common/api",
@@ -237,4 +236,11 @@ group("root") {
"//ui/ozone/demo",
]
}
+
+ # Non-mobile builds.
+ if (!is_android && !is_ios) {
+ deps += [
+ "//device/usb",
+ ]
+ }
}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 325ed73..d3dc853 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -447,8 +447,8 @@ static_library("browser") {
sources += rebase_path(gypi_values.chrome_browser_non_mobile_sources,
".", "//chrome")
deps += [
- "//components/usb_service",
"//device/core",
+ "//device/usb",
]
}
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index eb6d882..69b582a 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -70,7 +70,6 @@ include_rules = [
"+components/translate/core/browser",
"+components/translate/core/common",
"+components/url_matcher",
- "+components/usb_service",
"+components/user_manager",
"+components/user_prefs",
"+components/web_modal",
@@ -80,6 +79,7 @@ include_rules = [
"+courgette",
"+device/bluetooth",
"+device/core",
+ "+device/usb",
"+device/media_transfer_protocol",
"+extensions/browser",
"+extensions/common",
diff --git a/chrome/browser/chrome_device_client.cc b/chrome/browser/chrome_device_client.cc
index 941e777..f36d61f 100644
--- a/chrome/browser/chrome_device_client.cc
+++ b/chrome/browser/chrome_device_client.cc
@@ -5,15 +5,15 @@
#include "chrome/browser/chrome_device_client.h"
#include "base/logging.h"
-#include "components/usb_service/usb_service.h"
#include "content/public/browser/browser_thread.h"
+#include "device/usb/usb_service.h"
ChromeDeviceClient::ChromeDeviceClient() {}
ChromeDeviceClient::~ChromeDeviceClient() {}
-usb_service::UsbService* ChromeDeviceClient::GetUsbService() {
- return usb_service::UsbService::GetInstance(
+device::UsbService* ChromeDeviceClient::GetUsbService() {
+ return device::UsbService::GetInstance(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI));
}
diff --git a/chrome/browser/chrome_device_client.h b/chrome/browser/chrome_device_client.h
index d8814dc..9f08f96 100644
--- a/chrome/browser/chrome_device_client.h
+++ b/chrome/browser/chrome_device_client.h
@@ -18,7 +18,7 @@ class ChromeDeviceClient : device::DeviceClient {
virtual ~ChromeDeviceClient();
// device::DeviceClient implementation
- virtual usb_service::UsbService* GetUsbService() OVERRIDE;
+ virtual device::UsbService* GetUsbService() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ChromeDeviceClient);
diff --git a/chrome/browser/devtools/device/usb/android_usb_browsertest.cc b/chrome/browser/devtools/device/usb/android_usb_browsertest.cc
index 0a2934b..ca52178 100644
--- a/chrome/browser/devtools/device/usb/android_usb_browsertest.cc
+++ b/chrome/browser/devtools/device/usb/android_usb_browsertest.cc
@@ -10,16 +10,27 @@
#include "chrome/browser/devtools/device/usb/usb_device_provider.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
-#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_device_handle.h"
-#include "components/usb_service/usb_interface.h"
-#include "components/usb_service/usb_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h"
+#include "device/usb/usb_device.h"
+#include "device/usb/usb_device_handle.h"
+#include "device/usb/usb_interface.h"
+#include "device/usb/usb_service.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
-using namespace usb_service;
+using device::UsbConfigDescriptor;
+using device::UsbDevice;
+using device::UsbDeviceHandle;
+using device::UsbEndpointDescriptor;
+using device::UsbEndpointDirection;
+using device::UsbInterfaceDescriptor;
+using device::UsbInterfaceAltSettingDescriptor;
+using device::UsbService;
+using device::UsbSynchronizationType;
+using device::UsbTransferCallback;
+using device::UsbTransferType;
+using device::UsbUsageType;
namespace {
@@ -147,9 +158,9 @@ class MockUsbInterfaceAltSettingDescriptor
EXPECT_GT(static_cast<size_t>(2), index);
MockUsbEndpointDescriptor* result = new MockUsbEndpointDescriptor();
result->address_ = index + 1;
- result->usb_transfer_type_ = USB_TRANSFER_BULK;
- result->direction_ =
- ((index == 0) ? USB_DIRECTION_INBOUND : USB_DIRECTION_OUTBOUND);
+ result->usb_transfer_type_ = device::USB_TRANSFER_BULK;
+ result->direction_ = ((index == 0) ? device::USB_DIRECTION_INBOUND
+ : device::USB_DIRECTION_OUTBOUND);
result->maximum_packet_size_ = 1 << 20; // 1Mb maximum packet size
return result;
}
@@ -288,7 +299,7 @@ class MockUsbDeviceHandle : public UsbDeviceHandle {
const size_t length,
const unsigned int timeout,
const UsbTransferCallback& callback) OVERRIDE {
- if (direction == USB_DIRECTION_OUTBOUND) {
+ if (direction == device::USB_DIRECTION_OUTBOUND) {
if (remaining_body_length_ == 0) {
std::vector<uint32> header(6);
memcpy(&header[0], buffer->data(), length);
@@ -312,11 +323,11 @@ class MockUsbDeviceHandle : public UsbDeviceHandle {
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(callback,
- usb_service::USB_TRANSFER_COMPLETED,
+ device::USB_TRANSFER_COMPLETED,
scoped_refptr<net::IOBuffer>(),
0));
- } else if (direction == USB_DIRECTION_INBOUND) {
+ } else if (direction == device::USB_DIRECTION_INBOUND) {
queries_.push(Query(callback, make_scoped_refptr(buffer), length));
ProcessQueries();
}
@@ -408,7 +419,7 @@ class MockUsbDeviceHandle : public UsbDeviceHandle {
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(query.callback,
- usb_service::USB_TRANSFER_COMPLETED,
+ device::USB_TRANSFER_COMPLETED,
query.buffer,
query.size));
}
diff --git a/chrome/browser/devtools/device/usb/android_usb_device.cc b/chrome/browser/devtools/device/usb/android_usb_device.cc
index 51aed47..8ef9416 100644
--- a/chrome/browser/devtools/device/usb/android_usb_device.cc
+++ b/chrome/browser/devtools/device/usb/android_usb_device.cc
@@ -16,24 +16,24 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/devtools/device/usb/android_rsa.h"
#include "chrome/browser/devtools/device/usb/android_usb_socket.h"
-#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_interface.h"
-#include "components/usb_service/usb_service.h"
#include "content/public/browser/browser_thread.h"
#include "crypto/rsa_private_key.h"
#include "device/core/device_client.h"
+#include "device/usb/usb_device.h"
+#include "device/usb/usb_interface.h"
+#include "device/usb/usb_service.h"
#include "net/base/ip_endpoint.h"
#include "net/base/net_errors.h"
#include "net/socket/stream_socket.h"
-using usb_service::UsbConfigDescriptor;
-using usb_service::UsbDevice;
-using usb_service::UsbDeviceHandle;
-using usb_service::UsbInterfaceAltSettingDescriptor;
-using usb_service::UsbInterfaceDescriptor;
-using usb_service::UsbEndpointDescriptor;
-using usb_service::UsbService;
-using usb_service::UsbTransferStatus;
+using device::UsbConfigDescriptor;
+using device::UsbDevice;
+using device::UsbDeviceHandle;
+using device::UsbInterfaceAltSettingDescriptor;
+using device::UsbInterfaceDescriptor;
+using device::UsbEndpointDescriptor;
+using device::UsbService;
+using device::UsbTransferStatus;
namespace {
@@ -59,8 +59,7 @@ typedef std::set<scoped_refptr<UsbDevice> > UsbDeviceSet;
base::LazyInstance<std::vector<AndroidUsbDevice*> >::Leaky g_devices =
LAZY_INSTANCE_INITIALIZER;
-bool IsAndroidInterface(
- scoped_refptr<const usb_service::UsbInterfaceDescriptor> interface) {
+bool IsAndroidInterface(scoped_refptr<const UsbInterfaceDescriptor> interface) {
if (interface->GetNumAltSettings() == 0)
return false;
@@ -91,9 +90,9 @@ scoped_refptr<AndroidUsbDevice> ClaimInterface(
for (size_t i = 0; i < idesc->GetNumEndpoints(); ++i) {
scoped_refptr<const UsbEndpointDescriptor> edesc =
idesc->GetEndpoint(i);
- if (edesc->GetTransferType() != usb_service::USB_TRANSFER_BULK)
+ if (edesc->GetTransferType() != device::USB_TRANSFER_BULK)
continue;
- if (edesc->GetDirection() == usb_service::USB_DIRECTION_INBOUND)
+ if (edesc->GetDirection() == device::USB_DIRECTION_INBOUND)
inbound_address = edesc->GetAddress();
else
outbound_address = edesc->GetAddress();
@@ -431,7 +430,7 @@ void AndroidUsbDevice::ProcessOutgoing() {
BulkMessage message = outgoing_queue_.front();
outgoing_queue_.pop();
DumpMessage(true, message->data(), message->size());
- usb_handle_->BulkTransfer(usb_service::USB_DIRECTION_OUTBOUND,
+ usb_handle_->BulkTransfer(device::USB_DIRECTION_OUTBOUND,
outbound_address_,
message.get(),
message->size(),
@@ -445,7 +444,7 @@ void AndroidUsbDevice::OutgoingMessageSent(UsbTransferStatus status,
size_t result) {
DCHECK(message_loop_ == base::MessageLoop::current());
- if (status != usb_service::USB_TRANSFER_COMPLETED)
+ if (status != device::USB_TRANSFER_COMPLETED)
return;
message_loop_->PostTask(FROM_HERE,
base::Bind(&AndroidUsbDevice::ProcessOutgoing, this));
@@ -458,7 +457,7 @@ void AndroidUsbDevice::ReadHeader() {
return;
scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(kHeaderSize);
usb_handle_->BulkTransfer(
- usb_service::USB_DIRECTION_INBOUND,
+ device::USB_DIRECTION_INBOUND,
inbound_address_,
buffer.get(),
kHeaderSize,
@@ -471,13 +470,13 @@ void AndroidUsbDevice::ParseHeader(UsbTransferStatus status,
size_t result) {
DCHECK(message_loop_ == base::MessageLoop::current());
- if (status == usb_service::USB_TRANSFER_TIMEOUT) {
+ if (status == device::USB_TRANSFER_TIMEOUT) {
message_loop_->PostTask(FROM_HERE,
base::Bind(&AndroidUsbDevice::ReadHeader, this));
return;
}
- if (status != usb_service::USB_TRANSFER_COMPLETED || result != kHeaderSize) {
+ if (status != device::USB_TRANSFER_COMPLETED || result != kHeaderSize) {
TransferError(status);
return;
}
@@ -491,7 +490,7 @@ void AndroidUsbDevice::ParseHeader(UsbTransferStatus status,
uint32 data_check = header[4];
uint32 magic = header[5];
if ((message->command ^ 0xffffffff) != magic) {
- TransferError(usb_service::USB_TRANSFER_ERROR);
+ TransferError(device::USB_TRANSFER_ERROR);
return;
}
@@ -515,7 +514,7 @@ void AndroidUsbDevice::ReadBody(scoped_refptr<AdbMessage> message,
if (!usb_handle_.get())
return;
scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(data_length);
- usb_handle_->BulkTransfer(usb_service::USB_DIRECTION_INBOUND,
+ usb_handle_->BulkTransfer(device::USB_DIRECTION_INBOUND,
inbound_address_,
buffer.get(),
data_length,
@@ -535,14 +534,14 @@ void AndroidUsbDevice::ParseBody(scoped_refptr<AdbMessage> message,
size_t result) {
DCHECK(message_loop_ == base::MessageLoop::current());
- if (status == usb_service::USB_TRANSFER_TIMEOUT) {
+ if (status == device::USB_TRANSFER_TIMEOUT) {
message_loop_->PostTask(FROM_HERE,
base::Bind(&AndroidUsbDevice::ReadBody, this,
message, data_length, data_check));
return;
}
- if (status != usb_service::USB_TRANSFER_COMPLETED ||
+ if (status != device::USB_TRANSFER_COMPLETED ||
static_cast<uint32>(result) != data_length) {
TransferError(status);
return;
@@ -551,7 +550,7 @@ void AndroidUsbDevice::ParseBody(scoped_refptr<AdbMessage> message,
DumpMessage(false, buffer->data(), data_length);
message->body = std::string(buffer->data(), result);
if (Checksum(message->body) != data_check) {
- TransferError(usb_service::USB_TRANSFER_ERROR);
+ TransferError(device::USB_TRANSFER_ERROR);
return;
}
diff --git a/chrome/browser/devtools/device/usb/android_usb_device.h b/chrome/browser/devtools/device/usb/android_usb_device.h
index b7527c5..c97530d 100644
--- a/chrome/browser/devtools/device/usb/android_usb_device.h
+++ b/chrome/browser/devtools/device/usb/android_usb_device.h
@@ -8,9 +8,10 @@
#include <map>
#include <queue>
#include <vector>
+
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "components/usb_service/usb_device_handle.h"
+#include "device/usb/usb_device_handle.h"
namespace base {
class MessageLoop;
@@ -73,7 +74,7 @@ class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> {
static void CountDevices(const base::Callback<void(int)>& callback);
AndroidUsbDevice(crypto::RSAPrivateKey* rsa_key,
- scoped_refptr<usb_service::UsbDeviceHandle> device,
+ scoped_refptr<device::UsbDeviceHandle> device,
const std::string& serial,
int inbound_address,
int outbound_address,
@@ -89,9 +90,7 @@ class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> {
uint32 arg1,
const std::string& body);
- scoped_refptr<usb_service::UsbDeviceHandle> usb_device() {
- return usb_handle_;
- }
+ scoped_refptr<device::UsbDeviceHandle> usb_device() { return usb_handle_; }
std::string serial() { return serial_; }
@@ -103,12 +102,12 @@ class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> {
void Queue(scoped_refptr<AdbMessage> message);
void ProcessOutgoing();
- void OutgoingMessageSent(usb_service::UsbTransferStatus status,
+ void OutgoingMessageSent(device::UsbTransferStatus status,
scoped_refptr<net::IOBuffer> buffer,
size_t result);
void ReadHeader();
- void ParseHeader(usb_service::UsbTransferStatus status,
+ void ParseHeader(device::UsbTransferStatus status,
scoped_refptr<net::IOBuffer> buffer,
size_t result);
@@ -118,16 +117,15 @@ class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> {
void ParseBody(scoped_refptr<AdbMessage> message,
uint32 data_length,
uint32 data_check,
- usb_service::UsbTransferStatus status,
+ device::UsbTransferStatus status,
scoped_refptr<net::IOBuffer> buffer,
size_t result);
void HandleIncoming(scoped_refptr<AdbMessage> message);
- void TransferError(usb_service::UsbTransferStatus status);
+ void TransferError(device::UsbTransferStatus status);
- void TerminateIfReleased(
- scoped_refptr<usb_service::UsbDeviceHandle> usb_handle);
+ void TerminateIfReleased(scoped_refptr<device::UsbDeviceHandle> usb_handle);
void Terminate();
void SocketDeleted(uint32 socket_id);
@@ -137,7 +135,7 @@ class AndroidUsbDevice : public base::RefCountedThreadSafe<AndroidUsbDevice> {
scoped_ptr<crypto::RSAPrivateKey> rsa_key_;
// Device info
- scoped_refptr<usb_service::UsbDeviceHandle> usb_handle_;
+ scoped_refptr<device::UsbDeviceHandle> usb_handle_;
std::string serial_;
int inbound_address_;
int outbound_address_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index c23766e..b3a27ec 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3239,8 +3239,8 @@
}, { # OS!="android" and OS!="ios"
'sources': [ '<@(chrome_browser_non_mobile_sources)' ],
'dependencies': [
- '../components/components.gyp:usb_service',
'../device/core/core.gyp:device_core',
+ '../device/usb/usb.gyp:device_usb',
]
}],
['OS=="android"', {
diff --git a/components/BUILD.gn b/components/BUILD.gn
index bc0f186..6e8c026 100644
--- a/components/BUILD.gn
+++ b/components/BUILD.gn
@@ -88,7 +88,6 @@ group("all_components") {
"//components/translate/core/common",
"//components/url_fixer",
"//components/url_matcher",
- "//components/usb_service",
"//components/user_manager",
"//components/user_prefs",
"//components/variations",
@@ -167,7 +166,6 @@ group("all_components") {
"//components/translate/content/browser", # Blocked on content.
"//components/translate/content/common", # Blocked on content.
"//components/translate/content/renderer", # Blocked on content.
- "//components/usb_service", # Blocked on content.
"//components/user_prefs", # Blocked on content.
"//components/visitedlink/browser", # Blocked on content.
"//components/visitedlink/common", # Blocked on content.
diff --git a/components/components.gyp b/components/components.gyp
index 634b112..540babc 100644
--- a/components/components.gyp
+++ b/components/components.gyp
@@ -81,7 +81,6 @@
'includes': [
'copresence.gypi',
'storage_monitor.gypi',
- 'usb_service.gypi',
]
}],
['chromeos == 1', {
diff --git a/components/components_tests.gyp b/components/components_tests.gyp
index 1af0a56..37f3fc8 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -433,8 +433,6 @@
'autofill/content/renderer/renderer_save_password_progress_logger_unittest.cc',
'dom_distiller/content/dom_distiller_viewer_source_unittest.cc',
'power/origin_power_map_unittest.cc',
- 'usb_service/usb_context_unittest.cc',
- 'usb_service/usb_device_filter_unittest.cc',
],
'dependencies': [
# Dependencies of autofill
@@ -476,10 +474,6 @@
# Dependencies of url_matcher.
'components.gyp:url_matcher',
- # Dependencies of usb_service tests.
- 'components.gyp:usb_service',
- '../third_party/libusb/libusb.gyp:libusb',
-
# Dependencies of visitedlink
'components.gyp:visitedlink_browser',
'components.gyp:visitedlink_renderer',
@@ -593,8 +587,6 @@
'storage_monitor/media_storage_util_unittest.cc',
'storage_monitor/storage_info_unittest.cc',
'storage_monitor/storage_monitor_unittest.cc',
- 'usb_service/usb_context_unittest.cc',
- 'usb_service/usb_device_filter_unittest.cc',
'web_modal/web_contents_modal_dialog_manager_unittest.cc',
],
'dependencies': [
@@ -604,10 +596,8 @@
'components.gyp:feedback_component',
'components.gyp:storage_monitor',
'components.gyp:storage_monitor_test_support',
- 'components.gyp:usb_service',
'components.gyp:web_modal',
'components.gyp:web_modal_test_support',
- '../third_party/libusb/libusb.gyp:libusb',
],
}],
['OS != "android"', {
@@ -668,13 +658,11 @@
}],
['OS=="linux" and use_udev==0', {
'dependencies!': [
- '../third_party/libusb/libusb.gyp:libusb',
'components.gyp:storage_monitor',
'components.gyp:storage_monitor_test_support',
],
'sources/': [
['exclude', '^storage_monitor/'],
- ['exclude', '^usb_service/'],
],
}],
['OS=="win" and win_use_allocator_shim==1', {
diff --git a/components/usb_service.gypi b/components/usb_service.gypi
deleted file mode 100644
index 6d2d674..0000000
--- a/components/usb_service.gypi
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2014 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.
-
-{
- 'targets': [{
- # GN version: //components/usb_service
- 'target_name': 'usb_service',
- 'type': '<(component)',
- 'dependencies': [
- '../base/base.gyp:base',
- '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
- '../content/content.gyp:content_browser',
- '../net/net.gyp:net',
- '../third_party/libusb/libusb.gyp:libusb',
- ],
- 'defines': [
- 'USB_SERVICE_IMPLEMENTATION',
- ],
- 'include_dirs': [
- '..',
- ],
- 'sources': [
- # Note: sources list duplicated in GN build.
- 'usb_service/usb_context.cc',
- 'usb_service/usb_context.h',
- 'usb_service/usb_device_impl.cc',
- 'usb_service/usb_device_impl.h',
- 'usb_service/usb_device.h',
- 'usb_service/usb_device_filter.cc',
- 'usb_service/usb_device_filter.h',
- 'usb_service/usb_device_handle_impl.cc',
- 'usb_service/usb_device_handle_impl.h',
- 'usb_service/usb_device_handle.h',
- 'usb_service/usb_error.cc',
- 'usb_service/usb_error.h',
- 'usb_service/usb_interface.h',
- 'usb_service/usb_interface_impl.cc',
- 'usb_service/usb_interface_impl.h',
- 'usb_service/usb_service.h',
- 'usb_service/usb_service_impl.cc',
- ],
- 'conditions': [
- ['use_udev == 1', {
- 'dependencies': [
- '../build/linux/system.gyp:udev',
- ],
- }],
- ['chromeos==1', {
- 'dependencies': [
- '../chromeos/chromeos.gyp:chromeos',
- ],
- }],
- ]
- }],
-}
diff --git a/components/usb_service/OWNERS b/components/usb_service/OWNERS
deleted file mode 100644
index 28d05d3..0000000
--- a/components/usb_service/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-pfeldman@chromium.org
-rockot@chromium.org
-rpaquay@chromium.org
diff --git a/components/usb_service/usb_service_export.h b/components/usb_service/usb_service_export.h
deleted file mode 100644
index 7465597..0000000
--- a/components/usb_service/usb_service_export.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 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.
-
-#ifndef COMPONENTS_USB_SERVICE_USB_SERVICE_EXPORT_H_
-#define COMPONENTS_USB_SERVICE_USB_SERVICE_EXPORT_H_
-
-#if defined(COMPONENT_BUILD)
-#if defined(WIN32)
-
-#if defined(USB_SERVICE_IMPLEMENTATION)
-#define USB_SERVICE_EXPORT __declspec(dllexport)
-#else
-#define USB_SERVICE_EXPORT __declspec(dllimport)
-#endif // defined(USB_SERVICE_EXPORT)
-
-#else // defined(WIN32)
-#if defined(USB_SERVICE_IMPLEMENTATION)
-#define USB_SERVICE_EXPORT __attribute__((visibility("default")))
-#else
-#define USB_SERVICE_EXPORT
-#endif
-#endif
-
-#else // defined(COMPONENT_BUILD)
-#define USB_SERVICE_EXPORT
-#endif
-
-#endif // COMPONENTS_USB_SERVICE_USB_SERVICE_EXPORT_H_
diff --git a/device/core/device_client.cc b/device/core/device_client.cc
index ad96b1e..f92ec17 100644
--- a/device/core/device_client.cc
+++ b/device/core/device_client.cc
@@ -29,7 +29,7 @@ DeviceClient* DeviceClient::Get() {
return g_instance;
}
-usb_service::UsbService* DeviceClient::GetUsbService() {
+UsbService* DeviceClient::GetUsbService() {
// This should never be called by clients which do not support the USB API.
NOTREACHED();
return NULL;
diff --git a/device/core/device_client.h b/device/core/device_client.h
index d8d938b..3ca3130 100644
--- a/device/core/device_client.h
+++ b/device/core/device_client.h
@@ -7,12 +7,10 @@
#include "base/macros.h"
-namespace usb_service {
-class UsbService;
-}
-
namespace device {
+class UsbService;
+
// Interface used by consumers of //device APIs to get pointers to the service
// singletons appropriate for a given embedding application. For an example see
// //chrome/browser/chrome_device_client.h.
@@ -28,7 +26,7 @@ class DeviceClient {
static DeviceClient* Get();
// Returns the UsbService instance for this embedder.
- virtual usb_service::UsbService* GetUsbService();
+ virtual UsbService* GetUsbService();
private:
DISALLOW_COPY_AND_ASSIGN(DeviceClient);
diff --git a/device/device_tests.gyp b/device/device_tests.gyp
index 6b5a59b..9faa1a3 100644
--- a/device/device_tests.gyp
+++ b/device/device_tests.gyp
@@ -12,7 +12,6 @@
'type': '<(gtest_target_type)',
'dependencies': [
'../base/base.gyp:test_support_base',
- '../components/components.gyp:usb_service',
'../mojo/mojo_base.gyp:mojo_environment_chromium',
'../mojo/mojo_base.gyp:mojo_system_impl',
'../testing/gmock.gyp:gmock',
@@ -41,6 +40,8 @@
'bluetooth/bluetooth_uuid_unittest.cc',
'nfc/nfc_chromeos_unittest.cc',
'nfc/nfc_ndef_record_unittest.cc',
+ 'usb/usb_context_unittest.cc',
+ 'usb/usb_device_filter_unittest.cc',
'usb/usb_ids_unittest.cc',
'usb/usb_service_unittest.cc',
'hid/hid_connection_unittest.cc',
diff --git a/device/test/DEPS b/device/test/DEPS
index 9b323d8..a29f20f 100644
--- a/device/test/DEPS
+++ b/device/test/DEPS
@@ -1,5 +1,4 @@
include_rules = [
- "+components/usb_service",
"+mojo/embedder",
"+net/proxy",
"+net/url_request",
diff --git a/device/test/usb_test_gadget.h b/device/test/usb_test_gadget.h
index 1c835e2..1433bf8 100644
--- a/device/test/usb_test_gadget.h
+++ b/device/test/usb_test_gadget.h
@@ -10,12 +10,10 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
-namespace usb_service {
-class UsbDevice;
-} // namespace usb_service
-
namespace device {
+class UsbDevice;
+
class UsbTestGadget {
public:
enum Type {
@@ -35,7 +33,7 @@ class UsbTestGadget {
virtual bool Reconnect() = 0;
virtual bool SetType(Type type) = 0;
- virtual usb_service::UsbDevice* GetDevice() const = 0;
+ virtual UsbDevice* GetDevice() const = 0;
virtual std::string GetSerial() const = 0;
protected:
diff --git a/device/test/usb_test_gadget_impl.cc b/device/test/usb_test_gadget_impl.cc
index e95188b..5450b9e 100644
--- a/device/test/usb_test_gadget_impl.cc
+++ b/device/test/usb_test_gadget_impl.cc
@@ -23,9 +23,9 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
-#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_device_handle.h"
-#include "components/usb_service/usb_service.h"
+#include "device/usb/usb_device.h"
+#include "device/usb/usb_device_handle.h"
+#include "device/usb/usb_service.h"
#include "net/proxy/proxy_service.h"
#include "net/url_request/url_fetcher.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -36,9 +36,6 @@
using ::base::PlatformThread;
using ::base::TimeDelta;
-using ::usb_service::UsbDevice;
-using ::usb_service::UsbDeviceHandle;
-using ::usb_service::UsbService;
namespace device {
diff --git a/device/usb/BUILD.gn b/device/usb/BUILD.gn
index d8a7d77..0e97bfe 100644
--- a/device/usb/BUILD.gn
+++ b/device/usb/BUILD.gn
@@ -7,14 +7,39 @@ generated_ids = "$target_gen_dir/usb_ids_gen.cc"
source_set("usb") {
sources = [
+ "usb_context.cc",
+ "usb_context.h",
+ "usb_device_impl.cc",
+ "usb_device_impl.h",
+ "usb_device.h",
+ "usb_device_filter.cc",
+ "usb_device_filter.h",
+ "usb_device_handle_impl.cc",
+ "usb_device_handle_impl.h",
+ "usb_device_handle.h",
+ "usb_error.cc",
+ "usb_error.h",
"usb_ids.cc",
"usb_ids.h",
+ "usb_interface.h",
+ "usb_interface_impl.cc",
+ "usb_interface_impl.h",
+ "usb_service.h",
+ "usb_service_impl.cc",
generated_ids,
]
+
deps = [
":usb_device_ids",
"//base",
+ "//base/third_party/dynamic_annotations",
+ "//net",
+ "//third_party/libusb",
]
+
+ if (is_linux) {
+ configs += [ "//build/config/linux:udev" ]
+ }
}
action("usb_device_ids") {
diff --git a/device/usb/DEPS b/device/usb/DEPS
index 70ac41d..c114bca 100644
--- a/device/usb/DEPS
+++ b/device/usb/DEPS
@@ -1,3 +1,8 @@
include_rules = [
- "+components/usb_service",
+ "+chromeos",
+
+ "-net",
+ "+net/base",
+
+ "+third_party/libusb",
]
diff --git a/device/usb/OWNERS b/device/usb/OWNERS
index 51dcade..ee9faf8 100644
--- a/device/usb/OWNERS
+++ b/device/usb/OWNERS
@@ -1,3 +1,4 @@
-ikarienator@chromium.org
-gdk@chromium.org
-bryeung@chromium.org
+pfeldman@chromium.org
+reillyg@chromium.org
+rockot@chromium.org
+rpaquay@chromium.org
diff --git a/device/usb/usb.gyp b/device/usb/usb.gyp
index 47cf824..81bdf40 100644
--- a/device/usb/usb.gyp
+++ b/device/usb/usb.gyp
@@ -10,12 +10,32 @@
{
'target_name': 'device_usb',
'type': 'static_library',
+ 'dependencies': [
+ '../../third_party/libusb/libusb.gyp:libusb',
+ ],
'include_dirs': [
'../..',
],
'sources': [
+ 'usb_context.cc',
+ 'usb_context.h',
+ 'usb_device_impl.cc',
+ 'usb_device_impl.h',
+ 'usb_device.h',
+ 'usb_device_filter.cc',
+ 'usb_device_filter.h',
+ 'usb_device_handle_impl.cc',
+ 'usb_device_handle_impl.h',
+ 'usb_device_handle.h',
+ 'usb_error.cc',
+ 'usb_error.h',
'usb_ids.cc',
'usb_ids.h',
+ 'usb_interface.h',
+ 'usb_interface_impl.cc',
+ 'usb_interface_impl.h',
+ 'usb_service.h',
+ 'usb_service_impl.cc',
],
'actions': [
{
@@ -40,6 +60,18 @@
'process_outputs_as_sources': 1,
},
],
+ 'conditions': [
+ ['use_udev == 1', {
+ 'dependencies': [
+ '../../build/linux/system.gyp:udev',
+ ],
+ }],
+ ['chromeos==1', {
+ 'dependencies': [
+ '../../chromeos/chromeos.gyp:chromeos',
+ ],
+ }],
+ ]
},
],
}
diff --git a/components/usb_service/usb_context.cc b/device/usb/usb_context.cc
index 963986a..72a3835 100644
--- a/components/usb_service/usb_context.cc
+++ b/device/usb/usb_context.cc
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/usb_service/usb_context.h"
+#include "device/usb/usb_context.h"
#include "base/atomicops.h"
#include "base/logging.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/platform_thread.h"
-#include "components/usb_service/usb_error.h"
+#include "device/usb/usb_error.h"
#include "third_party/libusb/src/libusb/interrupt.h"
#include "third_party/libusb/src/libusb/libusb.h"
-namespace usb_service {
+namespace device {
// 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
@@ -34,9 +34,7 @@ class UsbContext::UsbEventHandler : public base::PlatformThread::Delegate {
};
UsbContext::UsbEventHandler::UsbEventHandler(libusb_context* context)
- : context_(context),
- thread_handle_(0),
- start_polling_(false, false) {
+ : context_(context), thread_handle_(0), start_polling_(false, false) {
base::subtle::Release_Store(&running_, 1);
bool success = base::PlatformThread::Create(0, this, &thread_handle_);
DCHECK(success) << "Failed to create USB IO handling thread.";
@@ -59,7 +57,8 @@ void UsbContext::UsbEventHandler::ThreadMain() {
while (base::subtle::Acquire_Load(&running_)) {
const int rv = libusb_handle_events(context_);
if (rv != LIBUSB_SUCCESS) {
- VLOG(1) << "Failed to handle events: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to handle events: "
+ << ConvertPlatformUsbErrorToString(rv);
}
}
VLOG(1) << "UsbEventHandler shutting down.";
@@ -78,4 +77,4 @@ UsbContext::~UsbContext() {
libusb_exit(context_);
}
-} // namespace usb_service
+} // namespace device
diff --git a/components/usb_service/usb_context.h b/device/usb/usb_context.h
index 73e4ee6..b628b4b 100644
--- a/components/usb_service/usb_context.h
+++ b/device/usb/usb_context.h
@@ -2,18 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_CONTEXT_H_
-#define COMPONENTS_USB_SERVICE_USB_CONTEXT_H_
+#ifndef DEVICE_USB_USB_CONTEXT_H_
+#define DEVICE_USB_USB_CONTEXT_H_
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
-#include "components/usb_service/usb_service_export.h"
struct libusb_context;
-namespace usb_service {
+namespace device {
typedef libusb_context* PlatformUsbContext;
@@ -21,8 +20,7 @@ typedef libusb_context* PlatformUsbContext;
// It also manages the life-cycle of UsbEventHandler.
// It is a blocking operation to delete UsbContext.
// Destructor must be called on FILE thread.
-class USB_SERVICE_EXPORT UsbContext
- : public base::RefCountedThreadSafe<UsbContext> {
+class UsbContext : public base::RefCountedThreadSafe<UsbContext> {
public:
PlatformUsbContext context() const { return context_; }
@@ -42,6 +40,6 @@ class USB_SERVICE_EXPORT UsbContext
DISALLOW_COPY_AND_ASSIGN(UsbContext);
};
-} // namespace usb_service
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_CONTEXT_H_
+#endif // DEVICE_USB_USB_CONTEXT_H_
diff --git a/components/usb_service/usb_context_unittest.cc b/device/usb/usb_context_unittest.cc
index 2722cc5..e00062c 100644
--- a/components/usb_service/usb_context_unittest.cc
+++ b/device/usb/usb_context_unittest.cc
@@ -4,12 +4,11 @@
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
-#include "components/usb_service/usb_context.h"
+#include "device/usb/usb_context.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libusb/src/libusb/libusb.h"
-using usb_service::UsbContext;
-using usb_service::PlatformUsbContext;
+namespace device {
namespace {
@@ -51,3 +50,5 @@ TEST_F(UsbContextTest, MAYBE_GracefulShutdown) {
FAIL();
}
}
+
+} // namespace device
diff --git a/components/usb_service/usb_device.h b/device/usb/usb_device.h
index 48ca516..586fd19 100644
--- a/components/usb_service/usb_device.h
+++ b/device/usb/usb_device.h
@@ -2,15 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_DEVICE_H_
-#define COMPONENTS_USB_SERVICE_USB_DEVICE_H_
+#ifndef DEVICE_USB_USB_DEVICE_H_
+#define DEVICE_USB_USB_DEVICE_H_
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
-#include "components/usb_service/usb_service_export.h"
-namespace usb_service {
+namespace device {
class UsbDeviceHandle;
class UsbConfigDescriptor;
@@ -18,8 +17,7 @@ class UsbConfigDescriptor;
// A UsbDevice object represents a detected USB device, providing basic
// information about it. For further manipulation of the device, a
// UsbDeviceHandle must be created from Open() method.
-class USB_SERVICE_EXPORT UsbDevice
- : public base::RefCountedThreadSafe<UsbDevice> {
+class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
public:
// Accessors to basic information.
uint16 vendor_id() const { return vendor_id_; }
@@ -67,6 +65,6 @@ class USB_SERVICE_EXPORT UsbDevice
DISALLOW_COPY_AND_ASSIGN(UsbDevice);
};
-} // namespace usb_service
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_DEVICE_H_
+#endif // DEVICE_USB_USB_DEVICE_H_
diff --git a/components/usb_service/usb_device_filter.cc b/device/usb/usb_device_filter.cc
index d026fa0..cc919e2 100644
--- a/components/usb_service/usb_device_filter.cc
+++ b/device/usb/usb_device_filter.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 "components/usb_service/usb_device_filter.h"
+#include "device/usb/usb_device_filter.h"
#include "base/values.h"
-#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_interface.h"
+#include "device/usb/usb_device.h"
+#include "device/usb/usb_interface.h"
-namespace usb_service {
+namespace device {
namespace {
@@ -137,4 +137,4 @@ bool UsbDeviceFilter::MatchesAny(scoped_refptr<UsbDevice> device,
return false;
}
-} // namespace usb_service
+} // namespace device
diff --git a/components/usb_service/usb_device_filter.h b/device/usb/usb_device_filter.h
index 2691152..6525f8f 100644
--- a/components/usb_service/usb_device_filter.h
+++ b/device/usb/usb_device_filter.h
@@ -2,23 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_DEVICE_FILTER_H_
-#define COMPONENTS_USB_SERVICE_USB_DEVICE_FILTER_H_
+#ifndef DEVICE_USB_USB_DEVICE_FILTER_H_
+#define DEVICE_USB_USB_DEVICE_FILTER_H_
#include <vector>
#include "base/memory/ref_counted.h"
-#include "components/usb_service/usb_service_export.h"
namespace base {
class Value;
}
-namespace usb_service {
+namespace device {
class UsbDevice;
-class USB_SERVICE_EXPORT UsbDeviceFilter {
+class UsbDeviceFilter {
public:
UsbDeviceFilter();
~UsbDeviceFilter();
@@ -48,6 +47,6 @@ class USB_SERVICE_EXPORT UsbDeviceFilter {
bool interface_protocol_set_ : 1;
};
-} // namespace usb_service
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_DEVICE_FILTER_H_
+#endif // DEVICE_USB_USB_DEVICE_FILTER_H_
diff --git a/components/usb_service/usb_device_filter_unittest.cc b/device/usb/usb_device_filter_unittest.cc
index c4789ea4..1fdccd4 100644
--- a/components/usb_service/usb_device_filter_unittest.cc
+++ b/device/usb/usb_device_filter_unittest.cc
@@ -5,19 +5,13 @@
#include <vector>
#include "base/memory/ref_counted.h"
-#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_device_filter.h"
-#include "components/usb_service/usb_device_handle.h"
-#include "components/usb_service/usb_interface.h"
+#include "device/usb/usb_device.h"
+#include "device/usb/usb_device_filter.h"
+#include "device/usb/usb_device_handle.h"
+#include "device/usb/usb_interface.h"
#include "testing/gtest/include/gtest/gtest.h"
-using usb_service::UsbConfigDescriptor;
-using usb_service::UsbDevice;
-using usb_service::UsbDeviceFilter;
-using usb_service::UsbDeviceHandle;
-using usb_service::UsbEndpointDescriptor;
-using usb_service::UsbInterfaceAltSettingDescriptor;
-using usb_service::UsbInterfaceDescriptor;
+namespace device {
namespace {
@@ -163,8 +157,6 @@ class UsbFilterTest : public testing::Test {
scoped_refptr<UsbDevice> android_phone_;
};
-} // namespace
-
TEST_F(UsbFilterTest, MatchAny) {
UsbDeviceFilter filter;
ASSERT_TRUE(filter.Matches(android_phone_));
@@ -254,3 +246,7 @@ TEST_F(UsbFilterTest, MatchesAnyVendorIdNegative) {
filters.back().SetVendorId(0x1d6b);
ASSERT_FALSE(UsbDeviceFilter::MatchesAny(android_phone_, filters));
}
+
+} // namespace
+
+} // namespace device
diff --git a/components/usb_service/usb_device_handle.h b/device/usb/usb_device_handle.h
index 0115e64..be7de09 100644
--- a/components/usb_service/usb_device_handle.h
+++ b/device/usb/usb_device_handle.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_H_
-#define COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_H_
+#ifndef DEVICE_USB_USB_DEVICE_HANDLE_H_
+#define DEVICE_USB_USB_DEVICE_HANDLE_H_
#include <map>
#include <vector>
@@ -12,11 +12,10 @@
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h"
-#include "components/usb_service/usb_interface.h"
-#include "components/usb_service/usb_service_export.h"
+#include "device/usb/usb_interface.h"
#include "net/base/io_buffer.h"
-namespace usb_service {
+namespace device {
class UsbDevice;
@@ -36,8 +35,7 @@ typedef base::Callback<
UsbTransferCallback;
// UsbDeviceHandle class provides basic I/O related functionalities.
-class USB_SERVICE_EXPORT UsbDeviceHandle
- : public base::RefCountedThreadSafe<UsbDeviceHandle> {
+class UsbDeviceHandle : public base::RefCountedThreadSafe<UsbDeviceHandle> {
public:
enum TransferRequestType { STANDARD, CLASS, VENDOR, RESERVED };
enum TransferRecipient { DEVICE, INTERFACE, ENDPOINT, OTHER };
@@ -107,6 +105,6 @@ class USB_SERVICE_EXPORT UsbDeviceHandle
DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandle);
};
-} // namespace usb_service
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_H_
+#endif // DEVICE_USB_USB_DEVICE_HANDLE_H_
diff --git a/components/usb_service/usb_device_handle_impl.cc b/device/usb/usb_device_handle_impl.cc
index 5823085..c9d69a4 100644
--- a/components/usb_service/usb_device_handle_impl.cc
+++ b/device/usb/usb_device_handle_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/usb_service/usb_device_handle_impl.h"
+#include "device/usb/usb_device_handle_impl.h"
#include <algorithm>
#include <vector>
@@ -14,18 +14,18 @@
#include "base/strings/string16.h"
#include "base/synchronization/lock.h"
#include "base/thread_task_runner_handle.h"
-#include "components/usb_service/usb_context.h"
-#include "components/usb_service/usb_device_impl.h"
-#include "components/usb_service/usb_error.h"
-#include "components/usb_service/usb_interface.h"
-#include "components/usb_service/usb_service.h"
+#include "device/usb/usb_context.h"
+#include "device/usb/usb_device_impl.h"
+#include "device/usb/usb_error.h"
+#include "device/usb/usb_interface.h"
+#include "device/usb/usb_service.h"
#include "third_party/libusb/src/libusb/libusb.h"
-namespace usb_service {
+namespace device {
typedef libusb_device* PlatformUsbDevice;
-void HandleTransferCompletion(usb_service::PlatformUsbTransferHandle transfer);
+void HandleTransferCompletion(PlatformUsbTransferHandle transfer);
namespace {
@@ -145,7 +145,8 @@ UsbDeviceHandleImpl::InterfaceClaimer::~InterfaceClaimer() {
bool UsbDeviceHandleImpl::InterfaceClaimer::Claim() const {
const int rv = libusb_claim_interface(handle_->handle(), interface_number_);
if (rv != LIBUSB_SUCCESS) {
- VLOG(1) << "Failed to claim interface: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to claim interface: "
+ << ConvertPlatformUsbErrorToString(rv);
}
return rv == LIBUSB_SUCCESS;
}
@@ -357,7 +358,8 @@ bool UsbDeviceHandleImpl::SetInterfaceAlternateSetting(
RefreshEndpointMap();
} else {
VLOG(1) << "Failed to set interface (" << interface_number << ", "
- << alternate_setting << "): " << ConvertErrorToString(rv);
+ << alternate_setting
+ << "): " << ConvertPlatformUsbErrorToString(rv);
}
return rv == LIBUSB_SUCCESS;
}
@@ -369,7 +371,8 @@ bool UsbDeviceHandleImpl::ResetDevice() {
const int rv = libusb_reset_device(handle_);
if (rv != LIBUSB_SUCCESS) {
- VLOG(1) << "Failed to reset device: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to reset device: "
+ << ConvertPlatformUsbErrorToString(rv);
}
return rv == LIBUSB_SUCCESS;
}
@@ -389,12 +392,12 @@ bool UsbDeviceHandleImpl::GetSupportedLanguages() {
sizeof(languages));
if (size < 0) {
VLOG(1) << "Failed to get list of supported languages: "
- << ConvertErrorToString(size);
+ << ConvertPlatformUsbErrorToString(size);
return false;
} else if (size < 2) {
VLOG(1) << "String descriptor zero has no header.";
return false;
- // The first 2 bytes of the descriptor are the total length and type tag.
+ // The first 2 bytes of the descriptor are the total length and type tag.
} else if ((languages[0] & 0xff) != size) {
VLOG(1) << "String descriptor zero size mismatch: " << (languages[0] & 0xff)
<< " != " << size;
@@ -433,13 +436,13 @@ bool UsbDeviceHandleImpl::GetStringDescriptor(uint8 string_id,
sizeof(text));
if (size < 0) {
VLOG(1) << "Failed to get string descriptor " << string_id << " (langid "
- << language_id << "): " << ConvertErrorToString(size);
+ << language_id << "): " << ConvertPlatformUsbErrorToString(size);
continue;
} else if (size < 2) {
VLOG(1) << "String descriptor " << string_id << " (langid " << language_id
<< ") has no header.";
continue;
- // The first 2 bytes of the descriptor are the total length and type tag.
+ // The first 2 bytes of the descriptor are the total length and type tag.
} else if ((text[0] & 0xff) != size) {
VLOG(1) << "String descriptor " << string_id << " (langid " << language_id
<< ") size mismatch: " << (text[0] & 0xff) << " != " << size;
@@ -466,7 +469,8 @@ bool UsbDeviceHandleImpl::GetManufacturer(base::string16* manufacturer) {
// This is a non-blocking call as libusb has the descriptor in memory.
const int rv = libusb_get_device_descriptor(device, &desc);
if (rv != LIBUSB_SUCCESS) {
- VLOG(1) << "Failed to read device descriptor: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to read device descriptor: "
+ << ConvertPlatformUsbErrorToString(rv);
return false;
}
@@ -485,7 +489,8 @@ bool UsbDeviceHandleImpl::GetProduct(base::string16* product) {
// This is a non-blocking call as libusb has the descriptor in memory.
const int rv = libusb_get_device_descriptor(device, &desc);
if (rv != LIBUSB_SUCCESS) {
- VLOG(1) << "Failed to read device descriptor: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to read device descriptor: "
+ << ConvertPlatformUsbErrorToString(rv);
return false;
}
@@ -504,7 +509,8 @@ bool UsbDeviceHandleImpl::GetSerial(base::string16* serial) {
// This is a non-blocking call as libusb has the descriptor in memory.
const int rv = libusb_get_device_descriptor(device, &desc);
if (rv != LIBUSB_SUCCESS) {
- VLOG(1) << "Failed to read device descriptor: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to read device descriptor: "
+ << ConvertPlatformUsbErrorToString(rv);
return false;
}
@@ -729,7 +735,8 @@ void UsbDeviceHandleImpl::SubmitTransfer(
if (rv == LIBUSB_SUCCESS) {
transfers_[handle] = transfer;
} else {
- VLOG(1) << "Failed to submit transfer: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to submit transfer: "
+ << ConvertPlatformUsbErrorToString(rv);
transfer.Complete(USB_TRANSFER_ERROR, 0);
}
}
@@ -755,4 +762,4 @@ void UsbDeviceHandleImpl::InternalClose() {
device_ = NULL;
}
-} // namespace usb_service
+} // namespace device
diff --git a/components/usb_service/usb_device_handle_impl.h b/device/usb/usb_device_handle_impl.h
index 66d6960..e4e5163 100644
--- a/components/usb_service/usb_device_handle_impl.h
+++ b/device/usb/usb_device_handle_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_IMPL_H_
-#define COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_IMPL_H_
+#ifndef DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_
+#define DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_
#include <map>
#include <vector>
@@ -12,8 +12,8 @@
#include "base/memory/ref_counted.h"
#include "base/strings/string16.h"
#include "base/threading/thread_checker.h"
-#include "components/usb_service/usb_device_handle.h"
-#include "components/usb_service/usb_interface.h"
+#include "device/usb/usb_device_handle.h"
+#include "device/usb/usb_interface.h"
#include "net/base/io_buffer.h"
#include "third_party/libusb/src/libusb/libusb.h"
@@ -21,7 +21,7 @@ namespace base {
class SingleThreadTaskRunner;
}
-namespace usb_service {
+namespace device {
class UsbContext;
class UsbConfigDescriptor;
@@ -169,6 +169,6 @@ class UsbDeviceHandleImpl : public UsbDeviceHandle {
DISALLOW_COPY_AND_ASSIGN(UsbDeviceHandleImpl);
};
-} // namespace usb_service
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_DEVICE_HANDLE_IMPL_H_
+#endif // DEVICE_USB_USB_DEVICE_HANDLE_IMPL_H_
diff --git a/components/usb_service/usb_device_impl.cc b/device/usb/usb_device_impl.cc
index b6d2a12..03c8ee0 100644
--- a/components/usb_service/usb_device_impl.cc
+++ b/device/usb/usb_device_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/usb_service/usb_device_impl.h"
+#include "device/usb/usb_device_impl.h"
#include <algorithm>
@@ -11,10 +11,10 @@
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/thread_task_runner_handle.h"
-#include "components/usb_service/usb_context.h"
-#include "components/usb_service/usb_device_handle_impl.h"
-#include "components/usb_service/usb_error.h"
-#include "components/usb_service/usb_interface_impl.h"
+#include "device/usb/usb_context.h"
+#include "device/usb/usb_device_handle_impl.h"
+#include "device/usb/usb_error.h"
+#include "device/usb/usb_interface_impl.h"
#include "third_party/libusb/src/libusb/libusb.h"
#if defined(OS_CHROMEOS)
@@ -36,7 +36,7 @@ void OnRequestUsbAccessReplied(
} // namespace
-namespace usb_service {
+namespace device {
UsbDeviceImpl::UsbDeviceImpl(
scoped_refptr<UsbContext> context,
@@ -109,7 +109,7 @@ scoped_refptr<UsbDeviceHandle> UsbDeviceImpl::Open() {
handles_.push_back(device_handle);
return device_handle;
} else {
- VLOG(1) << "Failed to open device: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to open device: " << ConvertPlatformUsbErrorToString(rv);
return NULL;
}
}
@@ -137,7 +137,8 @@ scoped_refptr<UsbConfigDescriptor> UsbDeviceImpl::ListInterfaces() {
if (rv == LIBUSB_SUCCESS) {
return new UsbConfigDescriptorImpl(platform_config);
} else {
- VLOG(1) << "Failed to get config descriptor: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to get config descriptor: "
+ << ConvertPlatformUsbErrorToString(rv);
return NULL;
}
}
@@ -150,4 +151,4 @@ void UsbDeviceImpl::OnDisconnect() {
(*it)->InternalClose();
}
-} // namespace usb_service
+} // namespace device
diff --git a/components/usb_service/usb_device_impl.h b/device/usb/usb_device_impl.h
index 07711bc..1ece2e0 100644
--- a/components/usb_service/usb_device_impl.h
+++ b/device/usb/usb_device_impl.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_DEVICE_IMPL_H_
-#define COMPONENTS_USB_SERVICE_USB_DEVICE_IMPL_H_
+#ifndef DEVICE_USB_USB_DEVICE_IMPL_H_
+#define DEVICE_USB_USB_DEVICE_IMPL_H_
#include <vector>
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/threading/thread_checker.h"
-#include "components/usb_service/usb_device.h"
+#include "device/usb/usb_device.h"
struct libusb_device;
struct libusb_config_descriptor;
@@ -19,7 +19,7 @@ namespace base {
class SingleThreadTaskRunner;
}
-namespace usb_service {
+namespace device {
class UsbDeviceHandleImpl;
class UsbContext;
@@ -72,6 +72,6 @@ class UsbDeviceImpl : public UsbDevice {
DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl);
};
-} // namespace usb_service
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_DEVICE_IMPL_H_
+#endif // DEVICE_USB_USB_DEVICE_IMPL_H_
diff --git a/components/usb_service/usb_error.cc b/device/usb/usb_error.cc
index d3e9960..9fadb16 100644
--- a/components/usb_service/usb_error.cc
+++ b/device/usb/usb_error.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/usb_service/usb_error.h"
+#include "device/usb/usb_error.h"
#include "third_party/libusb/src/libusb/libusb.h"
-namespace usb_service {
+namespace device {
-std::string ConvertErrorToString(int errcode) {
+std::string ConvertPlatformUsbErrorToString(int errcode) {
return libusb_strerror(static_cast<libusb_error>(errcode));
}
-} // namespace usb_service;
+} // namespace device
diff --git a/components/usb_service/usb_error.h b/device/usb/usb_error.h
index b718d67..590c450 100644
--- a/components/usb_service/usb_error.h
+++ b/device/usb/usb_error.h
@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_ERROR_H_
-#define COMPONENTS_USB_SERVICE_USB_ERROR_H_
+#ifndef DEVICE_USB_USB_ERROR_H_
+#define DEVICE_USB_USB_ERROR_H_
#include <string>
-namespace usb_service {
+namespace device {
// A number of libusb functions which return a member of enum libusb_error
// return an int instead so for convenience this function takes an int.
-std::string ConvertErrorToString(int errcode);
+std::string ConvertPlatformUsbErrorToString(int errcode);
-} // namespace usb_service;
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_ERROR_H_
+#endif // DEVICE_USB_USB_ERROR_H_
diff --git a/components/usb_service/usb_interface.h b/device/usb/usb_interface.h
index 7ca3197..9285718 100644
--- a/components/usb_service/usb_interface.h
+++ b/device/usb/usb_interface.h
@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_INTERFACE_H_
-#define COMPONENTS_USB_SERVICE_USB_INTERFACE_H_
+#ifndef DEVICE_USB_USB_INTERFACE_H_
+#define DEVICE_USB_USB_INTERFACE_H_
#include "base/memory/ref_counted.h"
-#include "components/usb_service/usb_service_export.h"
-namespace usb_service {
+namespace device {
enum UsbTransferType {
USB_TRANSFER_CONTROL = 0,
@@ -35,7 +34,7 @@ enum UsbUsageType {
USB_USAGE_EXPLICIT_FEEDBACK
};
-class USB_SERVICE_EXPORT UsbEndpointDescriptor
+class UsbEndpointDescriptor
: public base::RefCounted<const UsbEndpointDescriptor> {
public:
virtual int GetAddress() const = 0;
@@ -55,7 +54,7 @@ class USB_SERVICE_EXPORT UsbEndpointDescriptor
DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor);
};
-class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor
+class UsbInterfaceAltSettingDescriptor
: public base::RefCounted<const UsbInterfaceAltSettingDescriptor> {
public:
virtual size_t GetNumEndpoints() const = 0;
@@ -77,7 +76,7 @@ class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor);
};
-class USB_SERVICE_EXPORT UsbInterfaceDescriptor
+class UsbInterfaceDescriptor
: public base::RefCounted<const UsbInterfaceDescriptor> {
public:
virtual size_t GetNumAltSettings() const = 0;
@@ -93,8 +92,7 @@ class USB_SERVICE_EXPORT UsbInterfaceDescriptor
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor);
};
-class USB_SERVICE_EXPORT UsbConfigDescriptor
- : public base::RefCounted<UsbConfigDescriptor> {
+class UsbConfigDescriptor : public base::RefCounted<UsbConfigDescriptor> {
public:
virtual size_t GetNumInterfaces() const = 0;
virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface(
@@ -109,6 +107,6 @@ class USB_SERVICE_EXPORT UsbConfigDescriptor
DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor);
};
-} // namespace usb_service;
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_INTERFACE_H_
+#endif // DEVICE_USB_USB_INTERFACE_H_
diff --git a/components/usb_service/usb_interface_impl.cc b/device/usb/usb_interface_impl.cc
index 1eb1b2f..af3d0e3 100644
--- a/components/usb_service/usb_interface_impl.cc
+++ b/device/usb/usb_interface_impl.cc
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/usb_service/usb_interface_impl.h"
+#include "device/usb/usb_interface_impl.h"
#include "base/logging.h"
#include "third_party/libusb/src/libusb/libusb.h"
-namespace usb_service {
+namespace device {
UsbEndpointDescriptorImpl::UsbEndpointDescriptorImpl(
scoped_refptr<const UsbConfigDescriptor> config,
@@ -38,8 +38,8 @@ int UsbEndpointDescriptorImpl::GetMaximumPacketSize() const {
return descriptor_->wMaxPacketSize;
}
-UsbSynchronizationType
- UsbEndpointDescriptorImpl::GetSynchronizationType() const {
+UsbSynchronizationType UsbEndpointDescriptorImpl::GetSynchronizationType()
+ const {
switch (descriptor_->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) {
case LIBUSB_ISO_SYNC_TYPE_NONE:
return USB_SYNCHRONIZATION_NONE;
@@ -161,8 +161,8 @@ size_t UsbConfigDescriptorImpl::GetNumInterfaces() const {
}
scoped_refptr<const UsbInterfaceDescriptor>
- UsbConfigDescriptorImpl::GetInterface(size_t index) const {
+UsbConfigDescriptorImpl::GetInterface(size_t index) const {
return new UsbInterfaceDescriptorImpl(this, &config_->interface[index]);
}
-} // namespace usb_service
+} // namespace device
diff --git a/components/usb_service/usb_interface_impl.h b/device/usb/usb_interface_impl.h
index defde69..0f6b913 100644
--- a/components/usb_service/usb_interface_impl.h
+++ b/device/usb/usb_interface_impl.h
@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
-#define COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
+#ifndef DEVICE_USB_USB_INTERFACE_IMPL_H_
+#define DEVICE_USB_USB_INTERFACE_IMPL_H_
#include "base/memory/ref_counted.h"
-#include "components/usb_service/usb_interface.h"
-#include "components/usb_service/usb_service_export.h"
+#include "device/usb/usb_interface.h"
struct libusb_config_descriptor;
struct libusb_endpoint_descriptor;
struct libusb_interface;
struct libusb_interface_descriptor;
-namespace usb_service {
+namespace device {
typedef libusb_config_descriptor* PlatformUsbConfigDescriptor;
typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor;
@@ -39,7 +38,7 @@ class UsbEndpointDescriptorImpl : public UsbEndpointDescriptor {
friend class UsbInterfaceAltSettingDescriptorImpl;
UsbEndpointDescriptorImpl(scoped_refptr<const UsbConfigDescriptor> config,
- PlatformUsbEndpointDescriptor descriptor);
+ PlatformUsbEndpointDescriptor descriptor);
virtual ~UsbEndpointDescriptorImpl();
scoped_refptr<const UsbConfigDescriptor> config_;
@@ -113,6 +112,6 @@ class UsbConfigDescriptorImpl : public UsbConfigDescriptor {
DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptorImpl);
};
-} // namespace usb_service;
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
+#endif // DEVICE_USB_USB_INTERFACE_IMPL_H_
diff --git a/components/usb_service/usb_service.h b/device/usb/usb_service.h
index 11eac1a..0d49c2f 100644
--- a/components/usb_service/usb_service.h
+++ b/device/usb/usb_service.h
@@ -2,21 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_USB_SERVICE_USB_SERVICE_H_
-#define COMPONENTS_USB_SERVICE_USB_SERVICE_H_
+#ifndef DEVICE_USB_USB_SERVICE_H_
+#define DEVICE_USB_USB_SERVICE_H_
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/non_thread_safe.h"
-#include "components/usb_service/usb_service_export.h"
namespace base {
class SingleThreadTaskRunner;
}
-namespace usb_service {
+namespace device {
class UsbDevice;
@@ -24,7 +23,7 @@ class UsbDevice;
// used to manage and dispatch USB events. It is also responsible for device
// discovery on the system, which allows it to re-use device handles to prevent
// competition for the same USB device.
-class USB_SERVICE_EXPORT UsbService : public base::NonThreadSafe {
+class UsbService : public base::NonThreadSafe {
public:
// Must be called on a thread with a MessageLoopForIO (for example
// BrowserThread::FILE). The UI task runner reference is used to talk to the
@@ -49,6 +48,6 @@ class USB_SERVICE_EXPORT UsbService : public base::NonThreadSafe {
DISALLOW_COPY_AND_ASSIGN(UsbService);
};
-} // namespace usb_service
+} // namespace device
-#endif // COMPONENTS_USB_SERVICE_USB_SERVICE_H_
+#endif // DEVICE_USB_USB_SERVICE_H_
diff --git a/components/usb_service/usb_service_impl.cc b/device/usb/usb_service_impl.cc
index 051bead..78846d3 100644
--- a/components/usb_service/usb_service_impl.cc
+++ b/device/usb/usb_service_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/usb_service/usb_service.h"
+#include "device/usb/usb_service.h"
#include <map>
#include <set>
@@ -11,12 +11,12 @@
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
-#include "components/usb_service/usb_context.h"
-#include "components/usb_service/usb_device_impl.h"
-#include "components/usb_service/usb_error.h"
+#include "device/usb/usb_context.h"
+#include "device/usb/usb_device_impl.h"
+#include "device/usb/usb_error.h"
#include "third_party/libusb/src/libusb/libusb.h"
-namespace usb_service {
+namespace device {
namespace {
@@ -28,9 +28,8 @@ base::LazyInstance<scoped_ptr<UsbService> >::Leaky g_usb_service_instance =
typedef struct libusb_device* PlatformUsbDevice;
typedef struct libusb_context* PlatformUsbContext;
-class UsbServiceImpl
- : public UsbService,
- private base::MessageLoop::DestructionObserver {
+class UsbServiceImpl : public UsbService,
+ private base::MessageLoop::DestructionObserver {
public:
explicit UsbServiceImpl(
PlatformUsbContext context,
@@ -38,7 +37,7 @@ class UsbServiceImpl
virtual ~UsbServiceImpl();
private:
- // usb_service::UsbService implementation
+ // device::UsbService implementation
virtual scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) OVERRIDE;
virtual void GetDevices(
std::vector<scoped_refptr<UsbDevice> >* devices) OVERRIDE;
@@ -113,7 +112,7 @@ void UsbServiceImpl::RefreshDevices() {
libusb_get_device_list(context_->context(), &platform_devices);
if (device_count < 0) {
VLOG(1) << "Failed to get device list: "
- << ConvertErrorToString(device_count);
+ << ConvertPlatformUsbErrorToString(device_count);
}
std::set<UsbDevice*> connected_devices;
@@ -128,7 +127,7 @@ void UsbServiceImpl::RefreshDevices() {
// This test is needed. A valid vendor/produce pair is required.
if (rv != LIBUSB_SUCCESS) {
VLOG(1) << "Failed to get device descriptor: "
- << ConvertErrorToString(rv);
+ << ConvertPlatformUsbErrorToString(rv);
continue;
}
UsbDeviceImpl* new_device = new UsbDeviceImpl(context_,
@@ -170,7 +169,8 @@ UsbService* UsbService::GetInstance(
const int rv = libusb_init(&context);
if (rv != LIBUSB_SUCCESS) {
- VLOG(1) << "Failed to initialize libusb: " << ConvertErrorToString(rv);
+ VLOG(1) << "Failed to initialize libusb: "
+ << ConvertPlatformUsbErrorToString(rv);
return NULL;
}
if (!context)
@@ -187,4 +187,4 @@ void UsbService::SetInstanceForTest(UsbService* instance) {
g_usb_service_instance.Get().reset(instance);
}
-} // namespace usb_service
+} // namespace device
diff --git a/device/usb/usb_service_unittest.cc b/device/usb/usb_service_unittest.cc
index 1f8b8e2..5436200 100644
--- a/device/usb/usb_service_unittest.cc
+++ b/device/usb/usb_service_unittest.cc
@@ -4,13 +4,11 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
-#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_device_handle.h"
#include "device/test/usb_test_gadget.h"
+#include "device/usb/usb_device.h"
+#include "device/usb/usb_device_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
-using ::usb_service::UsbDeviceHandle;
-
namespace device {
namespace {
diff --git a/extensions/browser/BUILD.gn b/extensions/browser/BUILD.gn
index c1c856c..9fe04b2 100644
--- a/extensions/browser/BUILD.gn
+++ b/extensions/browser/BUILD.gn
@@ -349,11 +349,11 @@ source_set("browser") {
]
deps += [
- "//components/usb_service",
"//crypto:platform",
"//device/bluetooth",
"//device/hid",
"//device/serial",
+ "//device/usb",
"//extensions/browser/api/cast_channel:cast_channel_proto",
]
diff --git a/extensions/browser/api/usb/DEPS b/extensions/browser/api/usb/DEPS
index 549aed6..dce2c70 100644
--- a/extensions/browser/api/usb/DEPS
+++ b/extensions/browser/api/usb/DEPS
@@ -1,4 +1,4 @@
include_rules = [
- "+components/usb_service",
- "+device/core"
+ "+device/core",
+ "+device/usb",
]
diff --git a/extensions/browser/api/usb/usb_api.cc b/extensions/browser/api/usb/usb_api.cc
index 71c345e..53f5c5b 100644
--- a/extensions/browser/api/usb/usb_api.cc
+++ b/extensions/browser/api/usb/usb_api.cc
@@ -9,9 +9,9 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "components/usb_service/usb_device_handle.h"
-#include "components/usb_service/usb_service.h"
#include "device/core/device_client.h"
+#include "device/usb/usb_device_handle.h"
+#include "device/usb/usb_service.h"
#include "extensions/browser/api/usb/usb_device_resource.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/api/usb.h"
@@ -50,19 +50,19 @@ using usb::RequestType;
using usb::SynchronizationType;
using usb::TransferType;
using usb::UsageType;
-using usb_service::UsbConfigDescriptor;
-using usb_service::UsbDevice;
-using usb_service::UsbDeviceFilter;
-using usb_service::UsbDeviceHandle;
-using usb_service::UsbEndpointDescriptor;
-using usb_service::UsbEndpointDirection;
-using usb_service::UsbInterfaceAltSettingDescriptor;
-using usb_service::UsbInterfaceDescriptor;
-using usb_service::UsbService;
-using usb_service::UsbSynchronizationType;
-using usb_service::UsbTransferStatus;
-using usb_service::UsbTransferType;
-using usb_service::UsbUsageType;
+using device::UsbConfigDescriptor;
+using device::UsbDevice;
+using device::UsbDeviceFilter;
+using device::UsbDeviceHandle;
+using device::UsbEndpointDescriptor;
+using device::UsbEndpointDirection;
+using device::UsbInterfaceAltSettingDescriptor;
+using device::UsbInterfaceDescriptor;
+using device::UsbService;
+using device::UsbSynchronizationType;
+using device::UsbTransferStatus;
+using device::UsbTransferType;
+using device::UsbUsageType;
typedef std::vector<scoped_refptr<UsbDevice> > DeviceVector;
typedef scoped_ptr<DeviceVector> ScopedDeviceVector;
@@ -116,10 +116,10 @@ const int kMaxPacketLength = 64 * 1024;
bool ConvertDirectionToApi(const UsbEndpointDirection& input,
Direction* output) {
switch (input) {
- case usb_service::USB_DIRECTION_INBOUND:
+ case device::USB_DIRECTION_INBOUND:
*output = usb::DIRECTION_IN;
return true;
- case usb_service::USB_DIRECTION_OUTBOUND:
+ case device::USB_DIRECTION_OUTBOUND:
*output = usb::DIRECTION_OUT;
return true;
default:
@@ -131,16 +131,16 @@ bool ConvertDirectionToApi(const UsbEndpointDirection& input,
bool ConvertSynchronizationTypeToApi(const UsbSynchronizationType& input,
usb::SynchronizationType* output) {
switch (input) {
- case usb_service::USB_SYNCHRONIZATION_NONE:
+ case device::USB_SYNCHRONIZATION_NONE:
*output = usb::SYNCHRONIZATION_TYPE_NONE;
return true;
- case usb_service::USB_SYNCHRONIZATION_ASYNCHRONOUS:
+ case device::USB_SYNCHRONIZATION_ASYNCHRONOUS:
*output = usb::SYNCHRONIZATION_TYPE_ASYNCHRONOUS;
return true;
- case usb_service::USB_SYNCHRONIZATION_ADAPTIVE:
+ case device::USB_SYNCHRONIZATION_ADAPTIVE:
*output = usb::SYNCHRONIZATION_TYPE_ADAPTIVE;
return true;
- case usb_service::USB_SYNCHRONIZATION_SYNCHRONOUS:
+ case device::USB_SYNCHRONIZATION_SYNCHRONOUS:
*output = usb::SYNCHRONIZATION_TYPE_SYNCHRONOUS;
return true;
default:
@@ -152,16 +152,16 @@ bool ConvertSynchronizationTypeToApi(const UsbSynchronizationType& input,
bool ConvertTransferTypeToApi(const UsbTransferType& input,
usb::TransferType* output) {
switch (input) {
- case usb_service::USB_TRANSFER_CONTROL:
+ case device::USB_TRANSFER_CONTROL:
*output = usb::TRANSFER_TYPE_CONTROL;
return true;
- case usb_service::USB_TRANSFER_INTERRUPT:
+ case device::USB_TRANSFER_INTERRUPT:
*output = usb::TRANSFER_TYPE_INTERRUPT;
return true;
- case usb_service::USB_TRANSFER_ISOCHRONOUS:
+ case device::USB_TRANSFER_ISOCHRONOUS:
*output = usb::TRANSFER_TYPE_ISOCHRONOUS;
return true;
- case usb_service::USB_TRANSFER_BULK:
+ case device::USB_TRANSFER_BULK:
*output = usb::TRANSFER_TYPE_BULK;
return true;
default:
@@ -172,13 +172,13 @@ bool ConvertTransferTypeToApi(const UsbTransferType& input,
bool ConvertUsageTypeToApi(const UsbUsageType& input, usb::UsageType* output) {
switch (input) {
- case usb_service::USB_USAGE_DATA:
+ case device::USB_USAGE_DATA:
*output = usb::USAGE_TYPE_DATA;
return true;
- case usb_service::USB_USAGE_FEEDBACK:
+ case device::USB_USAGE_FEEDBACK:
*output = usb::USAGE_TYPE_FEEDBACK;
return true;
- case usb_service::USB_USAGE_EXPLICIT_FEEDBACK:
+ case device::USB_USAGE_EXPLICIT_FEEDBACK:
*output = usb::USAGE_TYPE_EXPLICITFEEDBACK;
return true;
default:
@@ -190,10 +190,10 @@ bool ConvertUsageTypeToApi(const UsbUsageType& input, usb::UsageType* output) {
bool ConvertDirection(const Direction& input, UsbEndpointDirection* output) {
switch (input) {
case usb::DIRECTION_IN:
- *output = usb_service::USB_DIRECTION_INBOUND;
+ *output = device::USB_DIRECTION_INBOUND;
return true;
case usb::DIRECTION_OUT:
- *output = usb_service::USB_DIRECTION_OUTBOUND;
+ *output = device::USB_DIRECTION_OUTBOUND;
return true;
default:
NOTREACHED();
@@ -275,9 +275,9 @@ scoped_refptr<net::IOBuffer> CreateBufferForTransfer(
scoped_refptr<net::IOBuffer> buffer =
new net::IOBuffer(std::max(static_cast<size_t>(1), size));
- if (direction == usb_service::USB_DIRECTION_INBOUND) {
+ if (direction == device::USB_DIRECTION_INBOUND) {
return buffer;
- } else if (direction == usb_service::USB_DIRECTION_OUTBOUND) {
+ } else if (direction == device::USB_DIRECTION_OUTBOUND) {
if (input.data.get() && size <= input.data->size()) {
memcpy(buffer->data(), input.data->data(), size);
return buffer;
@@ -289,21 +289,21 @@ scoped_refptr<net::IOBuffer> CreateBufferForTransfer(
const char* ConvertTransferStatusToErrorString(const UsbTransferStatus status) {
switch (status) {
- case usb_service::USB_TRANSFER_COMPLETED:
+ case device::USB_TRANSFER_COMPLETED:
return "";
- case usb_service::USB_TRANSFER_ERROR:
+ case device::USB_TRANSFER_ERROR:
return kErrorGeneric;
- case usb_service::USB_TRANSFER_TIMEOUT:
+ case device::USB_TRANSFER_TIMEOUT:
return kErrorTimeout;
- case usb_service::USB_TRANSFER_CANCELLED:
+ case device::USB_TRANSFER_CANCELLED:
return kErrorCancelled;
- case usb_service::USB_TRANSFER_STALLED:
+ case device::USB_TRANSFER_STALLED:
return kErrorStalled;
- case usb_service::USB_TRANSFER_DISCONNECT:
+ case device::USB_TRANSFER_DISCONNECT:
return kErrorDisconnect;
- case usb_service::USB_TRANSFER_OVERFLOW:
+ case device::USB_TRANSFER_OVERFLOW:
return kErrorOverflow;
- case usb_service::USB_TRANSFER_LENGTH_SHORT:
+ case device::USB_TRANSFER_LENGTH_SHORT:
return kErrorTransferLength;
default:
NOTREACHED();
@@ -438,8 +438,7 @@ void UsbAsyncApiFunction::CreateDeviceFilter(const usb::DeviceFilter& input,
}
}
-bool UsbAsyncApiFunction::HasDevicePermission(
- scoped_refptr<usb_service::UsbDevice> device) {
+bool UsbAsyncApiFunction::HasDevicePermission(scoped_refptr<UsbDevice> device) {
UsbDevicePermission::CheckParam param(
device->vendor_id(),
device->product_id(),
@@ -517,7 +516,7 @@ UsbAsyncApiTransferFunction::~UsbAsyncApiTransferFunction() {
void UsbAsyncApiTransferFunction::OnCompleted(UsbTransferStatus status,
scoped_refptr<net::IOBuffer> data,
size_t length) {
- if (status != usb_service::USB_TRANSFER_COMPLETED)
+ if (status != device::USB_TRANSFER_COMPLETED)
SetError(ConvertTransferStatusToErrorString(status));
SetResult(CreateTransferInfo(status, data, length));
diff --git a/extensions/browser/api/usb/usb_api.h b/extensions/browser/api/usb/usb_api.h
index 1549f97..fd02d80 100644
--- a/extensions/browser/api/usb/usb_api.h
+++ b/extensions/browser/api/usb/usb_api.h
@@ -10,9 +10,9 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "components/usb_service/usb_device.h"
-#include "components/usb_service/usb_device_filter.h"
-#include "components/usb_service/usb_device_handle.h"
+#include "device/usb/usb_device.h"
+#include "device/usb/usb_device_filter.h"
+#include "device/usb/usb_device_handle.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/async_api_function.h"
#include "extensions/common/api/usb.h"
@@ -34,17 +34,15 @@ class UsbAsyncApiFunction : public AsyncApiFunction {
static void CreateDeviceFilter(
const extensions::core_api::usb::DeviceFilter& input,
- usb_service::UsbDeviceFilter* output);
+ device::UsbDeviceFilter* output);
- bool HasDevicePermission(scoped_refptr<usb_service::UsbDevice> device);
+ bool HasDevicePermission(scoped_refptr<device::UsbDevice> device);
- scoped_refptr<usb_service::UsbDevice> GetDeviceOrCompleteWithError(
+ scoped_refptr<device::UsbDevice> GetDeviceOrCompleteWithError(
const extensions::core_api::usb::Device& input_device);
- scoped_refptr<usb_service::UsbDeviceHandle>
- GetDeviceHandleOrCompleteWithError(
- const extensions::core_api::usb::ConnectionHandle&
- input_device_handle);
+ scoped_refptr<device::UsbDeviceHandle> GetDeviceHandleOrCompleteWithError(
+ const extensions::core_api::usb::ConnectionHandle& input_device_handle);
void RemoveUsbDeviceResource(int api_resource_id);
@@ -59,15 +57,15 @@ class UsbAsyncApiTransferFunction : public UsbAsyncApiFunction {
virtual ~UsbAsyncApiTransferFunction();
bool ConvertDirectionSafely(const extensions::core_api::usb::Direction& input,
- usb_service::UsbEndpointDirection* output);
+ device::UsbEndpointDirection* output);
bool ConvertRequestTypeSafely(
const extensions::core_api::usb::RequestType& input,
- usb_service::UsbDeviceHandle::TransferRequestType* output);
+ device::UsbDeviceHandle::TransferRequestType* output);
bool ConvertRecipientSafely(
const extensions::core_api::usb::Recipient& input,
- usb_service::UsbDeviceHandle::TransferRecipient* output);
+ device::UsbDeviceHandle::TransferRecipient* output);
- void OnCompleted(usb_service::UsbTransferStatus status,
+ void OnCompleted(device::UsbTransferStatus status,
scoped_refptr<net::IOBuffer> data,
size_t length);
};
@@ -86,9 +84,9 @@ class UsbFindDevicesFunction : public UsbAsyncApiFunction {
private:
void OpenDevices(
- scoped_ptr<std::vector<scoped_refptr<usb_service::UsbDevice> > > devices);
+ scoped_ptr<std::vector<scoped_refptr<device::UsbDevice> > > devices);
- std::vector<scoped_refptr<usb_service::UsbDeviceHandle> > device_handles_;
+ std::vector<scoped_refptr<device::UsbDeviceHandle> > device_handles_;
scoped_ptr<extensions::core_api::usb::FindDevices::Params> parameters_;
};
@@ -106,7 +104,7 @@ class UsbGetDevicesFunction : public UsbAsyncApiFunction {
private:
void EnumerationCompletedFileThread(
- scoped_ptr<std::vector<scoped_refptr<usb_service::UsbDevice> > > devices);
+ scoped_ptr<std::vector<scoped_refptr<device::UsbDevice> > > devices);
scoped_ptr<extensions::core_api::usb::GetDevices::Params> parameters_;
};
@@ -142,7 +140,7 @@ class UsbOpenDeviceFunction : public UsbAsyncApiFunction {
virtual ~UsbOpenDeviceFunction();
private:
- scoped_refptr<usb_service::UsbDeviceHandle> handle_;
+ scoped_refptr<device::UsbDeviceHandle> handle_;
scoped_ptr<extensions::core_api::usb::OpenDevice::Params> parameters_;
};
@@ -159,15 +157,15 @@ class UsbListInterfacesFunction : public UsbAsyncApiFunction {
virtual void AsyncWorkStart() OVERRIDE;
private:
- bool ConvertDirectionSafely(const usb_service::UsbEndpointDirection& input,
+ bool ConvertDirectionSafely(const device::UsbEndpointDirection& input,
extensions::core_api::usb::Direction* output);
bool ConvertSynchronizationTypeSafely(
- const usb_service::UsbSynchronizationType& input,
+ const device::UsbSynchronizationType& input,
extensions::core_api::usb::SynchronizationType* output);
bool ConvertTransferTypeSafely(
- const usb_service::UsbTransferType& input,
+ const device::UsbTransferType& input,
extensions::core_api::usb::TransferType* output);
- bool ConvertUsageTypeSafely(const usb_service::UsbUsageType& input,
+ bool ConvertUsageTypeSafely(const device::UsbUsageType& input,
extensions::core_api::usb::UsageType* output);
scoped_ptr<base::ListValue> result_;
diff --git a/extensions/browser/api/usb/usb_apitest.cc b/extensions/browser/api/usb/usb_apitest.cc
index ee2fc6d..c3cd1a1 100644
--- a/extensions/browser/api/usb/usb_apitest.cc
+++ b/extensions/browser/api/usb/usb_apitest.cc
@@ -4,9 +4,9 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/ui/browser.h"
-#include "components/usb_service/usb_service.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h"
+#include "device/usb/usb_service.h"
#include "extensions/browser/api/usb/usb_api.h"
#include "net/base/io_buffer.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -15,13 +15,13 @@ using testing::AnyNumber;
using testing::_;
using testing::Return;
using content::BrowserThread;
-using usb_service::UsbConfigDescriptor;
-using usb_service::UsbDevice;
-using usb_service::UsbDeviceHandle;
-using usb_service::UsbEndpointDirection;
-using usb_service::UsbInterfaceDescriptor;
-using usb_service::UsbService;
-using usb_service::UsbTransferCallback;
+using device::UsbConfigDescriptor;
+using device::UsbDevice;
+using device::UsbDeviceHandle;
+using device::UsbEndpointDirection;
+using device::UsbInterfaceDescriptor;
+using device::UsbService;
+using device::UsbTransferCallback;
namespace {
@@ -218,11 +218,9 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, ResetDevice) {
EXPECT_CALL(*mock_device_handle_.get(), ResetDevice())
.WillOnce(Return(true))
.WillOnce(Return(false));
- EXPECT_CALL(
- *mock_device_handle_.get(),
- InterruptTransfer(usb_service::USB_DIRECTION_OUTBOUND, 2, _, 1, _, _))
- .WillOnce(
- InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_COMPLETED));
+ EXPECT_CALL(*mock_device_handle_.get(),
+ InterruptTransfer(device::USB_DIRECTION_OUTBOUND, 2, _, 1, _, _))
+ .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_COMPLETED));
ASSERT_TRUE(RunExtensionTest("usb/reset_device"));
}
@@ -238,7 +236,7 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, ListInterfaces) {
IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferEvent) {
EXPECT_CALL(*mock_device_handle_.get(),
- ControlTransfer(usb_service::USB_DIRECTION_OUTBOUND,
+ ControlTransfer(device::USB_DIRECTION_OUTBOUND,
UsbDeviceHandle::STANDARD,
UsbDeviceHandle::DEVICE,
1,
@@ -248,41 +246,33 @@ IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferEvent) {
1,
_,
_))
- .WillOnce(
- InvokeUsbTransferCallback<9>(usb_service::USB_TRANSFER_COMPLETED));
+ .WillOnce(InvokeUsbTransferCallback<9>(device::USB_TRANSFER_COMPLETED));
EXPECT_CALL(*mock_device_handle_.get(),
- BulkTransfer(usb_service::USB_DIRECTION_OUTBOUND, 1, _, 1, _, _))
- .WillOnce(
- InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_COMPLETED));
+ BulkTransfer(device::USB_DIRECTION_OUTBOUND, 1, _, 1, _, _))
+ .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_COMPLETED));
+ EXPECT_CALL(*mock_device_handle_.get(),
+ InterruptTransfer(device::USB_DIRECTION_OUTBOUND, 2, _, 1, _, _))
+ .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_COMPLETED));
EXPECT_CALL(
*mock_device_handle_.get(),
- InterruptTransfer(usb_service::USB_DIRECTION_OUTBOUND, 2, _, 1, _, _))
- .WillOnce(
- InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_COMPLETED));
- EXPECT_CALL(*mock_device_handle_.get(),
- IsochronousTransfer(
- usb_service::USB_DIRECTION_OUTBOUND, 3, _, 1, 1, 1, _, _))
- .WillOnce(
- InvokeUsbTransferCallback<7>(usb_service::USB_TRANSFER_COMPLETED));
+ IsochronousTransfer(device::USB_DIRECTION_OUTBOUND, 3, _, 1, 1, 1, _, _))
+ .WillOnce(InvokeUsbTransferCallback<7>(device::USB_TRANSFER_COMPLETED));
EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber());
ASSERT_TRUE(RunExtensionTest("usb/transfer_event"));
}
IN_PROC_BROWSER_TEST_F(UsbApiTest, ZeroLengthTransfer) {
EXPECT_CALL(*mock_device_handle_.get(), BulkTransfer(_, _, _, 0, _, _))
- .WillOnce(
- InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_COMPLETED));
+ .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_COMPLETED));
EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber());
ASSERT_TRUE(RunExtensionTest("usb/zero_length_transfer"));
}
IN_PROC_BROWSER_TEST_F(UsbApiTest, TransferFailure) {
EXPECT_CALL(*mock_device_handle_.get(), BulkTransfer(_, _, _, _, _, _))
- .WillOnce(
- InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_COMPLETED))
- .WillOnce(InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_ERROR))
- .WillOnce(
- InvokeUsbTransferCallback<5>(usb_service::USB_TRANSFER_TIMEOUT));
+ .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_COMPLETED))
+ .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_ERROR))
+ .WillOnce(InvokeUsbTransferCallback<5>(device::USB_TRANSFER_TIMEOUT));
EXPECT_CALL(*mock_device_handle_.get(), Close()).Times(AnyNumber());
ASSERT_TRUE(RunExtensionTest("usb/transfer_failure"));
}
diff --git a/extensions/browser/api/usb/usb_device_resource.cc b/extensions/browser/api/usb/usb_device_resource.cc
index 030de7b..347a1a7 100644
--- a/extensions/browser/api/usb/usb_device_resource.cc
+++ b/extensions/browser/api/usb/usb_device_resource.cc
@@ -10,13 +10,13 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/synchronization/lock.h"
-#include "components/usb_service/usb_device_handle.h"
#include "content/public/browser/browser_thread.h"
+#include "device/usb/usb_device_handle.h"
#include "extensions/browser/api/api_resource.h"
#include "extensions/common/api/usb.h"
using content::BrowserThread;
-using usb_service::UsbDeviceHandle;
+using device::UsbDeviceHandle;
namespace extensions {
diff --git a/extensions/browser/api/usb/usb_device_resource.h b/extensions/browser/api/usb/usb_device_resource.h
index cb6cbbe..dfa4bf4 100644
--- a/extensions/browser/api/usb/usb_device_resource.h
+++ b/extensions/browser/api/usb/usb_device_resource.h
@@ -12,8 +12,8 @@
#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
-#include "components/usb_service/usb_device_handle.h"
#include "content/public/browser/browser_thread.h"
+#include "device/usb/usb_device_handle.h"
#include "extensions/browser/api/api_resource.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/common/api/usb.h"
@@ -28,10 +28,10 @@ namespace extensions {
class UsbDeviceResource : public ApiResource {
public:
UsbDeviceResource(const std::string& owner_extension_id,
- scoped_refptr<usb_service::UsbDeviceHandle> device);
+ scoped_refptr<device::UsbDeviceHandle> device);
virtual ~UsbDeviceResource();
- scoped_refptr<usb_service::UsbDeviceHandle> device() { return device_; }
+ scoped_refptr<device::UsbDeviceHandle> device() { return device_; }
static const content::BrowserThread::ID kThreadId =
content::BrowserThread::FILE;
@@ -40,7 +40,7 @@ class UsbDeviceResource : public ApiResource {
friend class ApiResourceManager<UsbDeviceResource>;
static const char* service_name() { return "UsbDeviceResourceManager"; }
- scoped_refptr<usb_service::UsbDeviceHandle> device_;
+ scoped_refptr<device::UsbDeviceHandle> device_;
DISALLOW_COPY_AND_ASSIGN(UsbDeviceResource);
};
diff --git a/extensions/browser/api/usb_private/DEPS b/extensions/browser/api/usb_private/DEPS
index 1afc5ec..dce2c70 100644
--- a/extensions/browser/api/usb_private/DEPS
+++ b/extensions/browser/api/usb_private/DEPS
@@ -1,5 +1,4 @@
include_rules = [
- "+components/usb_service",
"+device/core",
"+device/usb",
]
diff --git a/extensions/browser/api/usb_private/usb_private_api.cc b/extensions/browser/api/usb_private/usb_private_api.cc
index ae523d6..dd29fd2 100644
--- a/extensions/browser/api/usb_private/usb_private_api.cc
+++ b/extensions/browser/api/usb_private/usb_private_api.cc
@@ -9,11 +9,11 @@
#include "base/memory/ref_counted.h"
#include "base/strings/utf_string_conversions.h"
-#include "components/usb_service/usb_device_filter.h"
-#include "components/usb_service/usb_device_handle.h"
-#include "components/usb_service/usb_service.h"
#include "device/core/device_client.h"
+#include "device/usb/usb_device_filter.h"
+#include "device/usb/usb_device_handle.h"
#include "device/usb/usb_ids.h"
+#include "device/usb/usb_service.h"
#include "extensions/common/api/usb_private.h"
namespace usb = extensions::core_api::usb;
@@ -22,10 +22,10 @@ namespace GetDevices = usb_private::GetDevices;
namespace GetDeviceInfo = usb_private::GetDeviceInfo;
using content::BrowserThread;
-using usb_service::UsbDevice;
-using usb_service::UsbDeviceFilter;
-using usb_service::UsbDeviceHandle;
-using usb_service::UsbService;
+using device::UsbDevice;
+using device::UsbDeviceFilter;
+using device::UsbDeviceHandle;
+using device::UsbService;
typedef std::vector<scoped_refptr<UsbDevice> > DeviceVector;
diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp
index 91b7c23..3e80dc0 100644
--- a/extensions/extensions.gyp
+++ b/extensions/extensions.gyp
@@ -270,7 +270,6 @@
'../components/components.gyp:keyed_service_core',
'../components/components.gyp:pref_registry',
'../components/components.gyp:sessions',
- '../components/components.gyp:usb_service',
'../components/components.gyp:web_modal',
'../content/content.gyp:content_browser',
'../device/bluetooth/bluetooth.gyp:device_bluetooth',
@@ -623,7 +622,6 @@
['exclude', '^browser/'],
],
'dependencies!': [
- '../components/components.gyp:usb_service',
'../device/bluetooth/bluetooth.gyp:device_bluetooth',
'../device/serial/serial.gyp:device_serial',
],
diff --git a/extensions/shell/browser/DEPS b/extensions/shell/browser/DEPS
index a98697b..bf7784a6 100644
--- a/extensions/shell/browser/DEPS
+++ b/extensions/shell/browser/DEPS
@@ -14,9 +14,9 @@ include_rules = [
"+content/shell/browser/shell_net_log.h",
# For device backend support.
- "+components/usb_service",
"+device/core",
"+device/hid",
+ "+device/usb",
# Only used in API tests that should be moved to extensions/browser/api/...
"+net",
diff --git a/extensions/shell/browser/shell_device_client.cc b/extensions/shell/browser/shell_device_client.cc
index 3120c01..b3c8168 100644
--- a/extensions/shell/browser/shell_device_client.cc
+++ b/extensions/shell/browser/shell_device_client.cc
@@ -5,8 +5,8 @@
#include "extensions/shell/browser/shell_device_client.h"
#include "base/logging.h"
-#include "components/usb_service/usb_service.h"
#include "content/public/browser/browser_thread.h"
+#include "device/usb/usb_service.h"
namespace extensions {
@@ -14,8 +14,8 @@ ShellDeviceClient::ShellDeviceClient() {}
ShellDeviceClient::~ShellDeviceClient() {}
-usb_service::UsbService* ShellDeviceClient::GetUsbService() {
- return usb_service::UsbService::GetInstance(
+device::UsbService* ShellDeviceClient::GetUsbService() {
+ return device::UsbService::GetInstance(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI));
}
diff --git a/extensions/shell/browser/shell_device_client.h b/extensions/shell/browser/shell_device_client.h
index d34e3ca..862d609 100644
--- a/extensions/shell/browser/shell_device_client.h
+++ b/extensions/shell/browser/shell_device_client.h
@@ -20,7 +20,7 @@ class ShellDeviceClient : device::DeviceClient {
virtual ~ShellDeviceClient();
// device::DeviceClient implementation
- virtual usb_service::UsbService* GetUsbService() OVERRIDE;
+ virtual device::UsbService* GetUsbService() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ShellDeviceClient);