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/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "core/dom/DOMDataView.h" | 9 #include "core/dom/DOMDataView.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 "uint8_t should be a single byte"); | 35 "uint8_t should be a single byte"); |
36 DOMArrayBuffer* domBuffer = | 36 DOMArrayBuffer* domBuffer = |
37 DOMArrayBuffer::create(wtfVector.data(), wtfVector.size()); | 37 DOMArrayBuffer::create(wtfVector.data(), wtfVector.size()); |
38 return DOMDataView::create(domBuffer, 0, wtfVector.size()); | 38 return DOMDataView::create(domBuffer, 0, wtfVector.size()); |
39 } | 39 } |
40 | 40 |
41 } // anonymous namespace | 41 } // anonymous namespace |
42 | 42 |
43 BluetoothRemoteGATTCharacteristic::BluetoothRemoteGATTCharacteristic( | 43 BluetoothRemoteGATTCharacteristic::BluetoothRemoteGATTCharacteristic( |
44 ExecutionContext* context, | 44 ExecutionContext* context, |
45 const String& serviceInstanceId, | |
46 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr characteristic, | 45 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr characteristic, |
47 BluetoothRemoteGATTService* service, | 46 BluetoothRemoteGATTService* service, |
48 BluetoothDevice* device) | 47 BluetoothDevice* device) |
49 : ContextLifecycleObserver(context), | 48 : ContextLifecycleObserver(context), |
50 m_serviceInstanceId(serviceInstanceId), | |
51 m_characteristic(std::move(characteristic)), | 49 m_characteristic(std::move(characteristic)), |
52 m_service(service), | 50 m_service(service), |
53 m_stopped(false), | 51 m_stopped(false), |
54 m_device(device) { | 52 m_device(device) { |
55 m_properties = | 53 m_properties = |
56 BluetoothCharacteristicProperties::create(m_characteristic->properties); | 54 BluetoothCharacteristicProperties::create(m_characteristic->properties); |
57 } | 55 } |
58 | 56 |
59 BluetoothRemoteGATTCharacteristic* BluetoothRemoteGATTCharacteristic::create( | 57 BluetoothRemoteGATTCharacteristic* BluetoothRemoteGATTCharacteristic::create( |
60 ExecutionContext* context, | 58 ExecutionContext* context, |
61 const String& serviceInstanceId, | |
62 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr characteristic, | 59 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr characteristic, |
63 BluetoothRemoteGATTService* service, | 60 BluetoothRemoteGATTService* service, |
64 BluetoothDevice* device) { | 61 BluetoothDevice* device) { |
65 return new BluetoothRemoteGATTCharacteristic( | 62 return new BluetoothRemoteGATTCharacteristic( |
66 context, serviceInstanceId, std::move(characteristic), service, device); | 63 context, std::move(characteristic), service, device); |
67 } | 64 } |
68 | 65 |
69 void BluetoothRemoteGATTCharacteristic::setValue(DOMDataView* domDataView) { | 66 void BluetoothRemoteGATTCharacteristic::setValue(DOMDataView* domDataView) { |
70 m_value = domDataView; | 67 m_value = domDataView; |
71 } | 68 } |
72 | 69 |
73 void BluetoothRemoteGATTCharacteristic::dispatchCharacteristicValueChanged( | 70 void BluetoothRemoteGATTCharacteristic::dispatchCharacteristicValueChanged( |
74 const Vector<uint8_t>& value) { | 71 const Vector<uint8_t>& value) { |
75 this->setValue(ConvertWTFVectorToDataView(value)); | 72 this->setValue(ConvertWTFVectorToDataView(value)); |
76 dispatchEvent(Event::create(EventTypeNames::characteristicvaluechanged)); | 73 dispatchEvent(Event::create(EventTypeNames::characteristicvaluechanged)); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { | 318 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) { |
322 visitor->trace(m_service); | 319 visitor->trace(m_service); |
323 visitor->trace(m_properties); | 320 visitor->trace(m_properties); |
324 visitor->trace(m_value); | 321 visitor->trace(m_value); |
325 visitor->trace(m_device); | 322 visitor->trace(m_device); |
326 EventTargetWithInlineData::trace(visitor); | 323 EventTargetWithInlineData::trace(visitor); |
327 ContextLifecycleObserver::trace(visitor); | 324 ContextLifecycleObserver::trace(visitor); |
328 } | 325 } |
329 | 326 |
330 } // namespace blink | 327 } // namespace blink |
OLD | NEW |