| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 m_resolver->reject(BluetoothError::take(m_resolver, e)); | 126 m_resolver->reject(BluetoothError::take(m_resolver, e)); |
| 127 } | 127 } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 130 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
| 131 Persistent<ScriptPromiseResolver> m_resolver; | 131 Persistent<ScriptPromiseResolver> m_resolver; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 ScriptPromise BluetoothRemoteGATTCharacteristic::readValue(ScriptState* scriptSt
ate) | 134 ScriptPromise BluetoothRemoteGATTCharacteristic::readValue(ScriptState* scriptSt
ate) |
| 135 { | 135 { |
| 136 #if OS(MACOSX) | |
| 137 // TODO(jlebel): Remove when readValue is implemented. | |
| 138 return ScriptPromise::rejectWithDOMException(scriptState, | |
| 139 DOMException::create(NotSupportedError, | |
| 140 "readValue is not implemented yet. See https://goo.gl/J6ASzs")); | |
| 141 #endif // OS(MACOSX) | |
| 142 | |
| 143 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); | 136 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); |
| 144 | 137 |
| 145 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 138 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 146 ScriptPromise promise = resolver->promise(); | 139 ScriptPromise promise = resolver->promise(); |
| 147 webbluetooth->readValue(m_webCharacteristic->characteristicInstanceID, new R
eadValueCallback(this, resolver)); | 140 webbluetooth->readValue(m_webCharacteristic->characteristicInstanceID, new R
eadValueCallback(this, resolver)); |
| 148 | 141 |
| 149 return promise; | 142 return promise; |
| 150 } | 143 } |
| 151 | 144 |
| 152 class WriteValueCallback : public WebBluetoothWriteValueCallbacks { | 145 class WriteValueCallback : public WebBluetoothWriteValueCallbacks { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 234 |
| 242 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) | 235 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) |
| 243 { | 236 { |
| 244 visitor->trace(m_properties); | 237 visitor->trace(m_properties); |
| 245 visitor->trace(m_value); | 238 visitor->trace(m_value); |
| 246 EventTargetWithInlineData::trace(visitor); | 239 EventTargetWithInlineData::trace(visitor); |
| 247 ActiveDOMObject::trace(visitor); | 240 ActiveDOMObject::trace(visitor); |
| 248 } | 241 } |
| 249 | 242 |
| 250 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |