| 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 "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" | 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMDataView.h" | 10 #include "core/dom/DOMDataView.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 DOMDataView* domDataView = ConvertWebVectorToDataView(value); | 129 DOMDataView* domDataView = ConvertWebVectorToDataView(value); |
| 130 if (m_webCharacteristic) | 130 if (m_webCharacteristic) |
| 131 m_webCharacteristic->setValue(domDataView); | 131 m_webCharacteristic->setValue(domDataView); |
| 132 | 132 |
| 133 m_resolver->resolve(domDataView); | 133 m_resolver->resolve(domDataView); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void onError( | 136 void onError( |
| 137 int32_t | 137 int32_t |
| 138 error /* Corresponds to WebBluetoothError in web_bluetooth.mojom */) | 138 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) |
| 139 override { | 139 override { |
| 140 if (!m_resolver->getExecutionContext() || | 140 if (!m_resolver->getExecutionContext() || |
| 141 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 141 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) |
| 142 return; | 142 return; |
| 143 m_resolver->reject(BluetoothError::take(m_resolver, error)); | 143 m_resolver->reject(BluetoothError::take(m_resolver, error)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 147 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
| 148 Persistent<ScriptPromiseResolver> m_resolver; | 148 Persistent<ScriptPromiseResolver> m_resolver; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 173 return; | 173 return; |
| 174 | 174 |
| 175 if (m_webCharacteristic) { | 175 if (m_webCharacteristic) { |
| 176 m_webCharacteristic->setValue(ConvertWebVectorToDataView(value)); | 176 m_webCharacteristic->setValue(ConvertWebVectorToDataView(value)); |
| 177 } | 177 } |
| 178 m_resolver->resolve(); | 178 m_resolver->resolve(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void onError( | 181 void onError( |
| 182 int32_t | 182 int32_t |
| 183 error /* Corresponds to WebBluetoothError in web_bluetooth.mojom */) | 183 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) |
| 184 override { | 184 override { |
| 185 if (!m_resolver->getExecutionContext() || | 185 if (!m_resolver->getExecutionContext() || |
| 186 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 186 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) |
| 187 return; | 187 return; |
| 188 m_resolver->reject(BluetoothError::take(m_resolver, error)); | 188 m_resolver->reject(BluetoothError::take(m_resolver, error)); |
| 189 } | 189 } |
| 190 | 190 |
| 191 private: | 191 private: |
| 192 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 192 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
| 193 Persistent<ScriptPromiseResolver> m_resolver; | 193 Persistent<ScriptPromiseResolver> m_resolver; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 void onSuccess() override { | 230 void onSuccess() override { |
| 231 if (!m_resolver->getExecutionContext() || | 231 if (!m_resolver->getExecutionContext() || |
| 232 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 232 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 m_resolver->resolve(m_webCharacteristic); | 235 m_resolver->resolve(m_webCharacteristic); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void onError( | 238 void onError( |
| 239 int32_t | 239 int32_t |
| 240 error /* Corresponds to WebBluetoothError in web_bluetooth.mojom */) | 240 error /* Corresponds to WebBluetoothResult in web_bluetooth.mojom */) |
| 241 override { | 241 override { |
| 242 if (!m_resolver->getExecutionContext() || | 242 if (!m_resolver->getExecutionContext() || |
| 243 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) | 243 m_resolver->getExecutionContext()->activeDOMObjectsAreStopped()) |
| 244 return; | 244 return; |
| 245 m_resolver->reject(BluetoothError::take(m_resolver, error)); | 245 m_resolver->reject(BluetoothError::take(m_resolver, error)); |
| 246 } | 246 } |
| 247 | 247 |
| 248 private: | 248 private: |
| 249 Persistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 249 Persistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
| 250 Persistent<ScriptPromiseResolver> m_resolver; | 250 Persistent<ScriptPromiseResolver> m_resolver; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { | 284 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { |
| 285 visitor->trace(m_service); | 285 visitor->trace(m_service); |
| 286 visitor->trace(m_properties); | 286 visitor->trace(m_properties); |
| 287 visitor->trace(m_value); | 287 visitor->trace(m_value); |
| 288 EventTargetWithInlineData::trace(visitor); | 288 EventTargetWithInlineData::trace(visitor); |
| 289 ActiveDOMObject::trace(visitor); | 289 ActiveDOMObject::trace(visitor); |
| 290 } | 290 } |
| 291 | 291 |
| 292 } // namespace blink | 292 } // namespace blink |
| OLD | NEW |