| OLD | NEW |
| 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 CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ |
| 6 #define CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ | 6 #define CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 ThreadSafeSender* thread_safe_sender, | 41 ThreadSafeSender* thread_safe_sender, |
| 42 int frame_routing_id); | 42 int frame_routing_id); |
| 43 ~WebBluetoothImpl() override; | 43 ~WebBluetoothImpl() override; |
| 44 | 44 |
| 45 // blink::WebBluetooth interface: | 45 // blink::WebBluetooth interface: |
| 46 void requestDevice( | 46 void requestDevice( |
| 47 const blink::WebRequestDeviceOptions& options, | 47 const blink::WebRequestDeviceOptions& options, |
| 48 blink::WebBluetoothRequestDeviceCallbacks* callbacks) override; | 48 blink::WebBluetoothRequestDeviceCallbacks* callbacks) override; |
| 49 void connect( | 49 void connect( |
| 50 const blink::WebString& device_id, | 50 const blink::WebString& device_id, |
| 51 blink::WebBluetoothDevice* device, |
| 51 blink::WebBluetoothRemoteGATTServerConnectCallbacks* callbacks) override; | 52 blink::WebBluetoothRemoteGATTServerConnectCallbacks* callbacks) override; |
| 52 void disconnect(const blink::WebString& device_id) override; | 53 void disconnect(const blink::WebString& device_id) override; |
| 53 void getPrimaryService( | 54 void getPrimaryService( |
| 54 const blink::WebString& device_id, | 55 const blink::WebString& device_id, |
| 55 const blink::WebString& service_uuid, | 56 const blink::WebString& service_uuid, |
| 56 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks) override; | 57 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks) override; |
| 57 void getCharacteristics( | 58 void getCharacteristics( |
| 58 const blink::WebString& service_instance_id, | 59 const blink::WebString& service_instance_id, |
| 59 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 60 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
| 60 const blink::WebString& characteristics_uuid, | 61 const blink::WebString& characteristics_uuid, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 76 void registerCharacteristicObject( | 77 void registerCharacteristicObject( |
| 77 const blink::WebString& characteristic_instance_id, | 78 const blink::WebString& characteristic_instance_id, |
| 78 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override; | 79 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override; |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 struct GetCharacteristicsCallback; | 82 struct GetCharacteristicsCallback; |
| 82 // WebBluetoothServiceClient methods: | 83 // WebBluetoothServiceClient methods: |
| 83 void RemoteCharacteristicValueChanged( | 84 void RemoteCharacteristicValueChanged( |
| 84 const mojo::String& characteristic_instance_id, | 85 const mojo::String& characteristic_instance_id, |
| 85 mojo::Array<uint8_t> value) override; | 86 mojo::Array<uint8_t> value) override; |
| 87 void GattServerDisconnected(const mojo::String& device_id) override; |
| 86 | 88 |
| 87 // Callbacks for WebBluetoothService calls: | 89 // Callbacks for WebBluetoothService calls: |
| 88 void OnConnectComplete( | 90 void OnConnectComplete( |
| 89 std::unique_ptr<blink::WebBluetoothRemoteGATTServerConnectCallbacks> | 91 std::unique_ptr<blink::WebBluetoothRemoteGATTServerConnectCallbacks> |
| 90 callbacks, | 92 callbacks, |
| 91 blink::mojom::WebBluetoothError error); | 93 blink::mojom::WebBluetoothError error); |
| 92 void OnGetPrimaryServiceComplete( | 94 void OnGetPrimaryServiceComplete( |
| 93 const blink::WebString& device_id, | 95 const blink::WebString& device_id, |
| 94 std::unique_ptr<blink::WebBluetoothGetPrimaryServiceCallbacks> callbacks, | 96 std::unique_ptr<blink::WebBluetoothGetPrimaryServiceCallbacks> callbacks, |
| 95 blink::mojom::WebBluetoothError error, | 97 blink::mojom::WebBluetoothError error, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 124 ServiceRegistry* const service_registry_; | 126 ServiceRegistry* const service_registry_; |
| 125 blink::mojom::WebBluetoothServicePtr web_bluetooth_service_; | 127 blink::mojom::WebBluetoothServicePtr web_bluetooth_service_; |
| 126 | 128 |
| 127 // Map of characteristic_instance_ids to | 129 // Map of characteristic_instance_ids to |
| 128 // WebBluetoothRemoteGATTCharacteristics. When characteristicObjectRemoved is | 130 // WebBluetoothRemoteGATTCharacteristics. When characteristicObjectRemoved is |
| 129 // called the characteristic should be removed from the map. | 131 // called the characteristic should be removed from the map. |
| 130 // Keeps track of what characteristics have listeners. | 132 // Keeps track of what characteristics have listeners. |
| 131 std::unordered_map<std::string, blink::WebBluetoothRemoteGATTCharacteristic*> | 133 std::unordered_map<std::string, blink::WebBluetoothRemoteGATTCharacteristic*> |
| 132 active_characteristics_; | 134 active_characteristics_; |
| 133 | 135 |
| 136 // Map of device_ids to WebBluetoothDevices. Added in connect() and removed in |
| 137 // disconnect(). This means a device may not actually be connected while in |
| 138 // this map, but that it will definitely be removed when the page navigates. |
| 139 std::unordered_map<std::string, blink::WebBluetoothDevice*> |
| 140 connected_devices_; |
| 141 |
| 134 // Binding associated with |web_bluetooth_service_|. | 142 // Binding associated with |web_bluetooth_service_|. |
| 135 mojo::AssociatedBinding<blink::mojom::WebBluetoothServiceClient> binding_; | 143 mojo::AssociatedBinding<blink::mojom::WebBluetoothServiceClient> binding_; |
| 136 | 144 |
| 137 const scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 145 const scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 138 const int frame_routing_id_; | 146 const int frame_routing_id_; |
| 139 | 147 |
| 140 DISALLOW_COPY_AND_ASSIGN(WebBluetoothImpl); | 148 DISALLOW_COPY_AND_ASSIGN(WebBluetoothImpl); |
| 141 }; | 149 }; |
| 142 | 150 |
| 143 } // namespace content | 151 } // namespace content |
| 144 | 152 |
| 145 #endif // CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ | 153 #endif // CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ |
| OLD | NEW |