| 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 BluetoothRemoteGATTService_h | 5 #ifndef BluetoothRemoteGATTService_h |
| 6 #define BluetoothRemoteGATTService_h | 6 #define BluetoothRemoteGATTService_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 "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
| 11 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTService.h" | 11 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTService.h" |
| 12 #include "public/platform/modules/bluetooth/web_bluetooth.mojom.h" | 12 #include "public/platform/modules/bluetooth/web_bluetooth.mojom.h" |
| 13 #include "wtf/OwnPtr.h" | |
| 14 #include "wtf/PassOwnPtr.h" | |
| 15 #include "wtf/text/WTFString.h" | 13 #include "wtf/text/WTFString.h" |
| 14 #include <memory> |
| 16 | 15 |
| 17 namespace blink { | 16 namespace blink { |
| 18 | 17 |
| 19 class ScriptPromise; | 18 class ScriptPromise; |
| 20 class ScriptPromiseResolver; | 19 class ScriptPromiseResolver; |
| 21 class ScriptState; | 20 class ScriptState; |
| 22 | 21 |
| 23 // Represents a GATT Service within a Bluetooth Peripheral, a collection of | 22 // Represents a GATT Service within a Bluetooth Peripheral, a collection of |
| 24 // characteristics and relationships to other services that encapsulate the | 23 // characteristics and relationships to other services that encapsulate the |
| 25 // behavior of part of a device. | 24 // behavior of part of a device. |
| 26 // | 25 // |
| 27 // Callbacks providing WebBluetoothRemoteGATTService objects are handled by | 26 // Callbacks providing WebBluetoothRemoteGATTService objects are handled by |
| 28 // CallbackPromiseAdapter templatized with this class. See this class's | 27 // CallbackPromiseAdapter templatized with this class. See this class's |
| 29 // "Interface required by CallbackPromiseAdapter" section and the | 28 // "Interface required by CallbackPromiseAdapter" section and the |
| 30 // CallbackPromiseAdapter class comments. | 29 // CallbackPromiseAdapter class comments. |
| 31 class BluetoothRemoteGATTService final | 30 class BluetoothRemoteGATTService final |
| 32 : public GarbageCollectedFinalized<BluetoothRemoteGATTService> | 31 : public GarbageCollectedFinalized<BluetoothRemoteGATTService> |
| 33 , public ScriptWrappable { | 32 , public ScriptWrappable { |
| 34 DEFINE_WRAPPERTYPEINFO(); | 33 DEFINE_WRAPPERTYPEINFO(); |
| 35 public: | 34 public: |
| 36 explicit BluetoothRemoteGATTService(PassOwnPtr<WebBluetoothRemoteGATTService
>); | 35 explicit BluetoothRemoteGATTService(std::unique_ptr<WebBluetoothRemoteGATTSe
rvice>); |
| 37 | 36 |
| 38 // Interface required by CallbackPromiseAdapter: | 37 // Interface required by CallbackPromiseAdapter: |
| 39 using WebType = OwnPtr<WebBluetoothRemoteGATTService>; | 38 using WebType = std::unique_ptr<WebBluetoothRemoteGATTService>; |
| 40 static BluetoothRemoteGATTService* take(ScriptPromiseResolver*, PassOwnPtr<W
ebBluetoothRemoteGATTService>); | 39 static BluetoothRemoteGATTService* take(ScriptPromiseResolver*, std::unique_
ptr<WebBluetoothRemoteGATTService>); |
| 41 | 40 |
| 42 // Interface required by garbage collection. | 41 // Interface required by garbage collection. |
| 43 DEFINE_INLINE_TRACE() { } | 42 DEFINE_INLINE_TRACE() { } |
| 44 | 43 |
| 45 // IDL exposed interface: | 44 // IDL exposed interface: |
| 46 String uuid() { return m_webService->uuid; } | 45 String uuid() { return m_webService->uuid; } |
| 47 bool isPrimary() { return m_webService->isPrimary; } | 46 bool isPrimary() { return m_webService->isPrimary; } |
| 48 ScriptPromise getCharacteristic(ScriptState*, const StringOrUnsignedLong& ch
aracteristic, ExceptionState&); | 47 ScriptPromise getCharacteristic(ScriptState*, const StringOrUnsignedLong& ch
aracteristic, ExceptionState&); |
| 49 ScriptPromise getCharacteristics(ScriptState*, const StringOrUnsignedLong& c
haracteristic, ExceptionState&); | 48 ScriptPromise getCharacteristics(ScriptState*, const StringOrUnsignedLong& c
haracteristic, ExceptionState&); |
| 50 ScriptPromise getCharacteristics(ScriptState*, ExceptionState&); | 49 ScriptPromise getCharacteristics(ScriptState*, ExceptionState&); |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 ScriptPromise getCharacteristicsImpl(ScriptState*, mojom::WebBluetoothGATTQu
eryQuantity, String characteristicUUID = String()); | 52 ScriptPromise getCharacteristicsImpl(ScriptState*, mojom::WebBluetoothGATTQu
eryQuantity, String characteristicUUID = String()); |
| 54 | 53 |
| 55 OwnPtr<WebBluetoothRemoteGATTService> m_webService; | 54 std::unique_ptr<WebBluetoothRemoteGATTService> m_webService; |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 } // namespace blink | 57 } // namespace blink |
| 59 | 58 |
| 60 #endif // BluetoothRemoteGATTService_h | 59 #endif // BluetoothRemoteGATTService_h |
| OLD | NEW |