| 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 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/bluetooth/BluetoothGATTCharacteristic.h" | 6 #include "modules/bluetooth/BluetoothGATTCharacteristic.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 11 #include "core/dom/DOMException.h" | 11 #include "core/dom/DOMException.h" |
| 12 #include "core/dom/ExceptionCode.h" | 12 #include "core/dom/ExceptionCode.h" |
| 13 #include "core/events/Event.h" | 13 #include "core/events/Event.h" |
| 14 #include "modules/bluetooth/BluetoothCharacteristicProperties.h" |
| 14 #include "modules/bluetooth/BluetoothError.h" | 15 #include "modules/bluetooth/BluetoothError.h" |
| 15 #include "modules/bluetooth/BluetoothSupplement.h" | 16 #include "modules/bluetooth/BluetoothSupplement.h" |
| 16 #include "modules/bluetooth/ConvertWebVectorToArrayBuffer.h" | 17 #include "modules/bluetooth/ConvertWebVectorToArrayBuffer.h" |
| 17 #include "public/platform/modules/bluetooth/WebBluetooth.h" | 18 #include "public/platform/modules/bluetooth/WebBluetooth.h" |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| 21 BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(ExecutionContext* conte
xt, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic) | 22 BluetoothGATTCharacteristic::BluetoothGATTCharacteristic(ExecutionContext* conte
xt, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic) |
| 22 : ActiveDOMObject(context) | 23 : ActiveDOMObject(context) |
| 23 , m_webCharacteristic(webCharacteristic) | 24 , m_webCharacteristic(webCharacteristic) |
| 24 , m_stopped(false) | 25 , m_stopped(false) |
| 25 { | 26 { |
| 27 m_properties = BluetoothCharacteristicProperties::create(m_webCharacteristic
->characteristicProperties); |
| 26 // See example in Source/platform/heap/ThreadState.h | 28 // See example in Source/platform/heap/ThreadState.h |
| 27 ThreadState::current()->registerPreFinalizer(this); | 29 ThreadState::current()->registerPreFinalizer(this); |
| 28 } | 30 } |
| 29 | 31 |
| 30 BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseReso
lver* resolver, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic
) | 32 BluetoothGATTCharacteristic* BluetoothGATTCharacteristic::take(ScriptPromiseReso
lver* resolver, PassOwnPtr<WebBluetoothGATTCharacteristicInit> webCharacteristic
) |
| 31 { | 33 { |
| 32 if (!webCharacteristic) { | 34 if (!webCharacteristic) { |
| 33 return nullptr; | 35 return nullptr; |
| 34 } | 36 } |
| 35 BluetoothGATTCharacteristic* characteristic = new BluetoothGATTCharacteristi
c(resolver->executionContext(), webCharacteristic); | 37 BluetoothGATTCharacteristic* characteristic = new BluetoothGATTCharacteristi
c(resolver->executionContext(), webCharacteristic); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 138 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 137 ScriptPromise promise = resolver->promise(); | 139 ScriptPromise promise = resolver->promise(); |
| 138 webbluetooth->stopNotifications(m_webCharacteristic->characteristicInstanceI
D, this, new CallbackPromiseAdapter<void, BluetoothError>(resolver)); | 140 webbluetooth->stopNotifications(m_webCharacteristic->characteristicInstanceI
D, this, new CallbackPromiseAdapter<void, BluetoothError>(resolver)); |
| 139 return promise; | 141 return promise; |
| 140 } | 142 } |
| 141 | 143 |
| 142 DEFINE_TRACE(BluetoothGATTCharacteristic) | 144 DEFINE_TRACE(BluetoothGATTCharacteristic) |
| 143 { | 145 { |
| 144 RefCountedGarbageCollectedEventTargetWithInlineData<BluetoothGATTCharacteris
tic>::trace(visitor); | 146 RefCountedGarbageCollectedEventTargetWithInlineData<BluetoothGATTCharacteris
tic>::trace(visitor); |
| 145 ActiveDOMObject::trace(visitor); | 147 ActiveDOMObject::trace(visitor); |
| 148 visitor->trace(m_properties); |
| 146 } | 149 } |
| 147 | 150 |
| 148 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |