Chromium Code Reviews| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) | 115 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 DOMDataView* domDataView = ConvertWebVectorToDataView(value); | 118 DOMDataView* domDataView = ConvertWebVectorToDataView(value); |
| 119 if (m_webCharacteristic) | 119 if (m_webCharacteristic) |
| 120 m_webCharacteristic->setValue(domDataView); | 120 m_webCharacteristic->setValue(domDataView); |
| 121 | 121 |
| 122 m_resolver->resolve(domDataView); | 122 m_resolver->resolve(domDataView); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void onError(const WebBluetoothError& e) override | 125 void onError(int32_t error) override |
|
Jeffrey Yasskin
2016/07/13 20:34:58
Please comment which enum this expects to receive.
ortuno
2016/07/13 22:47:29
Done.
| |
| 126 { | 126 { |
| 127 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) | 127 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) |
| 128 return; | 128 return; |
| 129 m_resolver->reject(BluetoothError::take(m_resolver, e)); | 129 m_resolver->reject(BluetoothError::take(m_resolver, error)); |
| 130 } | 130 } |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 133 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
| 134 Persistent<ScriptPromiseResolver> m_resolver; | 134 Persistent<ScriptPromiseResolver> m_resolver; |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 ScriptPromise BluetoothRemoteGATTCharacteristic::readValue(ScriptState* scriptSt ate) | 137 ScriptPromise BluetoothRemoteGATTCharacteristic::readValue(ScriptState* scriptSt ate) |
| 138 { | 138 { |
| 139 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); | 139 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 153 { | 153 { |
| 154 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) | 154 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) |
| 155 return; | 155 return; |
| 156 | 156 |
| 157 if (m_webCharacteristic) { | 157 if (m_webCharacteristic) { |
| 158 m_webCharacteristic->setValue(ConvertWebVectorToDataView(value)); | 158 m_webCharacteristic->setValue(ConvertWebVectorToDataView(value)); |
| 159 } | 159 } |
| 160 m_resolver->resolve(); | 160 m_resolver->resolve(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void onError(const WebBluetoothError& e) override | 163 void onError(int32_t error) override |
| 164 { | 164 { |
| 165 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) | 165 if (!m_resolver->getExecutionContext() || m_resolver->getExecutionContex t()->activeDOMObjectsAreStopped()) |
| 166 return; | 166 return; |
| 167 m_resolver->reject(BluetoothError::take(m_resolver, e)); | 167 m_resolver->reject(BluetoothError::take(m_resolver, error)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; | 171 WeakPersistent<BluetoothRemoteGATTCharacteristic> m_webCharacteristic; |
| 172 Persistent<ScriptPromiseResolver> m_resolver; | 172 Persistent<ScriptPromiseResolver> m_resolver; |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue(ScriptState* scriptS tate, const DOMArrayPiece& value) | 175 ScriptPromise BluetoothRemoteGATTCharacteristic::writeValue(ScriptState* scriptS tate, const DOMArrayPiece& value) |
| 176 { | 176 { |
| 177 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); | 177 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) | 224 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) |
| 225 { | 225 { |
| 226 visitor->trace(m_service); | 226 visitor->trace(m_service); |
| 227 visitor->trace(m_properties); | 227 visitor->trace(m_properties); |
| 228 visitor->trace(m_value); | 228 visitor->trace(m_value); |
| 229 EventTargetWithInlineData::trace(visitor); | 229 EventTargetWithInlineData::trace(visitor); |
| 230 ActiveDOMObject::trace(visitor); | 230 ActiveDOMObject::trace(visitor); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |