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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/Bluetooth.h

Issue 2565913002: [Onion Soup] Move WebBluetoothImpl from //content/renderer/bluetooth to Blink's bluetooth module (Closed)
Patch Set: renamed BluetoothUUID.typemap to Bluetooth.typemap Created 3 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/bluetooth/Bluetooth.h
diff --git a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.h b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.h
index 53246494860369adbf764a488d8aae84b1f5b8b0..9b058895742b2a324ccf7aae0ce93839d2759f45 100644
--- a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.h
+++ b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.h
@@ -8,40 +8,87 @@
#include "bindings/core/v8/ScriptPromise.h"
#include "bindings/core/v8/ScriptWrappable.h"
#include "modules/bluetooth/BluetoothDevice.h"
+#include "mojo/public/cpp/bindings/associated_binding.h"
#include "platform/heap/Handle.h"
+#include "public/platform/modules/bluetooth/web_bluetooth.mojom-blink.h"
#include <memory>
namespace blink {
+class BluetoothRemoteGATTCharacteristic;
class RequestDeviceOptions;
class ScriptPromise;
class ScriptState;
-class Bluetooth : public GarbageCollected<Bluetooth>, public ScriptWrappable {
+class Bluetooth : public GarbageCollectedFinalized<Bluetooth>,
+ public ScriptWrappable,
+ public mojom::blink::WebBluetoothServiceClient {
DEFINE_WRAPPERTYPEINFO();
+ USING_PRE_FINALIZER(Bluetooth, dispose);
public:
static Bluetooth* create() { return new Bluetooth(); }
+ void dispose();
+
// BluetoothDiscovery interface
ScriptPromise requestDevice(ScriptState*,
const RequestDeviceOptions&,
ExceptionState&);
+ mojom::blink::WebBluetoothService* service() { return m_service.get(); }
+
+ void addDevice(const String& deviceId, BluetoothDevice*);
+
+ void removeDevice(const String& deviceId);
+
+ void registerCharacteristicObject(const String& characteristicInstanceId,
+ BluetoothRemoteGATTCharacteristic*);
+ void characteristicObjectRemoved(const String& characteristicInstanceId);
+
// Interface required by Garbage Collection:
DECLARE_VIRTUAL_TRACE();
private:
- friend class RequestDeviceCallback;
+ Bluetooth();
+
+ // mojom::blink::WebBluetoothServiceClient:
+ void RemoteCharacteristicValueChanged(
+ const WTF::String& characteristicInstanceId,
+ const WTF::Vector<uint8_t>& value) override;
+ void GattServerDisconnected(mojom::blink::WebBluetoothDeviceIdPtr) override;
- BluetoothDevice* getBluetoothDeviceRepresentingDevice(
- std::unique_ptr<WebBluetoothDeviceInit>,
- ScriptPromiseResolver*);
+ BluetoothDevice* getBluetoothDeviceRepresentingDevice(const String& id,
+ const String& name,
+ ScriptPromiseResolver*);
+
+ void RequestDeviceCallback(ScriptPromiseResolver*,
+ mojom::blink::WebBluetoothResult,
+ mojom::blink::WebBluetoothDevicePtr);
// Map of device ids to BluetoothDevice objects.
// Ensures only one BluetoothDevice instance represents each
// Bluetooth device inside a single global object.
HeapHashMap<String, Member<BluetoothDevice>> m_deviceInstanceMap;
+
+ // Map of characteristic instance ids to BluetoothRemoteGATTCharacteristic.
+ // When characteristicObjectRemoved is called the characteristic should be
+ // removed from the map. Keeps track of what characteristics have listeners.
+ HeapHashMap<String, Member<BluetoothRemoteGATTCharacteristic>>
+ m_activeCharacteristics;
+
+ // Map of device ids to BluetoothDevice. Added in
+ // BluetoothRemoteGATTServer::connect() and removed in
+ // BluetoothRemoteGATTServer::disconnect(). This means a device may not
+ // actually be connected while in this map, but that it will definitely be
+ // removed when the page navigates.
+ HeapHashMap<String, Member<BluetoothDevice>> m_connectedDevices;
+
+ mojom::blink::WebBluetoothServicePtr m_service;
+
+ // Binding associated with |m_service|.
+ mojo::AssociatedBinding<mojom::blink::WebBluetoothServiceClient>
+ m_clientBinding;
};
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/bluetooth/BUILD.gn ('k') | third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698