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