Chromium Code Reviews| 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 #ifndef USB_h | 5 #ifndef USB_h |
| 6 #define USB_h | 6 #define USB_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/dom/ContextLifecycleObserver.h" | |
| 10 #include "core/events/EventTarget.h" | 11 #include "core/events/EventTarget.h" |
| 11 #include "core/frame/LocalFrameLifecycleObserver.h" | |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 #include "public/platform/modules/webusb/WebUSBClient.h" | 13 #include "public/platform/modules/webusb/WebUSBClient.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class LocalFrame; | 17 class LocalFrame; |
| 18 class ScriptState; | 18 class ScriptState; |
| 19 class USBDeviceRequestOptions; | 19 class USBDeviceRequestOptions; |
| 20 class WebUSBDevice; | 20 class WebUSBDevice; |
| 21 | 21 |
| 22 class USB final | 22 class USB final |
| 23 : public RefCountedGarbageCollectedEventTargetWithInlineData<USB> | 23 : public RefCountedGarbageCollectedEventTargetWithInlineData<USB> |
| 24 , public LocalFrameLifecycleObserver | 24 , public ContextLifecycleObserver |
| 25 , public WebUSBClient::Observer { | 25 , public WebUSBClient::Observer { |
| 26 DEFINE_WRAPPERTYPEINFO(); | 26 DEFINE_WRAPPERTYPEINFO(); |
| 27 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(USB); | 27 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(USB); |
| 28 USING_GARBAGE_COLLECTED_MIXIN(USB); | 28 USING_GARBAGE_COLLECTED_MIXIN(USB); |
| 29 public: | 29 public: |
| 30 static USB* create(LocalFrame& frame) | 30 static USB* create(LocalFrame& frame) |
|
haraken
2016/04/06 01:15:42
Can you make USB::create take Document instead of
Reilly Grant (use Gerrit)
2016/04/06 01:21:56
I cannot because I need the USBController (or in t
| |
| 31 { | 31 { |
| 32 return new USB(frame); | 32 return new USB(frame); |
| 33 } | 33 } |
| 34 | 34 |
| 35 ~USB() override; | 35 ~USB() override; |
| 36 | 36 |
| 37 // USB.idl | 37 // USB.idl |
| 38 ScriptPromise getDevices(ScriptState*); | 38 ScriptPromise getDevices(ScriptState*); |
| 39 ScriptPromise requestDevice(ScriptState*, const USBDeviceRequestOptions&); | 39 ScriptPromise requestDevice(ScriptState*, const USBDeviceRequestOptions&); |
| 40 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 40 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
| 41 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 41 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
| 42 | 42 |
| 43 // EventTarget overrides. | 43 // EventTarget overrides. |
| 44 ExecutionContext* getExecutionContext() const override; | 44 ExecutionContext* getExecutionContext() const override; |
| 45 const AtomicString& interfaceName() const override; | 45 const AtomicString& interfaceName() const override; |
| 46 | 46 |
| 47 // LocalFrameLifecycleObserver overrides. | 47 // ContextLifecycleObserver overrides. |
| 48 void willDetachFrameHost() override; | 48 void contextDestroyed() override; |
| 49 | 49 |
| 50 // WebUSBClient::Observer overrides. | 50 // WebUSBClient::Observer overrides. |
| 51 void onDeviceConnected(WebPassOwnPtr<WebUSBDevice>) override; | 51 void onDeviceConnected(WebPassOwnPtr<WebUSBDevice>) override; |
| 52 void onDeviceDisconnected(WebPassOwnPtr<WebUSBDevice>) override; | 52 void onDeviceDisconnected(WebPassOwnPtr<WebUSBDevice>) override; |
| 53 | 53 |
| 54 DECLARE_VIRTUAL_TRACE(); | 54 DECLARE_VIRTUAL_TRACE(); |
| 55 EAGERLY_FINALIZE(); | 55 EAGERLY_FINALIZE(); |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 explicit USB(LocalFrame& frame); | 58 explicit USB(LocalFrame& frame); |
| 59 | 59 |
| 60 WebUSBClient* m_client; | 60 WebUSBClient* m_client; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| 64 | 64 |
| 65 #endif // USB_h | 65 #endif // USB_h |
| OLD | NEW |