| 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/BluetoothRemoteGATTServer.h" | 5 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 8 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 resolver->reject(BluetoothError::take(resolver, result)); | 70 resolver->reject(BluetoothError::take(resolver, result)); |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 ScriptPromise BluetoothRemoteGATTServer::connect(ScriptState* scriptState) { | 74 ScriptPromise BluetoothRemoteGATTServer::connect(ScriptState* scriptState) { |
| 75 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 75 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 76 ScriptPromise promise = resolver->promise(); | 76 ScriptPromise promise = resolver->promise(); |
| 77 | 77 |
| 78 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); | 78 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); |
| 79 service->RemoteServerConnect( | 79 service->RemoteServerConnect( |
| 80 device()->id(), convertToBaseCallback(WTF::bind( | 80 device()->id(), |
| 81 &BluetoothRemoteGATTServer::ConnectCallback, | 81 convertToBaseCallback( |
| 82 wrapPersistent(this), wrapPersistent(resolver)))); | 82 WTF::bind(&BluetoothRemoteGATTServer::ConnectCallback, |
| 83 wrapPersistent(this), wrapPersistent(resolver)))); |
| 83 | 84 |
| 84 return promise; | 85 return promise; |
| 85 } | 86 } |
| 86 | 87 |
| 87 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) { | 88 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) { |
| 88 if (!m_connected) | 89 if (!m_connected) |
| 89 return; | 90 return; |
| 90 device()->cleanupDisconnectedDeviceAndFireEvent(); | 91 device()->cleanupDisconnectedDeviceAndFireEvent(); |
| 91 m_device->bluetooth()->removeFromConnectedDevicesMap(device()->id()); | 92 m_device->bluetooth()->removeFromConnectedDevicesMap(device()->id()); |
| 92 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); | 93 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); | 186 mojom::blink::WebBluetoothService* service = m_device->bluetooth()->service(); |
| 186 service->RemoteServerGetPrimaryServices( | 187 service->RemoteServerGetPrimaryServices( |
| 187 device()->id(), quantity, servicesUUID, | 188 device()->id(), quantity, servicesUUID, |
| 188 convertToBaseCallback( | 189 convertToBaseCallback( |
| 189 WTF::bind(&BluetoothRemoteGATTServer::GetPrimaryServicesCallback, | 190 WTF::bind(&BluetoothRemoteGATTServer::GetPrimaryServicesCallback, |
| 190 wrapPersistent(this), quantity, wrapPersistent(resolver)))); | 191 wrapPersistent(this), quantity, wrapPersistent(resolver)))); |
| 191 return promise; | 192 return promise; |
| 192 } | 193 } |
| 193 | 194 |
| 194 } // namespace blink | 195 } // namespace blink |
| OLD | NEW |