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/events/EventTarget.h" | 10 #include "core/events/EventTarget.h" |
| 11 #include "core/frame/LocalFrameLifecycleObserver.h" | 11 #include "core/frame/LocalFrameLifecycleObserver.h" |
| 12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 13 #include "platform/heap/ThreadState.h" | |
| 13 #include "public/platform/modules/webusb/WebUSBClient.h" | 14 #include "public/platform/modules/webusb/WebUSBClient.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class LocalFrame; | 18 class LocalFrame; |
| 18 class ScriptState; | 19 class ScriptState; |
| 19 class USBDeviceRequestOptions; | 20 class USBDeviceRequestOptions; |
| 20 class WebUSBDevice; | 21 class WebUSBDevice; |
| 21 | 22 |
| 22 class USB final | 23 class USB final |
| 23 : public RefCountedGarbageCollectedEventTargetWithInlineData<USB> | 24 : public RefCountedGarbageCollectedEventTargetWithInlineData<USB> |
| 24 , public LocalFrameLifecycleObserver | 25 , public LocalFrameLifecycleObserver |
| 25 , public WebUSBClient::Observer { | 26 , public WebUSBClient::Observer { |
| 26 DEFINE_WRAPPERTYPEINFO(); | 27 DEFINE_WRAPPERTYPEINFO(); |
| 27 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(USB); | 28 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(USB); |
| 28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(USB); | 29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(USB); |
| 30 WILL_BE_USING_PRE_FINALIZER(USB, dispose); | |
|
haraken
2016/04/01 01:12:44
You need to register the pre-finalizer. Otherwise,
Reilly Grant (use Gerrit)
2016/04/01 01:31:58
Done.
| |
| 29 public: | 31 public: |
| 30 static USB* create(LocalFrame& frame) | 32 static USB* create(LocalFrame& frame) |
| 31 { | 33 { |
| 32 return new USB(frame); | 34 return new USB(frame); |
| 33 } | 35 } |
| 34 | 36 |
| 35 ~USB() override; | 37 ~USB() override; |
| 36 | 38 |
| 39 void dispose(); | |
| 40 | |
| 37 // USB.idl | 41 // USB.idl |
| 38 ScriptPromise getDevices(ScriptState*); | 42 ScriptPromise getDevices(ScriptState*); |
| 39 ScriptPromise requestDevice(ScriptState*, const USBDeviceRequestOptions&); | 43 ScriptPromise requestDevice(ScriptState*, const USBDeviceRequestOptions&); |
| 40 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); | 44 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
| 41 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); | 45 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
| 42 | 46 |
| 43 // EventTarget overrides. | 47 // EventTarget overrides. |
| 44 ExecutionContext* getExecutionContext() const override; | 48 ExecutionContext* getExecutionContext() const override; |
| 45 const AtomicString& interfaceName() const override; | 49 const AtomicString& interfaceName() const override; |
| 46 | 50 |
| 47 // LocalFrameLifecycleObserver overrides. | 51 // LocalFrameLifecycleObserver overrides. |
| 48 void willDetachFrameHost() override; | 52 void willDetachFrameHost() override; |
| 49 | 53 |
| 50 // WebUSBClient::Observer overrides. | 54 // WebUSBClient::Observer overrides. |
| 51 void onDeviceConnected(WebPassOwnPtr<WebUSBDevice>) override; | 55 void onDeviceConnected(WebPassOwnPtr<WebUSBDevice>) override; |
| 52 void onDeviceDisconnected(WebPassOwnPtr<WebUSBDevice>) override; | 56 void onDeviceDisconnected(WebPassOwnPtr<WebUSBDevice>) override; |
| 53 | 57 |
| 54 DECLARE_VIRTUAL_TRACE(); | 58 DECLARE_VIRTUAL_TRACE(); |
| 55 | 59 |
| 56 private: | 60 private: |
| 57 explicit USB(LocalFrame& frame); | 61 explicit USB(LocalFrame& frame); |
| 58 | 62 |
| 59 WebUSBClient* m_client; | 63 WebUSBClient* m_client; |
| 60 }; | 64 }; |
| 61 | 65 |
| 62 } // namespace blink | 66 } // namespace blink |
| 63 | 67 |
| 64 #endif // USB_h | 68 #endif // USB_h |
| OLD | NEW |