Chromium Code Reviews| 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" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 // |thread_safe_sender| is required when constructing a BluetoothDispatcher. | 41 // |thread_safe_sender| is required when constructing a BluetoothDispatcher. |
| 42 static BluetoothDispatcher* GetOrCreateThreadSpecificInstance( | 42 static BluetoothDispatcher* GetOrCreateThreadSpecificInstance( |
| 43 ThreadSafeSender* thread_safe_sender); | 43 ThreadSafeSender* thread_safe_sender); |
| 44 | 44 |
| 45 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener. | 45 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener. |
| 46 bool Send(IPC::Message* msg); | 46 bool Send(IPC::Message* msg); |
| 47 void OnMessageReceived(const IPC::Message& msg); | 47 void OnMessageReceived(const IPC::Message& msg); |
| 48 | 48 |
| 49 // Corresponding to WebBluetoothImpl methods. | 49 // Corresponding to WebBluetoothImpl methods. |
| 50 void requestDevice(blink::WebBluetoothRequestDeviceCallbacks* callbacks); | 50 void requestDevice(blink::WebBluetoothRequestDeviceCallbacks* callbacks); |
| 51 void connectGATT(std::string instance_id, | |
| 52 blink::WebBluetoothConnectGATTCallbacks* callbacks); | |
| 51 void SetBluetoothMockDataSetForTesting(const std::string& name); | 53 void SetBluetoothMockDataSetForTesting(const std::string& name); |
| 52 | 54 |
| 53 // WorkerTaskRunner::Observer implementation. | 55 // WorkerTaskRunner::Observer implementation. |
| 54 void OnWorkerRunLoopStopped() override; | 56 void OnWorkerRunLoopStopped() override; |
| 55 | 57 |
| 56 private: | 58 private: |
| 57 // IPC Handlers, see definitions in bluetooth_messages.h. | 59 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 58 void OnRequestDeviceSuccess(int thread_id, | 60 void OnRequestDeviceSuccess(int thread_id, |
| 59 int request_id, | 61 int request_id, |
| 60 const BluetoothDevice& device); | 62 const BluetoothDevice& device); |
| 61 void OnRequestDeviceError(int thread_id, | 63 void OnRequestDeviceError(int thread_id, |
| 62 int request_id, | 64 int request_id, |
| 63 BluetoothError error_type); | 65 BluetoothError error_type); |
| 64 | 66 |
| 67 void OnConnectGATTSuccess(int thread_id, | |
| 68 int request_id, | |
| 69 const std::string& message); | |
| 70 | |
| 65 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | 71 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 66 | 72 |
| 67 // Tracks requests sent to browser to match replies with callbacks. | 73 // Tracks requests sent to browser to match replies with callbacks. |
| 68 // Owns callback objects. | 74 // Owns callback objects. |
| 69 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> | 75 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> |
| 70 pending_requests_; | 76 pending_requests_; |
| 77 // TODO(ortuno): Create an callback interface to use in the map. | |
|
scheib
2015/04/19 04:44:19
Drop the TODO comment for now. I'm not certain we'
ortuno
2015/04/20 20:09:33
Done.
| |
| 78 IDMap<blink::WebBluetoothConnectGATTCallbacks, IDMapOwnPointer> | |
| 79 pending_connect_requests_; | |
| 71 | 80 |
| 72 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); | 81 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); |
| 73 }; | 82 }; |
| 74 | 83 |
| 75 } // namespace content | 84 } // namespace content |
| 76 | 85 |
| 77 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 86 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
| OLD | NEW |