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

Unified Diff: content/renderer/usb/web_usb_device_impl.cc

Issue 1293253002: Connect WebUSB client interface to the devices app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak in WeakBindingSet Created 5 years, 4 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 | « content/renderer/usb/web_usb_device_impl.h ('k') | device/devices_app/devices_app.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/usb/web_usb_device_impl.cc
diff --git a/content/renderer/usb/web_usb_device_impl.cc b/content/renderer/usb/web_usb_device_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e59d5bf5dcf844198c563ffde237ca372dce7e00
--- /dev/null
+++ b/content/renderer/usb/web_usb_device_impl.cc
@@ -0,0 +1,113 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/usb/web_usb_device_impl.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/renderer/usb/type_converters.h"
+#include "device/devices_app/public/cpp/constants.h"
+#include "mojo/application/public/cpp/connect.h"
+#include "mojo/application/public/interfaces/shell.mojom.h"
+#include "third_party/WebKit/public/platform/WebVector.h"
+#include "third_party/WebKit/public/platform/modules/webusb/WebUSBDeviceInfo.h"
+#include "third_party/WebKit/public/platform/modules/webusb/WebUSBTransferInfo.h"
+
+namespace content {
+
+namespace {
+
+const char kNotImplementedError[] = "Not implemented.";
+
+template <typename ResultType>
+void RejectAsNotImplemented(
+ blink::WebCallbacks<ResultType, const blink::WebUSBError&>* callbacks) {
+ callbacks->onError(
+ blink::WebUSBError(blink::WebUSBError::Error::Service,
+ base::UTF8ToUTF16(kNotImplementedError)));
+ delete callbacks;
+}
+
+} // namespace
+
+WebUSBDeviceImpl::WebUSBDeviceImpl(device::usb::DeviceManagerPtr device_manager,
+ const blink::WebUSBDeviceInfo& device_info)
+ : device_manager_(device_manager.Pass()),
+ device_info_(device_info),
+ weak_factory_(this) {}
+
+WebUSBDeviceImpl::~WebUSBDeviceImpl() {}
+
+const blink::WebUSBDeviceInfo& WebUSBDeviceImpl::info() const {
+ return device_info_;
+}
+
+void WebUSBDeviceImpl::open(blink::WebUSBDeviceOpenCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::close(blink::WebUSBDeviceCloseCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::setConfiguration(
+ uint8_t configuration_value,
+ blink::WebUSBDeviceSetConfigurationCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::claimInterface(
+ uint8_t interface_number,
+ blink::WebUSBDeviceClaimInterfaceCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::releaseInterface(
+ uint8_t interface_number,
+ blink::WebUSBDeviceReleaseInterfaceCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::setInterface(
+ uint8_t interface_number,
+ uint8_t alternate_setting,
+ blink::WebUSBDeviceSetInterfaceAlternateSettingCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::clearHalt(
+ uint8_t endpoint_number,
+ blink::WebUSBDeviceClearHaltCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::controlTransfer(
+ const blink::WebUSBDevice::ControlTransferParameters& parameters,
+ uint8_t* data,
+ size_t data_size,
+ unsigned int timeout,
+ blink::WebUSBDeviceControlTransferCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::transfer(
+ blink::WebUSBDevice::TransferDirection direction,
+ uint8_t endpoint_number,
+ uint8_t* data,
+ size_t data_size,
+ unsigned int timeout,
+ blink::WebUSBDeviceBulkTransferCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::reset(blink::WebUSBDeviceResetCallbacks* callbacks) {
+ RejectAsNotImplemented(callbacks);
+}
+
+void WebUSBDeviceImpl::OnConnectionError() {
+ device_.reset();
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/usb/web_usb_device_impl.h ('k') | device/devices_app/devices_app.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698