| 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" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // events on navigator.bluetooth and still remain connected even if the | 72 // events on navigator.bluetooth and still remain connected even if the |
| 73 // BluetoothDevice object is garbage collected. | 73 // BluetoothDevice object is garbage collected. |
| 74 | 74 |
| 75 // USING_PRE_FINALIZER interface. | 75 // USING_PRE_FINALIZER interface. |
| 76 // Called before the object gets garbage collected. | 76 // Called before the object gets garbage collected. |
| 77 void dispose(); | 77 void dispose(); |
| 78 | 78 |
| 79 // ContextLifecycleObserver interface. | 79 // ContextLifecycleObserver interface. |
| 80 void contextDestroyed(ExecutionContext*) override; | 80 void contextDestroyed(ExecutionContext*) override; |
| 81 | 81 |
| 82 // If gatt is connected then sets gatt.connected to false and disconnects. | |
| 83 // This function only performs the necessary steps to ensure a device | |
| 84 // disconnects therefore it should only be used when the object is being | |
| 85 // garbage collected or the context is being destroyed. | |
| 86 void disconnectGATTIfConnected(); | |
| 87 | |
| 88 // Performs necessary cleanup when a device disconnects and fires | 82 // Performs necessary cleanup when a device disconnects and fires |
| 89 // gattserverdisconnected event. | 83 // gattserverdisconnected event. |
| 90 void cleanupDisconnectedDeviceAndFireEvent(); | 84 void clearAttributeInstanceMapAndFireEvent(); |
| 91 | 85 |
| 92 // EventTarget methods: | 86 // EventTarget methods: |
| 93 const AtomicString& interfaceName() const override; | 87 const AtomicString& interfaceName() const override; |
| 94 ExecutionContext* getExecutionContext() const override; | 88 ExecutionContext* getExecutionContext() const override; |
| 95 | 89 |
| 96 void dispatchGattServerDisconnected(); | |
| 97 | |
| 98 Bluetooth* bluetooth() { return m_bluetooth; } | 90 Bluetooth* bluetooth() { return m_bluetooth; } |
| 99 | 91 |
| 100 // Interface required by Garbage Collection: | 92 // Interface required by Garbage Collection: |
| 101 DECLARE_VIRTUAL_TRACE(); | 93 DECLARE_VIRTUAL_TRACE(); |
| 102 | 94 |
| 103 // IDL exposed interface: | 95 // IDL exposed interface: |
| 104 String id() { return m_device->id; } | 96 String id() { return m_device->id; } |
| 105 String name() { return m_device->name; } | 97 String name() { return m_device->name; } |
| 106 BluetoothRemoteGATTServer* gatt() { return m_gatt; } | 98 BluetoothRemoteGATTServer* gatt() { return m_gatt; } |
| 107 | 99 |
| 108 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected); | 100 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected); |
| 109 | 101 |
| 110 private: | 102 private: |
| 111 // Holds all GATT Attributes associated with this BluetoothDevice. | 103 // Holds all GATT Attributes associated with this BluetoothDevice. |
| 112 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap; | 104 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap; |
| 113 | 105 |
| 114 mojom::blink::WebBluetoothDevicePtr m_device; | 106 mojom::blink::WebBluetoothDevicePtr m_device; |
| 115 Member<BluetoothRemoteGATTServer> m_gatt; | 107 Member<BluetoothRemoteGATTServer> m_gatt; |
| 116 Member<Bluetooth> m_bluetooth; | 108 Member<Bluetooth> m_bluetooth; |
| 117 }; | 109 }; |
| 118 | 110 |
| 119 } // namespace blink | 111 } // namespace blink |
| 120 | 112 |
| 121 #endif // BluetoothDevice_h | 113 #endif // BluetoothDevice_h |
| OLD | NEW |