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