| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/BluetoothDevice.h" | 5 #include "modules/bluetooth/BluetoothDevice.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/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| 11 #include "core/events/Event.h" | 11 #include "core/events/Event.h" |
| 12 #include "modules/bluetooth/BluetoothAttributeInstanceMap.h" | 12 #include "modules/bluetooth/BluetoothAttributeInstanceMap.h" |
| 13 #include "modules/bluetooth/BluetoothError.h" | 13 #include "modules/bluetooth/BluetoothError.h" |
| 14 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" | 14 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" |
| 15 #include "modules/bluetooth/BluetoothSupplement.h" | 15 #include "modules/bluetooth/BluetoothSupplement.h" |
| 16 #include "public/platform/modules/bluetooth/WebBluetooth.h" | 16 #include "public/platform/modules/bluetooth/WebBluetooth.h" |
| 17 #include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic
Init.h" |
| 17 #include <memory> | 18 #include <memory> |
| 18 #include <utility> | 19 #include <utility> |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 BluetoothDevice::BluetoothDevice( | 23 BluetoothDevice::BluetoothDevice( |
| 23 ExecutionContext* context, | 24 ExecutionContext* context, |
| 24 std::unique_ptr<WebBluetoothDeviceInit> webDevice) | 25 std::unique_ptr<WebBluetoothDeviceInit> webDevice) |
| 25 : ContextLifecycleObserver(context), | 26 : ContextLifecycleObserver(context), |
| 26 m_attributeInstanceMap(new BluetoothAttributeInstanceMap(this)), | 27 m_attributeInstanceMap(new BluetoothAttributeInstanceMap(this)), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 BluetoothDevice::getOrCreateBluetoothRemoteGATTService( | 43 BluetoothDevice::getOrCreateBluetoothRemoteGATTService( |
| 43 std::unique_ptr<WebBluetoothRemoteGATTService> webService) { | 44 std::unique_ptr<WebBluetoothRemoteGATTService> webService) { |
| 44 return m_attributeInstanceMap->getOrCreateBluetoothRemoteGATTService( | 45 return m_attributeInstanceMap->getOrCreateBluetoothRemoteGATTService( |
| 45 std::move(webService)); | 46 std::move(webService)); |
| 46 } | 47 } |
| 47 | 48 |
| 48 bool BluetoothDevice::isValidService(const String& serviceInstanceId) { | 49 bool BluetoothDevice::isValidService(const String& serviceInstanceId) { |
| 49 return m_attributeInstanceMap->containsService(serviceInstanceId); | 50 return m_attributeInstanceMap->containsService(serviceInstanceId); |
| 50 } | 51 } |
| 51 | 52 |
| 53 BluetoothRemoteGATTCharacteristic* |
| 54 BluetoothDevice::getOrCreateBluetoothRemoteGATTCharacteristic( |
| 55 ExecutionContext* context, |
| 56 std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit> webCharacteristic, |
| 57 BluetoothRemoteGATTService* service) { |
| 58 return m_attributeInstanceMap->getOrCreateBluetoothRemoteGATTCharacteristic( |
| 59 context, std::move(webCharacteristic), service); |
| 60 } |
| 61 |
| 52 void BluetoothDevice::dispose() { | 62 void BluetoothDevice::dispose() { |
| 53 disconnectGATTIfConnected(); | 63 disconnectGATTIfConnected(); |
| 54 } | 64 } |
| 55 | 65 |
| 56 void BluetoothDevice::contextDestroyed() { | 66 void BluetoothDevice::contextDestroyed() { |
| 57 disconnectGATTIfConnected(); | 67 disconnectGATTIfConnected(); |
| 58 } | 68 } |
| 59 | 69 |
| 60 void BluetoothDevice::disconnectGATTIfConnected() { | 70 void BluetoothDevice::disconnectGATTIfConnected() { |
| 61 if (m_gatt->connected()) { | 71 if (m_gatt->connected()) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 90 } | 100 } |
| 91 | 101 |
| 92 DEFINE_TRACE(BluetoothDevice) { | 102 DEFINE_TRACE(BluetoothDevice) { |
| 93 EventTargetWithInlineData::trace(visitor); | 103 EventTargetWithInlineData::trace(visitor); |
| 94 ContextLifecycleObserver::trace(visitor); | 104 ContextLifecycleObserver::trace(visitor); |
| 95 visitor->trace(m_attributeInstanceMap); | 105 visitor->trace(m_attributeInstanceMap); |
| 96 visitor->trace(m_gatt); | 106 visitor->trace(m_gatt); |
| 97 } | 107 } |
| 98 | 108 |
| 99 } // namespace blink | 109 } // namespace blink |
| OLD | NEW |