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

Unified Diff: Source/modules/webusb/USBController.cpp

Issue 1262163003: Add WebUSB bindings and client interface [part 1] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Handle null navigator.frame() without ASSERT Created 5 years, 5 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 | « Source/modules/webusb/USBController.h ('k') | Source/modules/webusb/USBDevice.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webusb/USBController.cpp
diff --git a/Source/modules/webusb/USBController.cpp b/Source/modules/webusb/USBController.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2dd4d1ed9970dabb2697dc623a613efedad9e83f
--- /dev/null
+++ b/Source/modules/webusb/USBController.cpp
@@ -0,0 +1,53 @@
+// 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 "config.h"
+#include "modules/webusb/USBController.h"
+
+#include "platform/RuntimeEnabledFeatures.h"
+#include "public/platform/modules/webusb/WebUSBClient.h"
+
+namespace blink {
+
+USBController::~USBController()
+{
+}
+
+void USBController::provideTo(LocalFrame& frame, WebUSBClient* client)
+{
+ ASSERT(RuntimeEnabledFeatures::webUSBEnabled());
+ USBController* controller = new USBController(frame, client);
+ WillBeHeapSupplement<LocalFrame>::provideTo(frame, supplementName(), adoptPtrWillBeNoop(controller));
+}
+
+USBController& USBController::from(LocalFrame& frame)
+{
+ USBController* controller = static_cast<USBController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName()));
+ ASSERT(controller);
+ return *controller;
+}
+
+const char* USBController::supplementName()
+{
+ return "USBController";
+}
+
+USBController::USBController(LocalFrame& frame, WebUSBClient* client)
+ : LocalFrameLifecycleObserver(&frame)
+ , m_client(client)
+{
+}
+
+void USBController::willDetachFrameHost()
+{
+ m_client = nullptr;
+}
+
+DEFINE_TRACE(USBController)
+{
+ WillBeHeapSupplement<LocalFrame>::trace(visitor);
+ LocalFrameLifecycleObserver::trace(visitor);
+}
+
+} // namespace blink
« no previous file with comments | « Source/modules/webusb/USBController.h ('k') | Source/modules/webusb/USBDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698