| 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 BluetoothRemoteGATTServer_h | 5 #ifndef BluetoothRemoteGATTServer_h |
| 6 #define BluetoothRemoteGATTServer_h | 6 #define BluetoothRemoteGATTServer_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 8 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "bindings/modules/v8/StringOrUnsignedLong.h" | 9 #include "bindings/modules/v8/StringOrUnsignedLong.h" |
| 10 #include "core/dom/ContextLifecycleObserver.h" | 10 #include "core/dom/ContextLifecycleObserver.h" |
| 11 #include "modules/bluetooth/BluetoothDevice.h" | 11 #include "modules/bluetooth/BluetoothDevice.h" |
| 12 #include "mojo/public/cpp/bindings/associated_binding_set.h" | 12 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 13 #include "platform/heap/Heap.h" | 13 #include "platform/heap/Heap.h" |
| 14 #include "public/platform/modules/bluetooth/web_bluetooth.mojom-blink.h" | 14 #include "public/platform/modules/bluetooth/web_bluetooth.mojom-blink.h" |
| 15 #include "wtf/text/WTFString.h" | 15 #include "wtf/text/WTFString.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class BluetoothDevice; | 19 class BluetoothDevice; |
| 20 class ScriptPromise; | 20 class ScriptPromise; |
| 21 class ScriptPromiseResolver; | 21 class ScriptPromiseResolver; |
| 22 class ScriptState; | 22 class ScriptState; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 // | 52 // |
| 53 // Adds |resolver| to the set of Active Algorithms. CHECK-fails if | 53 // Adds |resolver| to the set of Active Algorithms. CHECK-fails if |
| 54 // |resolver| was already added. | 54 // |resolver| was already added. |
| 55 void AddToActiveAlgorithms(ScriptPromiseResolver*); | 55 void AddToActiveAlgorithms(ScriptPromiseResolver*); |
| 56 // Removes |resolver| from the set of Active Algorithms if it was in the set | 56 // Removes |resolver| from the set of Active Algorithms if it was in the set |
| 57 // and returns true, false otherwise. | 57 // and returns true, false otherwise. |
| 58 bool RemoveFromActiveAlgorithms(ScriptPromiseResolver*); | 58 bool RemoveFromActiveAlgorithms(ScriptPromiseResolver*); |
| 59 // Removes all ScriptPromiseResolvers from the set of Active Algorithms. | 59 // Removes all ScriptPromiseResolvers from the set of Active Algorithms. |
| 60 void ClearActiveAlgorithms() { m_activeAlgorithms.clear(); } | 60 void ClearActiveAlgorithms() { m_activeAlgorithms.clear(); } |
| 61 | 61 |
| 62 // If gatt is connected then sets gatt.connected to false and disconnects. | 62 // Performs necessary cleanup when a device disconnects. If |dispatchEvent| |
| 63 // This function only performs the necessary steps to ensure a device | 63 // is true, dispatch a gattserverdisconnected event. |
| 64 // disconnects therefore it should only be used when the object is being | 64 void CleanupDisconnectedDevice(bool dispatchEvent); |
| 65 // garbage collected or the context is being destroyed. | |
| 66 void DisconnectIfConnected(); | |
| 67 | 65 |
| 68 // Performs necessary cleanup when a device disconnects and fires | 66 void HandleClientConnectionError(); |
| 69 // gattserverdisconnected event. | |
| 70 void CleanupDisconnectedDeviceAndFireEvent(); | |
| 71 | |
| 72 void DispatchDisconnected(); | |
| 73 | 67 |
| 74 // USING_PRE_FINALIZER interface. | 68 // USING_PRE_FINALIZER interface. |
| 75 // Called before the object gets garbage collected. | 69 // Called before the object gets garbage collected. |
| 76 void Dispose(); | 70 void Dispose(); |
| 77 | 71 |
| 78 // Interface required by Garbage Collectoin: | 72 // Interface required by Garbage Collectoin: |
| 79 DECLARE_VIRTUAL_TRACE(); | 73 DECLARE_VIRTUAL_TRACE(); |
| 80 | 74 |
| 81 // IDL exposed interface: | 75 // IDL exposed interface: |
| 82 BluetoothDevice* device() { return m_device; } | 76 BluetoothDevice* device() { return m_device; } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 104 mojom::blink::WebBluetoothGATTQueryQuantity, | 98 mojom::blink::WebBluetoothGATTQueryQuantity, |
| 105 ScriptPromiseResolver*, | 99 ScriptPromiseResolver*, |
| 106 mojom::blink::WebBluetoothResult, | 100 mojom::blink::WebBluetoothResult, |
| 107 Optional<Vector<mojom::blink::WebBluetoothRemoteGATTServicePtr>> | 101 Optional<Vector<mojom::blink::WebBluetoothRemoteGATTServicePtr>> |
| 108 services); | 102 services); |
| 109 | 103 |
| 110 // Contains a ScriptPromiseResolver corresponding to each active algorithm | 104 // Contains a ScriptPromiseResolver corresponding to each active algorithm |
| 111 // using this server’s connection. | 105 // using this server’s connection. |
| 112 HeapHashSet<Member<ScriptPromiseResolver>> m_activeAlgorithms; | 106 HeapHashSet<Member<ScriptPromiseResolver>> m_activeAlgorithms; |
| 113 | 107 |
| 114 mojo::AssociatedBindingSet<mojom::blink::WebBluetoothServerClient> | 108 mojo::AssociatedBinding<mojom::blink::WebBluetoothServerClient> |
| 115 m_clientBindings; | 109 m_clientBinding; |
| 116 | 110 |
| 117 Member<BluetoothDevice> m_device; | 111 Member<BluetoothDevice> m_device; |
| 118 bool m_connected; | 112 bool m_connected; |
| 119 }; | 113 }; |
| 120 | 114 |
| 121 } // namespace blink | 115 } // namespace blink |
| 122 | 116 |
| 123 #endif // BluetoothDevice_h | 117 #endif // BluetoothDevice_h |
| OLD | NEW |