| 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 19 matching lines...) Expand all Loading... |
| 30 class BluetoothDispatcher; | 30 class BluetoothDispatcher; |
| 31 class ThreadSafeSender; | 31 class ThreadSafeSender; |
| 32 class ServiceRegistry; | 32 class ServiceRegistry; |
| 33 | 33 |
| 34 // Implementation of blink::WebBluetooth. Passes calls through to the thread | 34 // Implementation of blink::WebBluetooth. Passes calls through to the thread |
| 35 // specific BluetoothDispatcher. | 35 // specific BluetoothDispatcher. |
| 36 class CONTENT_EXPORT WebBluetoothImpl | 36 class CONTENT_EXPORT WebBluetoothImpl |
| 37 : NON_EXPORTED_BASE(public blink::mojom::WebBluetoothServiceClient), | 37 : NON_EXPORTED_BASE(public blink::mojom::WebBluetoothServiceClient), |
| 38 NON_EXPORTED_BASE(public blink::WebBluetooth) { | 38 NON_EXPORTED_BASE(public blink::WebBluetooth) { |
| 39 public: | 39 public: |
| 40 WebBluetoothImpl(ServiceRegistry* service_registry, | 40 WebBluetoothImpl(ServiceRegistry* service_registry); |
| 41 ThreadSafeSender* thread_safe_sender, | |
| 42 int frame_routing_id); | |
| 43 ~WebBluetoothImpl() override; | 41 ~WebBluetoothImpl() override; |
| 44 | 42 |
| 45 // blink::WebBluetooth interface: | 43 // blink::WebBluetooth interface: |
| 46 void requestDevice( | 44 void requestDevice( |
| 47 const blink::WebRequestDeviceOptions& options, | 45 const blink::WebRequestDeviceOptions& options, |
| 48 blink::WebBluetoothRequestDeviceCallbacks* callbacks) override; | 46 blink::WebBluetoothRequestDeviceCallbacks* callbacks) override; |
| 49 void connect( | 47 void connect( |
| 50 const blink::WebString& device_id, | 48 const blink::WebString& device_id, |
| 51 blink::WebBluetoothRemoteGATTServerConnectCallbacks* callbacks) override; | 49 blink::WebBluetoothRemoteGATTServerConnectCallbacks* callbacks) override; |
| 52 void disconnect(const blink::WebString& device_id) override; | 50 void disconnect(const blink::WebString& device_id) override; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 78 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override; | 76 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override; |
| 79 | 77 |
| 80 private: | 78 private: |
| 81 struct GetCharacteristicsCallback; | 79 struct GetCharacteristicsCallback; |
| 82 // WebBluetoothServiceClient methods: | 80 // WebBluetoothServiceClient methods: |
| 83 void RemoteCharacteristicValueChanged( | 81 void RemoteCharacteristicValueChanged( |
| 84 const mojo::String& characteristic_instance_id, | 82 const mojo::String& characteristic_instance_id, |
| 85 mojo::Array<uint8_t> value) override; | 83 mojo::Array<uint8_t> value) override; |
| 86 | 84 |
| 87 // Callbacks for WebBluetoothService calls: | 85 // Callbacks for WebBluetoothService calls: |
| 86 void OnRequestDeviceComplete( |
| 87 std::unique_ptr<blink::WebBluetoothRequestDeviceCallbacks> callbacks, |
| 88 const blink::mojom::WebBluetoothError error, |
| 89 blink::mojom::WebBluetoothDevicePtr device); |
| 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, |
| 96 blink::mojom::WebBluetoothRemoteGATTServicePtr service); | 98 blink::mojom::WebBluetoothRemoteGATTServicePtr service); |
| 97 void OnGetCharacteristicsComplete( | 99 void OnGetCharacteristicsComplete( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 111 void OnStartNotificationsComplete( | 113 void OnStartNotificationsComplete( |
| 112 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks, | 114 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks, |
| 113 blink::mojom::WebBluetoothError error); | 115 blink::mojom::WebBluetoothError error); |
| 114 void OnStopNotificationsComplete( | 116 void OnStopNotificationsComplete( |
| 115 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks); | 117 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks); |
| 116 | 118 |
| 117 void DispatchCharacteristicValueChanged( | 119 void DispatchCharacteristicValueChanged( |
| 118 const std::string& characteristic_instance_id, | 120 const std::string& characteristic_instance_id, |
| 119 const std::vector<uint8_t>& value); | 121 const std::vector<uint8_t>& value); |
| 120 | 122 |
| 121 BluetoothDispatcher* GetDispatcher(); | |
| 122 | |
| 123 blink::mojom::WebBluetoothService& GetWebBluetoothService(); | 123 blink::mojom::WebBluetoothService& GetWebBluetoothService(); |
| 124 ServiceRegistry* const service_registry_; | 124 ServiceRegistry* const service_registry_; |
| 125 blink::mojom::WebBluetoothServicePtr web_bluetooth_service_; | 125 blink::mojom::WebBluetoothServicePtr web_bluetooth_service_; |
| 126 | 126 |
| 127 // Map of characteristic_instance_ids to | 127 // Map of characteristic_instance_ids to |
| 128 // WebBluetoothRemoteGATTCharacteristics. When characteristicObjectRemoved is | 128 // WebBluetoothRemoteGATTCharacteristics. When characteristicObjectRemoved is |
| 129 // called the characteristic should be removed from the map. | 129 // called the characteristic should be removed from the map. |
| 130 // Keeps track of what characteristics have listeners. | 130 // Keeps track of what characteristics have listeners. |
| 131 std::unordered_map<std::string, blink::WebBluetoothRemoteGATTCharacteristic*> | 131 std::unordered_map<std::string, blink::WebBluetoothRemoteGATTCharacteristic*> |
| 132 active_characteristics_; | 132 active_characteristics_; |
| 133 | 133 |
| 134 // Binding associated with |web_bluetooth_service_|. | 134 // Binding associated with |web_bluetooth_service_|. |
| 135 mojo::AssociatedBinding<blink::mojom::WebBluetoothServiceClient> binding_; | 135 mojo::AssociatedBinding<blink::mojom::WebBluetoothServiceClient> binding_; |
| 136 | 136 |
| 137 const scoped_refptr<ThreadSafeSender> thread_safe_sender_; | |
| 138 const int frame_routing_id_; | |
| 139 | |
| 140 DISALLOW_COPY_AND_ASSIGN(WebBluetoothImpl); | 137 DISALLOW_COPY_AND_ASSIGN(WebBluetoothImpl); |
| 141 }; | 138 }; |
| 142 | 139 |
| 143 } // namespace content | 140 } // namespace content |
| 144 | 141 |
| 145 #endif // CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ | 142 #endif // CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ |
| OLD | NEW |