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

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

Issue 2478013002: bluetooth: Invalidate services upon disconnection (Closed)
Patch Set: Clean up Created 4 years, 1 month 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/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"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); 93 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
94 ScriptPromise promise = resolver->promise(); 94 ScriptPromise promise = resolver->promise();
95 webbluetooth->connect(device()->id(), device(), 95 webbluetooth->connect(device()->id(), device(),
96 new ConnectCallback(device(), resolver)); 96 new ConnectCallback(device(), resolver));
97 return promise; 97 return promise;
98 } 98 }
99 99
100 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) { 100 void BluetoothRemoteGATTServer::disconnect(ScriptState* scriptState) {
101 if (!m_connected) 101 if (!m_connected)
102 return; 102 return;
103 m_connected = false; 103 device()->CleanupDisconnectedDeviceAndFireEvent();
ortuno 2016/11/04 03:09:48 Note how we only clear the active algorithms map o
104 ClearActiveAlgorithms();
105 WebBluetooth* webbluetooth = 104 WebBluetooth* webbluetooth =
106 BluetoothSupplement::fromScriptState(scriptState); 105 BluetoothSupplement::fromScriptState(scriptState);
107 webbluetooth->disconnect(device()->id()); 106 webbluetooth->disconnect(device()->id());
108 device()->dispatchEvent(
109 Event::createBubble(EventTypeNames::gattserverdisconnected));
110 } 107 }
111 108
112 // Class that allows us to resolve the promise with a single service or 109 // Class that allows us to resolve the promise with a single service or
113 // with a vector owning the services. 110 // with a vector owning the services.
114 class GetPrimaryServicesCallback 111 class GetPrimaryServicesCallback
115 : public WebBluetoothGetPrimaryServicesCallbacks { 112 : public WebBluetoothGetPrimaryServicesCallbacks {
116 public: 113 public:
117 GetPrimaryServicesCallback( 114 GetPrimaryServicesCallback(
118 BluetoothDevice* device, 115 BluetoothDevice* device,
119 mojom::blink::WebBluetoothGATTQueryQuantity quantity, 116 mojom::blink::WebBluetoothGATTQueryQuantity quantity,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 WebBluetooth* webbluetooth = 224 WebBluetooth* webbluetooth =
228 BluetoothSupplement::fromScriptState(scriptState); 225 BluetoothSupplement::fromScriptState(scriptState);
229 webbluetooth->getPrimaryServices( 226 webbluetooth->getPrimaryServices(
230 device()->id(), static_cast<int32_t>(quantity), servicesUUID, 227 device()->id(), static_cast<int32_t>(quantity), servicesUUID,
231 new GetPrimaryServicesCallback(device(), quantity, resolver)); 228 new GetPrimaryServicesCallback(device(), quantity, resolver));
232 229
233 return promise; 230 return promise;
234 } 231 }
235 232
236 } // namespace blink 233 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698