Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | |
| 6 #define CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | |
| 7 | |
| 8 #include "base/id_map.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "content/child/worker_task_runner.h" | |
| 11 #include "content/common/bluetooth/bluetooth_error.h" | |
| 12 #include "third_party/WebKit/public/platform/WebBluetooth.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class MessageLoop; | |
| 16 class TaskRunner; | |
| 17 } | |
| 18 | |
| 19 namespace IPC { | |
| 20 class Message; | |
| 21 } | |
| 22 | |
| 23 namespace content { | |
| 24 class ThreadSafeSender; | |
| 25 | |
| 26 class BluetoothDispatcher : public WorkerTaskRunner::Observer { | |
| 27 public: | |
| 28 explicit BluetoothDispatcher(ThreadSafeSender* sender); | |
| 29 ~BluetoothDispatcher() override; | |
| 30 | |
| 31 // Gets or Creates a BluetoothDispatcher for the current thread. | |
| 32 // |thread_safe_sender| is required when constructing a BluetoothDispatcher. | |
| 33 static BluetoothDispatcher* GetOrCreateThreadSpecificInstance( | |
| 34 ThreadSafeSender* thread_safe_sender); | |
| 35 | |
| 36 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener. | |
| 37 bool Send(IPC::Message* msg); | |
| 38 void OnMessageReceived(const IPC::Message& msg); | |
| 39 | |
| 40 // Corresponding to WebBluetoothImpl methods. | |
| 41 // TODO: Remove old void version after crrev.com/715613005 lands. | |
| 42 void requestDevice( | |
| 43 blink::WebCallbacks<void, blink::WebBluetoothError>* callbacks); | |
| 44 void requestDevice(blink::WebCallbacks<blink::WebBluetoothDevice, | |
| 45 blink::WebBluetoothError>* callbacks); | |
| 46 void SetBluetoothMockDataSetForTesting(const std::string& name); | |
| 47 | |
| 48 // WorkerTaskRunner::Observer implementation. | |
| 49 void OnWorkerRunLoopStopped() override; | |
| 50 | |
| 51 private: | |
| 52 // IPC Handlers, see definitions in bluetooth_messages.h. | |
| 53 void OnRequestDeviceSuccess(int thread_id, | |
| 54 int request_id, | |
| 55 const std::string& device_id); | |
|
Jeffrey Yasskin
2014/11/24 23:30:11
We should be consistent between instance_id and de
scheib
2014/11/25 16:11:06
Done.
| |
| 56 void OnRequestDeviceError(int thread_id, | |
| 57 int request_id, | |
| 58 BluetoothError error_type); | |
| 59 | |
| 60 scoped_refptr<ThreadSafeSender> thread_safe_sender_; | |
| 61 | |
| 62 // Tracks requests sent to browser to match replies with callbacks. | |
| 63 // Owns callback objects. | |
| 64 // TODO: Remove old void version after crrev.com/715613005 lands. | |
| 65 IDMap<blink::WebCallbacks<void, blink::WebBluetoothError>, IDMapOwnPointer> | |
| 66 pending_requests_old_; | |
| 67 IDMap< | |
| 68 blink::WebCallbacks<blink::WebBluetoothDevice, blink::WebBluetoothError>, | |
| 69 IDMapOwnPointer> pending_requests_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); | |
| 72 }; | |
| 73 | |
| 74 } // namespace content | |
| 75 | |
| 76 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | |
| OLD | NEW |