| 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 "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/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
| 12 #include "core/inspector/ConsoleMessage.h" | |
| 13 #include "modules/bluetooth/BluetoothError.h" | 12 #include "modules/bluetooth/BluetoothError.h" |
| 14 #include "modules/bluetooth/BluetoothRemoteGATTService.h" | 13 #include "modules/bluetooth/BluetoothRemoteGATTService.h" |
| 15 #include "modules/bluetooth/BluetoothSupplement.h" | 14 #include "modules/bluetooth/BluetoothSupplement.h" |
| 16 #include "modules/bluetooth/BluetoothUUID.h" | 15 #include "modules/bluetooth/BluetoothUUID.h" |
| 17 #include "public/platform/modules/bluetooth/WebBluetooth.h" | 16 #include "public/platform/modules/bluetooth/WebBluetooth.h" |
| 18 #include "wtf/OwnPtr.h" | 17 #include "wtf/OwnPtr.h" |
| 19 | 18 |
| 20 namespace blink { | 19 namespace blink { |
| 21 | 20 |
| 22 BluetoothRemoteGATTServer::BluetoothRemoteGATTServer(BluetoothDevice* device) | 21 BluetoothRemoteGATTServer::BluetoothRemoteGATTServer(BluetoothDevice* device) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 73 |
| 75 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) | 74 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) |
| 76 { | 75 { |
| 77 m_connected = false; | 76 m_connected = false; |
| 78 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); | 77 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); |
| 79 webbluetooth->disconnect(device()->id()); | 78 webbluetooth->disconnect(device()->id()); |
| 80 } | 79 } |
| 81 | 80 |
| 82 ScriptPromise BluetoothRemoteGATTServer::getPrimaryService(ScriptState* scriptSt
ate, const StringOrUnsignedLong& service, ExceptionState& exceptionState) | 81 ScriptPromise BluetoothRemoteGATTServer::getPrimaryService(ScriptState* scriptSt
ate, const StringOrUnsignedLong& service, ExceptionState& exceptionState) |
| 83 { | 82 { |
| 84 #if OS(MACOSX) | |
| 85 // TODO(jlebel): Remove when getPrimaryService is implemented. | |
| 86 return ScriptPromise::rejectWithDOMException(scriptState, | |
| 87 DOMException::create(NotSupportedError, | |
| 88 "getPrimaryService is not implemented yet. See https://goo.gl/J6ASzs
")); | |
| 89 #endif // OS(MACOSX) | |
| 90 | |
| 91 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); | 83 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat
e); |
| 92 | 84 |
| 93 String serviceUUID = BluetoothUUID::getService(service, exceptionState); | 85 String serviceUUID = BluetoothUUID::getService(service, exceptionState); |
| 94 if (exceptionState.hadException()) | 86 if (exceptionState.hadException()) |
| 95 return exceptionState.reject(scriptState); | 87 return exceptionState.reject(scriptState); |
| 96 | 88 |
| 97 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 89 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 98 ScriptPromise promise = resolver->promise(); | 90 ScriptPromise promise = resolver->promise(); |
| 99 webbluetooth->getPrimaryService(device()->id(), serviceUUID, new CallbackPro
miseAdapter<BluetoothRemoteGATTService, BluetoothError>(resolver)); | 91 webbluetooth->getPrimaryService(device()->id(), serviceUUID, new CallbackPro
miseAdapter<BluetoothRemoteGATTService, BluetoothError>(resolver)); |
| 100 | 92 |
| 101 return promise; | 93 return promise; |
| 102 } | 94 } |
| 103 | 95 |
| 104 } // namespace blink | 96 } // namespace blink |
| OLD | NEW |