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