 Chromium Code Reviews
 Chromium Code Reviews Issue 1291753004:
  Add onconnect and ondisconnect events to navigator.usb.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 1291753004:
  Add onconnect and ondisconnect events to navigator.usb.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "config.h" | 5 #include "config.h" | 
| 6 #include "modules/webusb/USB.h" | 6 #include "modules/webusb/USB.h" | 
| 7 | 7 | 
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" | 
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 
| 11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" | 
| 12 #include "core/dom/Document.h" | 12 #include "core/dom/Document.h" | 
| 13 #include "core/dom/ExceptionCode.h" | 13 #include "core/dom/ExceptionCode.h" | 
| 14 #include "modules/EventTargetModules.h" | |
| 14 #include "modules/webusb/USBDevice.h" | 15 #include "modules/webusb/USBDevice.h" | 
| 15 #include "modules/webusb/USBDeviceFilter.h" | 16 #include "modules/webusb/USBDeviceFilter.h" | 
| 16 #include "modules/webusb/USBDeviceRequestOptions.h" | 17 #include "modules/webusb/USBDeviceRequestOptions.h" | 
| 17 #include "modules/webusb/USBError.h" | 18 #include "modules/webusb/USBError.h" | 
| 18 #include "public/platform/Platform.h" | 19 #include "public/platform/Platform.h" | 
| 19 #include "public/platform/WebVector.h" | 20 #include "public/platform/WebVector.h" | 
| 20 #include "public/platform/modules/webusb/WebUSBClient.h" | 21 #include "public/platform/modules/webusb/WebUSBClient.h" | 
| 21 #include "public/platform/modules/webusb/WebUSBDeviceFilter.h" | 22 #include "public/platform/modules/webusb/WebUSBDeviceFilter.h" | 
| 22 #include "public/platform/modules/webusb/WebUSBDeviceRequestOptions.h" | 23 #include "public/platform/modules/webusb/WebUSBDeviceRequestOptions.h" | 
| 23 #include "public/platform/modules/webusb/WebUSBError.h" | 24 #include "public/platform/modules/webusb/WebUSBError.h" | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | 102 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; | 
| 102 ScriptPromise promise = resolver->promise(); | 103 ScriptPromise promise = resolver->promise(); | 
| 103 | 104 | 
| 104 WebUSBDeviceRequestOptions webOptions; | 105 WebUSBDeviceRequestOptions webOptions; | 
| 105 convertDeviceRequestOptions(options, &webOptions); | 106 convertDeviceRequestOptions(options, &webOptions); | 
| 106 client->requestDevice(webOptions, new CallbackPromiseAdapter<USBDevice, USBE rror>(resolver)); | 107 client->requestDevice(webOptions, new CallbackPromiseAdapter<USBDevice, USBE rror>(resolver)); | 
| 107 | 108 | 
| 108 return promise; | 109 return promise; | 
| 109 } | 110 } | 
| 110 | 111 | 
| 112 ExecutionContext* USB::executionContext() const | |
| 113 { | |
| 114 return m_controller->frame()->document(); | |
| 
haraken
2015/08/20 00:31:31
m_controller->frame() can be null if the frame was
 | |
| 115 } | |
| 116 | |
| 117 const AtomicString& USB::interfaceName() const | |
| 118 { | |
| 119 return EventTargetNames::USB; | |
| 120 } | |
| 121 | |
| 111 DEFINE_TRACE(USB) | 122 DEFINE_TRACE(USB) | 
| 112 { | 123 { | 
| 113 visitor->trace(m_controller); | 124 visitor->trace(m_controller); | 
| 125 RefCountedGarbageCollectedEventTargetWithInlineData<USB>::trace(visitor); | |
| 114 } | 126 } | 
| 115 | 127 | 
| 116 } // namespace blink | 128 } // namespace blink | 
| OLD | NEW |