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

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

Issue 2183903002: bluetooth: Reject getPrimaryService(s) if frame is not connected (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Docs Created 4 years, 4 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 #ifndef BluetoothRemoteGATTServer_h 5 #ifndef BluetoothRemoteGATTServer_h
6 #define BluetoothRemoteGATTServer_h 6 #define BluetoothRemoteGATTServer_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "bindings/modules/v8/StringOrUnsignedLong.h" 9 #include "bindings/modules/v8/StringOrUnsignedLong.h"
10 #include "modules/bluetooth/BluetoothDevice.h" 10 #include "modules/bluetooth/BluetoothDevice.h"
(...skipping 13 matching lines...) Expand all
24 : public GarbageCollected<BluetoothRemoteGATTServer> 24 : public GarbageCollected<BluetoothRemoteGATTServer>
25 , public ScriptWrappable { 25 , public ScriptWrappable {
26 DEFINE_WRAPPERTYPEINFO(); 26 DEFINE_WRAPPERTYPEINFO();
27 public: 27 public:
28 BluetoothRemoteGATTServer(BluetoothDevice*); 28 BluetoothRemoteGATTServer(BluetoothDevice*);
29 29
30 static BluetoothRemoteGATTServer* create(BluetoothDevice*); 30 static BluetoothRemoteGATTServer* create(BluetoothDevice*);
31 31
32 void setConnected(bool connected) { m_connected = connected; } 32 void setConnected(bool connected) { m_connected = connected; }
33 33
34 // Adds |resolver| to the set of Active Algorithms. CHECK-fails if
35 // |resolver| was already added.
36 void AddToActiveAlgorithms(ScriptPromiseResolver*);
37 // Returns false if |resolver| was not in the set of Active Algorithms.
38 // Otherwise it removes |resolver| from the set of Active Algorithms and
39 // returns true.
40 bool RemoveFromActiveAlgorithms(ScriptPromiseResolver*);
41 // Removes all ScriptPromiseResolvers from the set of Active Algorithms.
42 void ClearActiveAlgorithms() { m_activeAlgorithms.clear(); }
43
34 // Interface required by Garbage Collectoin: 44 // Interface required by Garbage Collectoin:
35 DECLARE_VIRTUAL_TRACE(); 45 DECLARE_VIRTUAL_TRACE();
36 46
37 // IDL exposed interface: 47 // IDL exposed interface:
38 BluetoothDevice* device() { return m_device; } 48 BluetoothDevice* device() { return m_device; }
39 bool connected() { return m_connected; } 49 bool connected() { return m_connected; }
40 ScriptPromise connect(ScriptState*); 50 ScriptPromise connect(ScriptState*);
41 void disconnect(ScriptState*); 51 void disconnect(ScriptState*);
42 ScriptPromise getPrimaryService(ScriptState*, const StringOrUnsignedLong& se rvice, ExceptionState&); 52 ScriptPromise getPrimaryService(ScriptState*, const StringOrUnsignedLong& se rvice, ExceptionState&);
43 ScriptPromise getPrimaryServices(ScriptState*, const StringOrUnsignedLong& s ervice, ExceptionState&); 53 ScriptPromise getPrimaryServices(ScriptState*, const StringOrUnsignedLong& s ervice, ExceptionState&);
44 ScriptPromise getPrimaryServices(ScriptState*, ExceptionState&); 54 ScriptPromise getPrimaryServices(ScriptState*, ExceptionState&);
45 55
46 private: 56 private:
47 ScriptPromise getPrimaryServicesImpl(ScriptState*, mojom::blink::WebBluetoot hGATTQueryQuantity, String serviceUUID = String()); 57 ScriptPromise getPrimaryServicesImpl(ScriptState*, mojom::blink::WebBluetoot hGATTQueryQuantity, String serviceUUID = String());
48 58
59 // Contains a ScriptPromiseResolver corresponding to each algorithm using
60 // this server’s connection. Disconnection i.e. disconnect() method or the
61 // device disconnecting by itself, empties this set so that the algorithm
62 // can tell whether its realm was ever disconnected while it was running.
63 HeapHashSet<Member<ScriptPromiseResolver>> m_activeAlgorithms;
64
49 Member<BluetoothDevice> m_device; 65 Member<BluetoothDevice> m_device;
50 bool m_connected; 66 bool m_connected;
51 }; 67 };
52 68
53 } // namespace blink 69 } // namespace blink
54 70
55 #endif // BluetoothDevice_h 71 #endif // BluetoothDevice_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698