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..ca012cfe495b244ddb3c024162a0e8c6658a0b84 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,45 @@ 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. |
|
Jeffrey Yasskin
2016/01/21 23:44:33
We should allow folks to turn on notifications, li
ortuno
2016/01/22 21:34:12
Done.
|
| + // 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. When the tab is no longer in the foreground e.g. change tabs. |
|
Jeffrey Yasskin
2016/01/21 23:44:33
I'd phrase this something like "For now (https://c
ortuno
2016/01/22 21:34:12
Done.
|
| + // pageVisibilityChanged() is called in this case. |
| + // 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 |
| + |
| + // 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; } |