OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 BluetoothDevice_h | 5 #ifndef BluetoothDevice_h |
6 #define BluetoothDevice_h | 6 #define BluetoothDevice_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
9 #include "core/dom/ContextLifecycleObserver.h" | 9 #include "core/dom/ContextLifecycleObserver.h" |
10 #include "modules/EventTargetModules.h" | 10 #include "modules/EventTargetModules.h" |
11 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" | 11 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" |
12 #include "platform/heap/Heap.h" | 12 #include "platform/heap/Heap.h" |
13 #include "public/platform/modules/bluetooth/WebBluetoothDevice.h" | 13 #include "public/platform/modules/bluetooth/WebBluetoothDevice.h" |
14 #include "public/platform/modules/bluetooth/WebBluetoothDeviceInit.h" | 14 #include "public/platform/modules/bluetooth/WebBluetoothDeviceInit.h" |
15 #include "wtf/text/WTFString.h" | 15 #include "wtf/text/WTFString.h" |
16 #include <memory> | 16 #include <memory> |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 class BluetoothAttributeInstanceMap; | 20 class BluetoothAttributeInstanceMap; |
21 class BluetoothRemoteGATTCharacteristic; | 21 class BluetoothRemoteGATTCharacteristic; |
| 22 class BluetoothRemoteGATTDescriptor; |
22 class BluetoothRemoteGATTServer; | 23 class BluetoothRemoteGATTServer; |
23 class BluetoothRemoteGATTService; | 24 class BluetoothRemoteGATTService; |
24 class ScriptPromise; | 25 class ScriptPromise; |
25 class ScriptPromiseResolver; | 26 class ScriptPromiseResolver; |
26 | 27 |
27 struct WebBluetoothRemoteGATTCharacteristicInit; | 28 struct WebBluetoothRemoteGATTCharacteristicInit; |
| 29 struct WebBluetoothRemoteGATTDescriptorInit; |
28 struct WebBluetoothRemoteGATTService; | 30 struct WebBluetoothRemoteGATTService; |
29 | 31 |
30 // BluetoothDevice represents a physical bluetooth device in the DOM. See IDL. | 32 // BluetoothDevice represents a physical bluetooth device in the DOM. See IDL. |
31 // | 33 // |
32 // Callbacks providing WebBluetoothDevice objects are handled by | 34 // Callbacks providing WebBluetoothDevice objects are handled by |
33 // CallbackPromiseAdapter templatized with this class. See this class's | 35 // CallbackPromiseAdapter templatized with this class. See this class's |
34 // "Interface required by CallbackPromiseAdapter" section and the | 36 // "Interface required by CallbackPromiseAdapter" section and the |
35 // CallbackPromiseAdapter class comments. | 37 // CallbackPromiseAdapter class comments. |
36 class BluetoothDevice final : public EventTargetWithInlineData, | 38 class BluetoothDevice final : public EventTargetWithInlineData, |
37 public ContextLifecycleObserver, | 39 public ContextLifecycleObserver, |
(...skipping 14 matching lines...) Expand all Loading... |
52 std::unique_ptr<WebBluetoothRemoteGATTService>); | 54 std::unique_ptr<WebBluetoothRemoteGATTService>); |
53 bool isValidService(const String& serviceInstanceId); | 55 bool isValidService(const String& serviceInstanceId); |
54 | 56 |
55 BluetoothRemoteGATTCharacteristic* | 57 BluetoothRemoteGATTCharacteristic* |
56 getOrCreateBluetoothRemoteGATTCharacteristic( | 58 getOrCreateBluetoothRemoteGATTCharacteristic( |
57 ExecutionContext*, | 59 ExecutionContext*, |
58 std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit>, | 60 std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit>, |
59 BluetoothRemoteGATTService*); | 61 BluetoothRemoteGATTService*); |
60 bool isValidCharacteristic(const String& characteristicInstanceId); | 62 bool isValidCharacteristic(const String& characteristicInstanceId); |
61 | 63 |
| 64 BluetoothRemoteGATTDescriptor* getOrCreateBluetoothRemoteGATTDescriptor( |
| 65 std::unique_ptr<WebBluetoothRemoteGATTDescriptorInit>, |
| 66 BluetoothRemoteGATTCharacteristic*); |
| 67 bool isValidDescriptor(const String& descriptorInstanceId); |
| 68 |
62 // We should disconnect from the device in all of the following cases: | 69 // We should disconnect from the device in all of the following cases: |
63 // 1. When the object gets GarbageCollected e.g. it went out of scope. | 70 // 1. When the object gets GarbageCollected e.g. it went out of scope. |
64 // dispose() is called in this case. | 71 // dispose() is called in this case. |
65 // 2. When the parent document gets detached e.g. reloading a page. | 72 // 2. When the parent document gets detached e.g. reloading a page. |
66 // stop() is called in this case. | 73 // stop() is called in this case. |
67 // TODO(ortuno): Users should be able to turn on notifications for | 74 // TODO(ortuno): Users should be able to turn on notifications for |
68 // events on navigator.bluetooth and still remain connected even if the | 75 // events on navigator.bluetooth and still remain connected even if the |
69 // BluetoothDevice object is garbage collected. | 76 // BluetoothDevice object is garbage collected. |
70 | 77 |
71 // USING_PRE_FINALIZER interface. | 78 // USING_PRE_FINALIZER interface. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Holds all GATT Attributes associated with this BluetoothDevice. | 113 // Holds all GATT Attributes associated with this BluetoothDevice. |
107 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap; | 114 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap; |
108 | 115 |
109 std::unique_ptr<WebBluetoothDeviceInit> m_webDevice; | 116 std::unique_ptr<WebBluetoothDeviceInit> m_webDevice; |
110 Member<BluetoothRemoteGATTServer> m_gatt; | 117 Member<BluetoothRemoteGATTServer> m_gatt; |
111 }; | 118 }; |
112 | 119 |
113 } // namespace blink | 120 } // namespace blink |
114 | 121 |
115 #endif // BluetoothDevice_h | 122 #endif // BluetoothDevice_h |
OLD | NEW |