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 "modules/webusb/USBController.h" | 11 #include "modules/webusb/USBController.h" |
11 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 class LocalFrame; | 16 class LocalFrame; |
16 class ScriptState; | 17 class ScriptState; |
17 class USBDeviceRequestOptions; | 18 class USBDeviceRequestOptions; |
18 | 19 |
19 class USB final | 20 class USB final |
20 : public GarbageCollectedFinalized<USB> | 21 : public RefCountedGarbageCollectedEventTargetWithInlineData<USB> { |
21 , public ScriptWrappable { | |
22 DEFINE_WRAPPERTYPEINFO(); | 22 DEFINE_WRAPPERTYPEINFO(); |
| 23 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(USB); |
| 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(USB); |
23 public: | 25 public: |
24 static USB* create(LocalFrame& frame) | 26 static USB* create(LocalFrame& frame) |
25 { | 27 { |
26 return new USB(frame); | 28 return new USB(frame); |
27 } | 29 } |
28 | 30 |
29 explicit USB(LocalFrame& frame); | 31 explicit USB(LocalFrame& frame); |
30 | 32 |
| 33 // USB.idl |
31 ScriptPromise getDevices(ScriptState*); | 34 ScriptPromise getDevices(ScriptState*); |
32 ScriptPromise requestDevice(ScriptState*, const USBDeviceRequestOptions&); | 35 ScriptPromise requestDevice(ScriptState*, const USBDeviceRequestOptions&); |
| 36 DEFINE_ATTRIBUTE_EVENT_LISTENER(connect); |
| 37 DEFINE_ATTRIBUTE_EVENT_LISTENER(disconnect); |
| 38 |
| 39 // EventTarget overrides. |
| 40 ExecutionContext* executionContext() const override; |
| 41 const AtomicString& interfaceName() const override; |
33 | 42 |
34 DECLARE_VIRTUAL_TRACE(); | 43 DECLARE_VIRTUAL_TRACE(); |
35 | 44 |
36 private: | 45 private: |
37 RawPtrWillBeMember<USBController> m_controller; | 46 RawPtrWillBeMember<USBController> m_controller; |
38 }; | 47 }; |
39 | 48 |
40 } // namespace blink | 49 } // namespace blink |
41 | 50 |
42 #endif // USB_h | 51 #endif // USB_h |
OLD | NEW |