Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: content/child/bluetooth/bluetooth_dispatcher.h

Issue 1159523002: bluetooth: Browser side partial implementation of getPrimaryService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove anonymous namespace Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 base { 15 namespace base {
16 class MessageLoop; 16 class MessageLoop;
17 class TaskRunner; 17 class TaskRunner;
18 } 18 }
19 19
20 namespace IPC { 20 namespace IPC {
21 class Message; 21 class Message;
22 } 22 }
23 23
24 struct BluetoothPrimaryServiceRequest;
25
24 namespace content { 26 namespace content {
25 class ThreadSafeSender; 27 class ThreadSafeSender;
26 28
27 // Dispatcher for child process threads which communicates to the browser's 29 // Dispatcher for child process threads which communicates to the browser's
28 // BluetoothDispatcherHost. 30 // BluetoothDispatcherHost.
29 // 31 //
30 // Instances are created for each thread as necessary by WebBluetoothImpl. 32 // Instances are created for each thread as necessary by WebBluetoothImpl.
31 // 33 //
32 // Incoming IPC messages are received by the BluetoothMessageFilter and 34 // Incoming IPC messages are received by the BluetoothMessageFilter and
33 // directed to the thread specific instance of this class. 35 // directed to the thread specific instance of this class.
34 // Outgoing messages come from WebBluetoothImpl. 36 // Outgoing messages come from WebBluetoothImpl.
35 class BluetoothDispatcher : public WorkerTaskRunner::Observer { 37 class BluetoothDispatcher : public WorkerTaskRunner::Observer {
36 public: 38 public:
37 explicit BluetoothDispatcher(ThreadSafeSender* sender); 39 explicit BluetoothDispatcher(ThreadSafeSender* sender);
38 ~BluetoothDispatcher() override; 40 ~BluetoothDispatcher() override;
39 41
40 // Gets or Creates a BluetoothDispatcher for the current thread. 42 // Gets or Creates a BluetoothDispatcher for the current thread.
41 // |thread_safe_sender| is required when constructing a BluetoothDispatcher. 43 // |thread_safe_sender| is required when constructing a BluetoothDispatcher.
42 static BluetoothDispatcher* GetOrCreateThreadSpecificInstance( 44 static BluetoothDispatcher* GetOrCreateThreadSpecificInstance(
43 ThreadSafeSender* thread_safe_sender); 45 ThreadSafeSender* thread_safe_sender);
44 46
45 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener. 47 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener.
46 bool Send(IPC::Message* msg); 48 bool Send(IPC::Message* msg);
47 void OnMessageReceived(const IPC::Message& msg); 49 void OnMessageReceived(const IPC::Message& msg);
48 50
49 // Corresponding to WebBluetoothImpl methods. 51 // Corresponding to WebBluetoothImpl methods.
50 void requestDevice(blink::WebBluetoothRequestDeviceCallbacks* callbacks); 52 void requestDevice(blink::WebBluetoothRequestDeviceCallbacks* callbacks);
51 void connectGATT(const blink::WebString& device_instance_id, 53 void connectGATT(const blink::WebString& device_instance_id,
52 blink::WebBluetoothConnectGATTCallbacks* callbacks); 54 blink::WebBluetoothConnectGATTCallbacks* callbacks);
55 void getPrimaryService(
56 const blink::WebString& device_instance_id,
57 const blink::WebString& service_uuid,
58 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks);
53 59
54 // WorkerTaskRunner::Observer implementation. 60 // WorkerTaskRunner::Observer implementation.
55 void OnWorkerRunLoopStopped() override; 61 void OnWorkerRunLoopStopped() override;
56 62
57 private: 63 private:
58 // IPC Handlers, see definitions in bluetooth_messages.h. 64 // IPC Handlers, see definitions in bluetooth_messages.h.
59 void OnRequestDeviceSuccess(int thread_id, 65 void OnRequestDeviceSuccess(int thread_id,
60 int request_id, 66 int request_id,
61 const BluetoothDevice& device); 67 const BluetoothDevice& device);
62 void OnRequestDeviceError(int thread_id, 68 void OnRequestDeviceError(int thread_id,
63 int request_id, 69 int request_id,
64 BluetoothError error_type); 70 BluetoothError error_type);
65 71
66 void OnConnectGATTSuccess(int thread_id, 72 void OnConnectGATTSuccess(int thread_id,
67 int request_id, 73 int request_id,
68 const std::string& message); 74 const std::string& message);
69 75
70 void OnConnectGATTError(int thread_id, 76 void OnConnectGATTError(int thread_id,
71 int request_id, 77 int request_id,
72 BluetoothError error_type); 78 BluetoothError error_type);
79 void OnGetPrimaryServiceSuccess(int thread_id,
80 int request_id,
81 const std::string& service_instance_id);
82 void OnGetPrimaryServiceError(int thread_id,
83 int request_id,
84 BluetoothError error_type);
73 85
74 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 86 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
75 87
76 // Tracks device requests sent to browser to match replies with callbacks. 88 // Tracks device requests sent to browser to match replies with callbacks.
77 // Owns callback objects. 89 // Owns callback objects.
78 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> 90 IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer>
79 pending_requests_; 91 pending_requests_;
80 // Tracks requests to connect to a device. 92 // Tracks requests to connect to a device.
81 // Owns callback objects. 93 // Owns callback objects.
82 IDMap<blink::WebBluetoothConnectGATTCallbacks, IDMapOwnPointer> 94 IDMap<blink::WebBluetoothConnectGATTCallbacks, IDMapOwnPointer>
83 pending_connect_requests_; 95 pending_connect_requests_;
96 // Tracks requests to get a primary service from a device.
97 // Owns request objects.
98 IDMap<BluetoothPrimaryServiceRequest, IDMapOwnPointer>
99 pending_primary_service_requests_;
84 100
85 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); 101 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher);
86 }; 102 };
87 103
88 } // namespace content 104 } // namespace content
89 105
90 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ 106 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_dispatcher_host.cc ('k') | content/child/bluetooth/bluetooth_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698