| 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 "base/id_map.h" | 8 #include "base/id_map.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "content/child/worker_task_runner.h" | 10 #include "content/child/worker_task_runner.h" |
| 11 #include "content/common/bluetooth/bluetooth_device.h" | 11 #include "content/common/bluetooth/bluetooth_device.h" |
| 12 #include "content/common/bluetooth/bluetooth_error.h" | 12 #include "content/common/bluetooth/bluetooth_error.h" |
| 13 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetooth.h" | 13 #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetooth.h" |
| 14 | 14 |
| 15 namespace { |
| 16 struct BluetoothPrimaryServiceRequest; |
| 17 } |
| 18 |
| 15 namespace base { | 19 namespace base { |
| 16 class MessageLoop; | 20 class MessageLoop; |
| 17 class TaskRunner; | 21 class TaskRunner; |
| 18 } | 22 } |
| 19 | 23 |
| 20 namespace IPC { | 24 namespace IPC { |
| 21 class Message; | 25 class Message; |
| 22 } | 26 } |
| 23 | 27 |
| 24 namespace content { | 28 namespace content { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 43 ThreadSafeSender* thread_safe_sender); | 47 ThreadSafeSender* thread_safe_sender); |
| 44 | 48 |
| 45 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener. | 49 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener. |
| 46 bool Send(IPC::Message* msg); | 50 bool Send(IPC::Message* msg); |
| 47 void OnMessageReceived(const IPC::Message& msg); | 51 void OnMessageReceived(const IPC::Message& msg); |
| 48 | 52 |
| 49 // Corresponding to WebBluetoothImpl methods. | 53 // Corresponding to WebBluetoothImpl methods. |
| 50 void requestDevice(blink::WebBluetoothRequestDeviceCallbacks* callbacks); | 54 void requestDevice(blink::WebBluetoothRequestDeviceCallbacks* callbacks); |
| 51 void connectGATT(const blink::WebString& device_instance_id, | 55 void connectGATT(const blink::WebString& device_instance_id, |
| 52 blink::WebBluetoothConnectGATTCallbacks* callbacks); | 56 blink::WebBluetoothConnectGATTCallbacks* callbacks); |
| 57 void getPrimaryService( |
| 58 const blink::WebString& device_instance_id, |
| 59 const blink::WebString& service_uuid, |
| 60 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks); |
| 53 | 61 |
| 54 // WorkerTaskRunner::Observer implementation. | 62 // WorkerTaskRunner::Observer implementation. |
| 55 void OnWorkerRunLoopStopped() override; | 63 void OnWorkerRunLoopStopped() override; |
| 56 | 64 |
| 57 private: | 65 private: |
| 58 // IPC Handlers, see definitions in bluetooth_messages.h. | 66 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 59 void OnRequestDeviceSuccess(int thread_id, | 67 void OnRequestDeviceSuccess(int thread_id, |
| 60 int request_id, | 68 int request_id, |
| 61 const BluetoothDevice& device); | 69 const BluetoothDevice& device); |
| 62 void OnRequestDeviceError(int thread_id, | 70 void OnRequestDeviceError(int thread_id, |
| 63 int request_id, | 71 int request_id, |
| 64 BluetoothError error_type); | 72 BluetoothError error_type); |
| 65 | 73 |
| 66 void OnConnectGATTSuccess(int thread_id, | 74 void OnConnectGATTSuccess(int thread_id, |
| 67 int request_id, | 75 int request_id, |
| 68 const std::string& message); | 76 const std::string& message); |
| 69 | 77 |
| 70 void OnConnectGATTError(int thread_id, | 78 void OnConnectGATTError(int thread_id, |
| 71 int request_id, | 79 int request_id, |
| 72 BluetoothError error_type); | 80 BluetoothError error_type); |
| 81 void OnGetPrimaryServiceSuccess(int thread_id, |
| 82 int request_id, |
| 83 const std::string& service_instance_id); |
| 84 void OnGetPrimaryServiceError(int thread_id, |
| 85 int request_id, |
| 86 BluetoothError error_type); |
| 73 | 87 |
| 74 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 88 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 75 | 89 |
| 76 // Tracks device requests sent to browser to match replies with callbacks. | 90 // Tracks device requests sent to browser to match replies with callbacks. |
| 77 // Owns callback objects. | 91 // Owns callback objects. |
| 78 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> | 92 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> |
| 79 pending_requests_; | 93 pending_requests_; |
| 80 // Tracks requests to connect to a device. | 94 // Tracks requests to connect to a device. |
| 81 // Owns callback objects. | 95 // Owns callback objects. |
| 82 IDMap<blink::WebBluetoothConnectGATTCallbacks, IDMapOwnPointer> | 96 IDMap<blink::WebBluetoothConnectGATTCallbacks, IDMapOwnPointer> |
| 83 pending_connect_requests_; | 97 pending_connect_requests_; |
| 98 // Tracks requests to get a primary service from a device. |
| 99 // Owns request objects. |
| 100 IDMap<BluetoothPrimaryServiceRequest, IDMapOwnPointer> |
| 101 pending_primary_service_requests_; |
| 84 | 102 |
| 85 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); | 103 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); |
| 86 }; | 104 }; |
| 87 | 105 |
| 88 } // namespace content | 106 } // namespace content |
| 89 | 107 |
| 90 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 108 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
| OLD | NEW |