| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 // We should disconnect from the device in all of the following cases: | 65 // We should disconnect from the device in all of the following cases: |
| 66 // 1. When the object gets GarbageCollected e.g. it went out of scope. | 66 // 1. When the object gets GarbageCollected e.g. it went out of scope. |
| 67 // dispose() is called in this case. | 67 // dispose() is called in this case. |
| 68 // 2. When the parent document gets detached e.g. reloading a page. | 68 // 2. When the parent document gets detached e.g. reloading a page. |
| 69 // stop() is called in this case. | 69 // stop() is called in this case. |
| 70 // TODO(ortuno): Users should be able to turn on notifications for | 70 // TODO(ortuno): Users should be able to turn on notifications for |
| 71 // events on navigator.bluetooth and still remain connected even if the | 71 // events on navigator.bluetooth and still remain connected even if the |
| 72 // BluetoothDevice object is garbage collected. | 72 // BluetoothDevice object is garbage collected. |
| 73 | 73 |
| 74 // Performs necessary cleanup when a device disconnects and fires | 74 // Performs necessary cleanup when a device disconnects. |
| 75 // gattserverdisconnected event. | 75 void ClearAttributeInstanceMap(); |
| 76 void ClearAttributeInstanceMapAndFireEvent(); | |
| 77 | 76 |
| 78 // EventTarget methods: | 77 // EventTarget methods: |
| 79 const AtomicString& interfaceName() const override; | 78 const AtomicString& interfaceName() const override; |
| 80 ExecutionContext* getExecutionContext() const override; | 79 ExecutionContext* getExecutionContext() const override; |
| 81 | 80 |
| 82 Bluetooth* bluetooth() { return m_bluetooth; } | 81 Bluetooth* bluetooth() { return m_bluetooth; } |
| 83 | 82 |
| 84 // Interface required by Garbage Collection: | 83 // Interface required by Garbage Collection: |
| 85 DECLARE_VIRTUAL_TRACE(); | 84 DECLARE_VIRTUAL_TRACE(); |
| 86 | 85 |
| 87 // IDL exposed interface: | 86 // IDL exposed interface: |
| 88 String id() { return m_device->id; } | 87 String id() { return m_device->id; } |
| 89 String name() { return m_device->name; } | 88 String name() { return m_device->name; } |
| 90 BluetoothRemoteGATTServer* gatt() { return m_gatt; } | 89 BluetoothRemoteGATTServer* gatt() { return m_gatt; } |
| 91 | 90 |
| 92 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected); | 91 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected); |
| 93 | 92 |
| 94 private: | 93 private: |
| 95 // Holds all GATT Attributes associated with this BluetoothDevice. | 94 // Holds all GATT Attributes associated with this BluetoothDevice. |
| 96 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap; | 95 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap; |
| 97 | 96 |
| 98 mojom::blink::WebBluetoothDevicePtr m_device; | 97 mojom::blink::WebBluetoothDevicePtr m_device; |
| 99 Member<BluetoothRemoteGATTServer> m_gatt; | 98 Member<BluetoothRemoteGATTServer> m_gatt; |
| 100 Member<Bluetooth> m_bluetooth; | 99 Member<Bluetooth> m_bluetooth; |
| 101 }; | 100 }; |
| 102 | 101 |
| 103 } // namespace blink | 102 } // namespace blink |
| 104 | 103 |
| 105 #endif // BluetoothDevice_h | 104 #endif // BluetoothDevice_h |
| OLD | NEW |