| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 m_resolver.get())) { | 162 m_resolver.get())) { |
| 163 m_resolver->reject( | 163 m_resolver->reject( |
| 164 DOMException::create(NetworkError, kGATTServerDisconnected)); | 164 DOMException::create(NetworkError, kGATTServerDisconnected)); |
| 165 return; | 165 return; |
| 166 } | 166 } |
| 167 | 167 |
| 168 m_resolver->reject(BluetoothError::take(m_resolver, error)); | 168 m_resolver->reject(BluetoothError::take(m_resolver, error)); |
| 169 } | 169 } |
| 170 | 170 |
| 171 private: | 171 private: |
| 172 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_characteristic; | 172 Persistent<BluetoothRemoteGATTCharacteristic> m_characteristic; |
| 173 Persistent<ScriptPromiseResolver> m_resolver; | 173 Persistent<ScriptPromiseResolver> m_resolver; |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 ScriptPromise BluetoothRemoteGATTCharacteristic::readValue( | 176 ScriptPromise BluetoothRemoteGATTCharacteristic::readValue( |
| 177 ScriptState* scriptState) { | 177 ScriptState* scriptState) { |
| 178 if (!gatt()->connected()) { | 178 if (!gatt()->connected()) { |
| 179 return ScriptPromise::rejectWithDOMException( | 179 return ScriptPromise::rejectWithDOMException( |
| 180 scriptState, | 180 scriptState, |
| 181 DOMException::create(NetworkError, kGATTServerNotConnected)); | 181 DOMException::create(NetworkError, kGATTServerNotConnected)); |
| 182 } | 182 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 m_resolver.get())) { | 233 m_resolver.get())) { |
| 234 m_resolver->reject( | 234 m_resolver->reject( |
| 235 DOMException::create(NetworkError, kGATTServerDisconnected)); | 235 DOMException::create(NetworkError, kGATTServerDisconnected)); |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 | 238 |
| 239 m_resolver->reject(BluetoothError::take(m_resolver, error)); | 239 m_resolver->reject(BluetoothError::take(m_resolver, error)); |
| 240 } | 240 } |
| 241 | 241 |
| 242 private: | 242 private: |
| 243 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_characteristic; | 243 Persistent<BluetoothRemoteGATTCharacteristic> m_characteristic; |
| 244 Persistent<ScriptPromiseResolver> m_resolver; | 244 Persistent<ScriptPromiseResolver> m_resolver; |
| 245 }; | 245 }; |
| 246 | 246 |
| 247 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue( | 247 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue( |
| 248 ScriptState* scriptState, | 248 ScriptState* scriptState, |
| 249 const DOMArrayPiece& value) { | 249 const DOMArrayPiece& value) { |
| 250 if (!gatt()->connected()) { | 250 if (!gatt()->connected()) { |
| 251 return ScriptPromise::rejectWithDOMException( | 251 return ScriptPromise::rejectWithDOMException( |
| 252 scriptState, | 252 scriptState, |
| 253 DOMException::create(NetworkError, kGATTServerNotConnected)); | 253 DOMException::create(NetworkError, kGATTServerNotConnected)); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 | 372 |
| 373 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { | 373 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { |
| 374 visitor->trace(m_service); | 374 visitor->trace(m_service); |
| 375 visitor->trace(m_properties); | 375 visitor->trace(m_properties); |
| 376 visitor->trace(m_value); | 376 visitor->trace(m_value); |
| 377 EventTargetWithInlineData::trace(visitor); | 377 EventTargetWithInlineData::trace(visitor); |
| 378 ActiveDOMObject::trace(visitor); | 378 ActiveDOMObject::trace(visitor); |
| 379 } | 379 } |
| 380 | 380 |
| 381 } // namespace blink | 381 } // namespace blink |
| OLD | NEW |