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

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

Issue 1991063002: Implement the gattserverdisconnected event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rename-web-bluetooth-device
Patch Set: Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 BluetoothDevice_h 5 #ifndef BluetoothDevice_h
6 #define BluetoothDevice_h 6 #define BluetoothDevice_h
7 7
8 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/dom/ActiveDOMObject.h" 9 #include "core/dom/ActiveDOMObject.h"
10 #include "modules/EventTargetModules.h" 10 #include "modules/EventTargetModules.h"
11 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" 11 #include "modules/bluetooth/BluetoothRemoteGATTServer.h"
12 #include "platform/heap/Heap.h" 12 #include "platform/heap/Heap.h"
13 #include "public/platform/modules/bluetooth/WebBluetoothDevice.h"
13 #include "public/platform/modules/bluetooth/WebBluetoothDeviceInit.h" 14 #include "public/platform/modules/bluetooth/WebBluetoothDeviceInit.h"
14 #include "wtf/OwnPtr.h" 15 #include "wtf/OwnPtr.h"
15 #include "wtf/PassOwnPtr.h" 16 #include "wtf/PassOwnPtr.h"
16 #include "wtf/text/WTFString.h" 17 #include "wtf/text/WTFString.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 class BluetoothRemoteGATTServer; 21 class BluetoothRemoteGATTServer;
21 class ScriptPromise; 22 class ScriptPromise;
22 class ScriptPromiseResolver; 23 class ScriptPromiseResolver;
23 class ScriptState; 24 class ScriptState;
24 25
25 // BluetoothDevice represents a physical bluetooth device in the DOM. See IDL. 26 // BluetoothDevice represents a physical bluetooth device in the DOM. See IDL.
26 // 27 //
27 // Callbacks providing WebBluetoothDevice objects are handled by 28 // Callbacks providing WebBluetoothDevice objects are handled by
28 // CallbackPromiseAdapter templatized with this class. See this class's 29 // CallbackPromiseAdapter templatized with this class. See this class's
29 // "Interface required by CallbackPromiseAdapter" section and the 30 // "Interface required by CallbackPromiseAdapter" section and the
30 // CallbackPromiseAdapter class comments. 31 // CallbackPromiseAdapter class comments.
31 class BluetoothDevice final 32 class BluetoothDevice final
32 : public EventTargetWithInlineData 33 : public EventTargetWithInlineData
33 , public ActiveDOMObject { 34 , public ActiveDOMObject
35 , public WebBluetoothDevice {
34 USING_PRE_FINALIZER(BluetoothDevice, dispose); 36 USING_PRE_FINALIZER(BluetoothDevice, dispose);
35 DEFINE_WRAPPERTYPEINFO(); 37 DEFINE_WRAPPERTYPEINFO();
36 USING_GARBAGE_COLLECTED_MIXIN(BluetoothDevice); 38 USING_GARBAGE_COLLECTED_MIXIN(BluetoothDevice);
37 public: 39 public:
38 BluetoothDevice(ExecutionContext*, PassOwnPtr<WebBluetoothDeviceInit>); 40 BluetoothDevice(ExecutionContext*, PassOwnPtr<WebBluetoothDeviceInit>);
39 41
40 // Interface required by CallbackPromiseAdapter: 42 // Interface required by CallbackPromiseAdapter:
41 using WebType = OwnPtr<WebBluetoothDeviceInit>; 43 using WebType = OwnPtr<WebBluetoothDeviceInit>;
42 static BluetoothDevice* take(ScriptPromiseResolver*, PassOwnPtr<WebBluetooth DeviceInit>); 44 static BluetoothDevice* take(ScriptPromiseResolver*, PassOwnPtr<WebBluetooth DeviceInit>);
43 45
(...skipping 14 matching lines...) Expand all
58 void stop() override; 60 void stop() override;
59 61
60 // If gatt is connected then disconnects and sets gatt.connected to false. 62 // If gatt is connected then disconnects and sets gatt.connected to false.
61 // Returns true if gatt was disconnected. 63 // Returns true if gatt was disconnected.
62 bool disconnectGATTIfConnected(); 64 bool disconnectGATTIfConnected();
63 65
64 // EventTarget methods: 66 // EventTarget methods:
65 const AtomicString& interfaceName() const override; 67 const AtomicString& interfaceName() const override;
66 ExecutionContext* getExecutionContext() const override; 68 ExecutionContext* getExecutionContext() const override;
67 69
70 // WebBluetoothDevice interface:
71 void dispatchGattServerDisconnected() override;
72
68 // Interface required by Garbage Collection: 73 // Interface required by Garbage Collection:
69 DECLARE_VIRTUAL_TRACE(); 74 DECLARE_VIRTUAL_TRACE();
70 75
71 // IDL exposed interface: 76 // IDL exposed interface:
72 String id() { return m_webDevice->id; } 77 String id() { return m_webDevice->id; }
73 String name() { return m_webDevice->name; } 78 String name() { return m_webDevice->name; }
74 BluetoothRemoteGATTServer* gatt() { return m_gatt; } 79 BluetoothRemoteGATTServer* gatt() { return m_gatt; }
75 Vector<String> uuids(); 80 Vector<String> uuids();
76 // TODO(ortuno): Remove connectGATT 81 // TODO(ortuno): Remove connectGATT
77 // http://crbug.com/582292 82 // http://crbug.com/582292
78 ScriptPromise connectGATT(ScriptState*); 83 ScriptPromise connectGATT(ScriptState*);
79 84
80 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected); 85 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected);
81 86
82 private: 87 private:
83 OwnPtr<WebBluetoothDeviceInit> m_webDevice; 88 OwnPtr<WebBluetoothDeviceInit> m_webDevice;
84 Member<BluetoothRemoteGATTServer> m_gatt; 89 Member<BluetoothRemoteGATTServer> m_gatt;
85 }; 90 };
86 91
87 } // namespace blink 92 } // namespace blink
88 93
89 #endif // BluetoothDevice_h 94 #endif // BluetoothDevice_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698