| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 void BluetoothDevice::stop() | 42 void BluetoothDevice::stop() |
| 43 { | 43 { |
| 44 disconnectGATTIfConnected(); | 44 disconnectGATTIfConnected(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool BluetoothDevice::disconnectGATTIfConnected() | 47 bool BluetoothDevice::disconnectGATTIfConnected() |
| 48 { | 48 { |
| 49 if (m_gatt->connected()) { | 49 if (m_gatt->connected()) { |
| 50 m_gatt->setConnected(false); | 50 m_gatt->setConnected(false); |
| 51 m_gatt->ClearActiveAlgorithms(); |
| 51 BluetoothSupplement::fromExecutionContext(getExecutionContext())->discon
nect(id()); | 52 BluetoothSupplement::fromExecutionContext(getExecutionContext())->discon
nect(id()); |
| 52 return true; | 53 return true; |
| 53 } | 54 } |
| 54 return false; | 55 return false; |
| 55 } | 56 } |
| 56 | 57 |
| 57 const WTF::AtomicString& BluetoothDevice::interfaceName() const | 58 const WTF::AtomicString& BluetoothDevice::interfaceName() const |
| 58 { | 59 { |
| 59 return EventTargetNames::BluetoothDevice; | 60 return EventTargetNames::BluetoothDevice; |
| 60 } | 61 } |
| 61 | 62 |
| 62 ExecutionContext* BluetoothDevice::getExecutionContext() const | 63 ExecutionContext* BluetoothDevice::getExecutionContext() const |
| 63 { | 64 { |
| 64 return ActiveDOMObject::getExecutionContext(); | 65 return ActiveDOMObject::getExecutionContext(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void BluetoothDevice::dispatchGattServerDisconnected() | 68 void BluetoothDevice::dispatchGattServerDisconnected() |
| 68 { | 69 { |
| 69 if (m_gatt->connected()) { | 70 if (m_gatt->connected()) { |
| 70 m_gatt->setConnected(false); | 71 m_gatt->setConnected(false); |
| 72 m_gatt->ClearActiveAlgorithms(); |
| 71 dispatchEvent(Event::createBubble(EventTypeNames::gattserverdisconnected
)); | 73 dispatchEvent(Event::createBubble(EventTypeNames::gattserverdisconnected
)); |
| 72 } | 74 } |
| 73 } | 75 } |
| 74 | 76 |
| 75 DEFINE_TRACE(BluetoothDevice) | 77 DEFINE_TRACE(BluetoothDevice) |
| 76 { | 78 { |
| 77 EventTargetWithInlineData::trace(visitor); | 79 EventTargetWithInlineData::trace(visitor); |
| 78 ActiveDOMObject::trace(visitor); | 80 ActiveDOMObject::trace(visitor); |
| 79 visitor->trace(m_gatt); | 81 visitor->trace(m_gatt); |
| 80 } | 82 } |
| 81 | 83 |
| 82 Vector<String> BluetoothDevice::uuids() | 84 Vector<String> BluetoothDevice::uuids() |
| 83 { | 85 { |
| 84 Vector<String> uuids(m_webDevice->uuids.size()); | 86 Vector<String> uuids(m_webDevice->uuids.size()); |
| 85 for (size_t i = 0; i < m_webDevice->uuids.size(); ++i) | 87 for (size_t i = 0; i < m_webDevice->uuids.size(); ++i) |
| 86 uuids[i] = m_webDevice->uuids[i]; | 88 uuids[i] = m_webDevice->uuids[i]; |
| 87 return uuids; | 89 return uuids; |
| 88 } | 90 } |
| 89 | 91 |
| 90 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |