| 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_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
| 6 #define CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 6 #define CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <queue> | 11 #include <queue> |
| 12 | 12 |
| 13 #include "base/id_map.h" | 13 #include "base/id_map.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "content/common/bluetooth/bluetooth_device.h" | 16 #include "content/common/bluetooth/bluetooth_device.h" |
| 17 #include "content/public/child/worker_thread.h" | 17 #include "content/public/child/worker_thread.h" |
| 18 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetooth.h" | 18 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetooth.h" |
| 19 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothError
.h" | 19 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothError
.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class MessageLoop; | 22 class MessageLoop; |
| 23 class TaskRunner; | 23 class TaskRunner; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace blink { | |
| 27 class WebBluetoothRemoteGATTCharacteristic; | |
| 28 } | |
| 29 | |
| 30 namespace IPC { | 26 namespace IPC { |
| 31 class Message; | 27 class Message; |
| 32 } | 28 } |
| 33 | 29 |
| 34 struct BluetoothCharacteristicRequest; | |
| 35 struct BluetoothCharacteristicsRequest; | |
| 36 struct BluetoothPrimaryServiceRequest; | 30 struct BluetoothPrimaryServiceRequest; |
| 37 | 31 |
| 38 namespace content { | 32 namespace content { |
| 39 class ThreadSafeSender; | 33 class ThreadSafeSender; |
| 40 | 34 |
| 41 // Dispatcher for child process threads which communicates to the browser's | 35 // Dispatcher for child process threads which communicates to the browser's |
| 42 // BluetoothDispatcherHost. | 36 // BluetoothDispatcherHost. |
| 43 // | 37 // |
| 44 // Instances are created for each thread as necessary by WebBluetoothImpl. | 38 // Instances are created for each thread as necessary by WebBluetoothImpl. |
| 45 // | 39 // |
| (...skipping 20 matching lines...) Expand all Loading... |
| 66 blink::WebBluetoothRequestDeviceCallbacks* callbacks); | 60 blink::WebBluetoothRequestDeviceCallbacks* callbacks); |
| 67 void connect(int frame_routing_id, | 61 void connect(int frame_routing_id, |
| 68 const blink::WebString& device_id, | 62 const blink::WebString& device_id, |
| 69 blink::WebBluetoothRemoteGATTServerConnectCallbacks* callbacks); | 63 blink::WebBluetoothRemoteGATTServerConnectCallbacks* callbacks); |
| 70 void disconnect(int frame_routing_id, const blink::WebString& device_id); | 64 void disconnect(int frame_routing_id, const blink::WebString& device_id); |
| 71 void getPrimaryService( | 65 void getPrimaryService( |
| 72 int frame_routing_id, | 66 int frame_routing_id, |
| 73 const blink::WebString& device_id, | 67 const blink::WebString& device_id, |
| 74 const blink::WebString& service_uuid, | 68 const blink::WebString& service_uuid, |
| 75 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks); | 69 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks); |
| 76 void getCharacteristic( | |
| 77 int frame_routing_id, | |
| 78 const blink::WebString& service_instance_id, | |
| 79 const blink::WebString& characteristic_uuid, | |
| 80 blink::WebBluetoothGetCharacteristicCallbacks* callbacks); | |
| 81 void getCharacteristics( | |
| 82 int frame_routing_id, | |
| 83 const blink::WebString& service_instance_id, | |
| 84 const blink::WebString& characteristics_uuid, | |
| 85 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks); | |
| 86 | 70 |
| 87 // WorkerThread::Observer implementation. | 71 // WorkerThread::Observer implementation. |
| 88 void WillStopCurrentWorkerThread() override; | 72 void WillStopCurrentWorkerThread() override; |
| 89 | 73 |
| 90 private: | 74 private: |
| 91 // IPC Handlers, see definitions in bluetooth_messages.h. | 75 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 92 void OnRequestDeviceSuccess(int thread_id, | 76 void OnRequestDeviceSuccess(int thread_id, |
| 93 int request_id, | 77 int request_id, |
| 94 const BluetoothDevice& device); | 78 const BluetoothDevice& device); |
| 95 void OnRequestDeviceError(int thread_id, | 79 void OnRequestDeviceError(int thread_id, |
| 96 int request_id, | 80 int request_id, |
| 97 blink::WebBluetoothError error); | 81 blink::WebBluetoothError error); |
| 98 void OnGATTServerConnectSuccess(int thread_id, int request_id); | 82 void OnGATTServerConnectSuccess(int thread_id, int request_id); |
| 99 void OnGATTServerConnectError(int thread_id, | 83 void OnGATTServerConnectError(int thread_id, |
| 100 int request_id, | 84 int request_id, |
| 101 blink::WebBluetoothError error); | 85 blink::WebBluetoothError error); |
| 102 void OnGetPrimaryServiceSuccess(int thread_id, | 86 void OnGetPrimaryServiceSuccess(int thread_id, |
| 103 int request_id, | 87 int request_id, |
| 104 const std::string& service_instance_id); | 88 const std::string& service_instance_id); |
| 105 void OnGetPrimaryServiceError(int thread_id, | 89 void OnGetPrimaryServiceError(int thread_id, |
| 106 int request_id, | 90 int request_id, |
| 107 blink::WebBluetoothError error); | 91 blink::WebBluetoothError error); |
| 108 void OnGetCharacteristicSuccess(int thread_id, | |
| 109 int request_id, | |
| 110 const std::string& characteristic_instance_id, | |
| 111 uint32_t characteristic_properties); | |
| 112 void OnGetCharacteristicError(int thread_id, | |
| 113 int request_id, | |
| 114 blink::WebBluetoothError error); | |
| 115 void OnGetCharacteristicsSuccess( | |
| 116 int thread_id, | |
| 117 int request_id, | |
| 118 const std::vector<std::string>& characteristics_instance_ids, | |
| 119 const std::vector<std::string>& characteristics_uuids, | |
| 120 const std::vector<uint32_t>& characteristic_properties); | |
| 121 void OnGetCharacteristicsError(int thread_id, | |
| 122 int request_id, | |
| 123 blink::WebBluetoothError error); | |
| 124 | 92 |
| 125 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 93 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 126 | 94 |
| 127 // Tracks device requests sent to browser to match replies with callbacks. | 95 // Tracks device requests sent to browser to match replies with callbacks. |
| 128 // Owns callback objects. | 96 // Owns callback objects. |
| 129 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> | 97 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> |
| 130 pending_requests_; | 98 pending_requests_; |
| 131 // Tracks requests to connect to a device. | 99 // Tracks requests to connect to a device. |
| 132 // Owns callback objects. | 100 // Owns callback objects. |
| 133 IDMap<blink::WebBluetoothRemoteGATTServerConnectCallbacks, IDMapOwnPointer> | 101 IDMap<blink::WebBluetoothRemoteGATTServerConnectCallbacks, IDMapOwnPointer> |
| 134 pending_connect_requests_; | 102 pending_connect_requests_; |
| 135 // Tracks requests to get a primary service from a device. | 103 // Tracks requests to get a primary service from a device. |
| 136 // Owns request objects. | 104 // Owns request objects. |
| 137 IDMap<BluetoothPrimaryServiceRequest, IDMapOwnPointer> | 105 IDMap<BluetoothPrimaryServiceRequest, IDMapOwnPointer> |
| 138 pending_primary_service_requests_; | 106 pending_primary_service_requests_; |
| 139 // Tracks requests to get a characteristic from a service. | |
| 140 IDMap<BluetoothCharacteristicRequest, IDMapOwnPointer> | |
| 141 pending_characteristic_requests_; | |
| 142 // Tracks requests to get characteristics from a service. | |
| 143 IDMap<BluetoothCharacteristicsRequest, IDMapOwnPointer> | |
| 144 pending_characteristics_requests_; | |
| 145 | 107 |
| 146 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); | 108 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); |
| 147 }; | 109 }; |
| 148 | 110 |
| 149 } // namespace content | 111 } // namespace content |
| 150 | 112 |
| 151 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 113 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
| OLD | NEW |