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

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

Issue 2615093002: Typemap WebBluetoothDeviceId to WTF::String (Closed)
Patch Set: merge master Created 3 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 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/ContextLifecycleObserver.h" 9 #include "core/dom/ContextLifecycleObserver.h"
10 #include "modules/EventTargetModules.h" 10 #include "modules/EventTargetModules.h"
(...skipping 19 matching lines...) Expand all
30 // "Interface required by CallbackPromiseAdapter" section and the 30 // "Interface required by CallbackPromiseAdapter" section and the
31 // CallbackPromiseAdapter class comments. 31 // CallbackPromiseAdapter class comments.
32 class BluetoothDevice final : public EventTargetWithInlineData, 32 class BluetoothDevice final : public EventTargetWithInlineData,
33 public ContextLifecycleObserver { 33 public ContextLifecycleObserver {
34 USING_PRE_FINALIZER(BluetoothDevice, dispose); 34 USING_PRE_FINALIZER(BluetoothDevice, dispose);
35 DEFINE_WRAPPERTYPEINFO(); 35 DEFINE_WRAPPERTYPEINFO();
36 USING_GARBAGE_COLLECTED_MIXIN(BluetoothDevice); 36 USING_GARBAGE_COLLECTED_MIXIN(BluetoothDevice);
37 37
38 public: 38 public:
39 BluetoothDevice(ExecutionContext*, 39 BluetoothDevice(ExecutionContext*,
40 const String& id, 40 mojom::blink::WebBluetoothDevicePtr,
41 const String& name,
42 Bluetooth*); 41 Bluetooth*);
43 42
44 // Interface required by CallbackPromiseAdapter: 43 // Interface required by CallbackPromiseAdapter:
45 static BluetoothDevice* take(ScriptPromiseResolver*, 44 static BluetoothDevice* take(ScriptPromiseResolver*,
46 const String& id, 45 mojom::blink::WebBluetoothDevicePtr,
47 const String& name,
48 Bluetooth*); 46 Bluetooth*);
49 47
50 static mojom::blink::WebBluetoothDeviceIdPtr createMojoDeviceId(
51 const String& deviceId);
52
53 BluetoothRemoteGATTService* getOrCreateRemoteGATTService( 48 BluetoothRemoteGATTService* getOrCreateRemoteGATTService(
54 const String& serviceInstanceId, 49 mojom::blink::WebBluetoothRemoteGATTServicePtr,
55 const String& uuid,
56 bool isPrimary, 50 bool isPrimary,
57 const String& deviceInstanceId); 51 const String& deviceInstanceId);
58 bool isValidService(const String& serviceInstanceId); 52 bool isValidService(const String& serviceInstanceId);
59 53
60 BluetoothRemoteGATTCharacteristic* getOrCreateRemoteGATTCharacteristic( 54 BluetoothRemoteGATTCharacteristic* getOrCreateRemoteGATTCharacteristic(
61 ExecutionContext*, 55 ExecutionContext*,
62 const String& characteristicInstanceId,
63 const String& serviceInstanceId, 56 const String& serviceInstanceId,
64 const String& uuid, 57 mojom::blink::WebBluetoothRemoteGATTCharacteristicPtr,
65 uint32_t characteristicProperties,
66 BluetoothRemoteGATTService*); 58 BluetoothRemoteGATTService*);
67 bool isValidCharacteristic(const String& characteristicInstanceId); 59 bool isValidCharacteristic(const String& characteristicInstanceId);
68 60
69 // We should disconnect from the device in all of the following cases: 61 // We should disconnect from the device in all of the following cases:
70 // 1. When the object gets GarbageCollected e.g. it went out of scope. 62 // 1. When the object gets GarbageCollected e.g. it went out of scope.
71 // dispose() is called in this case. 63 // dispose() is called in this case.
72 // 2. When the parent document gets detached e.g. reloading a page. 64 // 2. When the parent document gets detached e.g. reloading a page.
73 // stop() is called in this case. 65 // stop() is called in this case.
74 // TODO(ortuno): Users should be able to turn on notifications for 66 // TODO(ortuno): Users should be able to turn on notifications for
75 // events on navigator.bluetooth and still remain connected even if the 67 // events on navigator.bluetooth and still remain connected even if the
(...skipping 21 matching lines...) Expand all
97 ExecutionContext* getExecutionContext() const override; 89 ExecutionContext* getExecutionContext() const override;
98 90
99 void dispatchGattServerDisconnected(); 91 void dispatchGattServerDisconnected();
100 92
101 Bluetooth* bluetooth() { return m_bluetooth; } 93 Bluetooth* bluetooth() { return m_bluetooth; }
102 94
103 // Interface required by Garbage Collection: 95 // Interface required by Garbage Collection:
104 DECLARE_VIRTUAL_TRACE(); 96 DECLARE_VIRTUAL_TRACE();
105 97
106 // IDL exposed interface: 98 // IDL exposed interface:
107 String id() { return m_id; } 99 String id() { return m_device->id; }
108 String name() { return m_name; } 100 String name() { return m_device->name; }
109 BluetoothRemoteGATTServer* gatt() { return m_gatt; } 101 BluetoothRemoteGATTServer* gatt() { return m_gatt; }
110 102
111 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected); 103 DEFINE_ATTRIBUTE_EVENT_LISTENER(gattserverdisconnected);
112 104
113 private: 105 private:
114 // Holds all GATT Attributes associated with this BluetoothDevice. 106 // Holds all GATT Attributes associated with this BluetoothDevice.
115 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap; 107 Member<BluetoothAttributeInstanceMap> m_attributeInstanceMap;
116 108
117 const String m_id; 109 mojom::blink::WebBluetoothDevicePtr m_device;
118 const String m_name;
119 Member<BluetoothRemoteGATTServer> m_gatt; 110 Member<BluetoothRemoteGATTServer> m_gatt;
120 Member<Bluetooth> m_bluetooth; 111 Member<Bluetooth> m_bluetooth;
121 }; 112 };
122 113
123 } // namespace blink 114 } // namespace blink
124 115
125 #endif // BluetoothDevice_h 116 #endif // BluetoothDevice_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698