Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp

Issue 1527853002: bluetooth: Add disconnect function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-device-identifier
Patch Set: Fix test that fails after upstream change. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/BluetoothGATTRemoteServer.h" 5 #include "modules/bluetooth/BluetoothGATTRemoteServer.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 11 matching lines...) Expand all
22 : m_webGATT(webGATT) 22 : m_webGATT(webGATT)
23 { 23 {
24 } 24 }
25 25
26 BluetoothGATTRemoteServer* BluetoothGATTRemoteServer::take(ScriptPromiseResolver *, PassOwnPtr<WebBluetoothGATTRemoteServer> webGATT) 26 BluetoothGATTRemoteServer* BluetoothGATTRemoteServer::take(ScriptPromiseResolver *, PassOwnPtr<WebBluetoothGATTRemoteServer> webGATT)
27 { 27 {
28 ASSERT(webGATT); 28 ASSERT(webGATT);
29 return new BluetoothGATTRemoteServer(webGATT); 29 return new BluetoothGATTRemoteServer(webGATT);
30 } 30 }
31 31
32 void BluetoothGATTRemoteServer::disconnect(ScriptState* scriptState)
33 {
34 m_webGATT->connected = false;
35 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e);
36 webbluetooth->disconnect(m_webGATT->deviceId);
37 }
38
32 ScriptPromise BluetoothGATTRemoteServer::getPrimaryService(ScriptState* scriptSt ate, const StringOrUnsignedLong& service, ExceptionState& exceptionState) 39 ScriptPromise BluetoothGATTRemoteServer::getPrimaryService(ScriptState* scriptSt ate, const StringOrUnsignedLong& service, ExceptionState& exceptionState)
33 { 40 {
34 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e); 41 WebBluetooth* webbluetooth = BluetoothSupplement::fromScriptState(scriptStat e);
35 42
36 String serviceUUID = BluetoothUUID::getService(service, exceptionState); 43 String serviceUUID = BluetoothUUID::getService(service, exceptionState);
37 if (exceptionState.hadException()) 44 if (exceptionState.hadException())
38 return exceptionState.reject(scriptState); 45 return exceptionState.reject(scriptState);
39 46
40 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 47 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
41 ScriptPromise promise = resolver->promise(); 48 ScriptPromise promise = resolver->promise();
42 webbluetooth->getPrimaryService(m_webGATT->deviceInstanceID, serviceUUID, ne w CallbackPromiseAdapter<BluetoothGATTService, BluetoothError>(resolver)); 49 webbluetooth->getPrimaryService(m_webGATT->deviceId, serviceUUID, new Callba ckPromiseAdapter<BluetoothGATTService, BluetoothError>(resolver));
43 50
44 return promise; 51 return promise;
45 } 52 }
46 53
47 } // namespace blink 54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698