Chromium Code Reviews| Index: third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.h |
| diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.h b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.h |
| index 5cad45982a6563fe2fce9cc1e2a4eee7f3fc7800..b1e1cee15dd960f3e05582fe1850c7a6940d391c 100644 |
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.h |
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.h |
| @@ -7,6 +7,8 @@ |
| #include "bindings/core/v8/ScriptWrappable.h" |
| #include "bindings/modules/v8/UnionTypesModules.h" |
| +#include "core/dom/ActiveDOMObject.h" |
| +#include "core/page/PageLifecycleObserver.h" |
| #include "platform/heap/Heap.h" |
| #include "public/platform/modules/bluetooth/WebBluetoothGATTRemoteServer.h" |
| #include "wtf/OwnPtr.h" |
| @@ -27,17 +29,49 @@ class ScriptState; |
| // CallbackPromiseAdapter class comments. |
| class BluetoothGATTRemoteServer final |
| : public GarbageCollectedFinalized<BluetoothGATTRemoteServer> |
| + , public ActiveDOMObject |
| + , public PageLifecycleObserver |
| , public ScriptWrappable { |
| + USING_PRE_FINALIZER(BluetoothGATTRemoteServer, dispose); |
| DEFINE_WRAPPERTYPEINFO(); |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(BluetoothGATTRemoteServer); |
| public: |
| - BluetoothGATTRemoteServer(PassOwnPtr<WebBluetoothGATTRemoteServer>); |
| + BluetoothGATTRemoteServer(ExecutionContext*, PassOwnPtr<WebBluetoothGATTRemoteServer>); |
| // Interface required by CallbackPromiseAdapter: |
| using WebType = OwnPtr<WebBluetoothGATTRemoteServer>; |
| static BluetoothGATTRemoteServer* take(ScriptPromiseResolver*, PassOwnPtr<WebBluetoothGATTRemoteServer>); |
| + // We should disconnect from the device in all of the following cases: |
| + // 1. When the object gets GarbageCollected e.g. it went out of scope. |
| + // dispose() is called in this case. |
| + // 2. When the parent document gets detached e.g. reloading a page. |
| + // stop() is called in this case. |
| + // 3. For now (https://crbug.com/579746), when the tab is no longer in the |
| + // foreground e.g. change tabs. |
| + // pageVisibilityChanged() is called in this case. |
| + // TODO(ortuno): Users should be able to turn on notifications listen for |
| + // events on navigator.bluetooth and still remain connected even if the |
| + // BluetoothGATTRemoteServer object is garbage collected. |
| + // TODO(ortuno): Allow connections when the tab is in the background. |
| + // This is a short term solution instead of implementing a tab indicator |
| + // for bluetooth connections. |
| + // https://crbug.com/579746 |
|
Jeffrey Yasskin
2016/01/22 21:59:02
You can probably remove this line.
ortuno
2016/01/22 22:18:14
Done.
|
| + |
| + // USING_PRE_FINALIZER interface. |
| + // Called before the object gets garbage collected. |
| + void dispose(); |
| + |
| + // ActiveDOMObject interface. |
| + void stop() override; |
| + |
| + // PageLifecycleObserver interface. |
| + void pageVisibilityChanged() override; |
| + |
| + void disconnectIfConnected(); |
| + |
| // Interface required by Garbage Collectoin: |
| - DEFINE_INLINE_TRACE() { } |
| + DECLARE_VIRTUAL_TRACE(); |
| // IDL exposed interface: |
| bool connected() { return m_webGATT->connected; } |