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

Side by Side Diff: content/browser/bluetooth/bluetooth_dispatcher_host.h

Issue 1775953004: bluetooth: Move writeValue to mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Moar cleanup Created 4 years, 9 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_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 11
12 #include "base/id_map.h" 12 #include "base/id_map.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h" 16 #include "content/browser/bluetooth/bluetooth_allowed_devices_map.h"
17 #include "content/browser/bluetooth/bluetooth_metrics.h"
18 #include "content/common/bluetooth/bluetooth_messages.h"
17 #include "content/public/browser/bluetooth_chooser.h" 19 #include "content/public/browser/bluetooth_chooser.h"
18 #include "content/public/browser/browser_message_filter.h" 20 #include "content/public/browser/browser_message_filter.h"
19 #include "device/bluetooth/bluetooth_adapter.h" 21 #include "device/bluetooth/bluetooth_adapter.h"
20 #include "device/bluetooth/bluetooth_gatt_connection.h" 22 #include "device/bluetooth/bluetooth_gatt_connection.h"
21 #include "device/bluetooth/bluetooth_gatt_notify_session.h" 23 #include "device/bluetooth/bluetooth_gatt_notify_session.h"
22 #include "device/bluetooth/bluetooth_gatt_service.h" 24 #include "device/bluetooth/bluetooth_gatt_service.h"
23 25
24 namespace device { 26 namespace device {
25 class BluetoothUUID; 27 class BluetoothUUID;
26 } 28 }
(...skipping 19 matching lines...) Expand all
46 BluetoothDispatcherHost(int render_process_id); 48 BluetoothDispatcherHost(int render_process_id);
47 // BrowserMessageFilter: 49 // BrowserMessageFilter:
48 void OnDestruct() const override; 50 void OnDestruct() const override;
49 void OverrideThreadForMessage(const IPC::Message& message, 51 void OverrideThreadForMessage(const IPC::Message& message,
50 BrowserThread::ID* thread) override; 52 BrowserThread::ID* thread) override;
51 bool OnMessageReceived(const IPC::Message& message) override; 53 bool OnMessageReceived(const IPC::Message& message) override;
52 54
53 void SetBluetoothAdapterForTesting( 55 void SetBluetoothAdapterForTesting(
54 scoped_refptr<device::BluetoothAdapter> mock_adapter); 56 scoped_refptr<device::BluetoothAdapter> mock_adapter);
55 57
58 struct CacheQueryResult {
59 CacheQueryResult();
60 CacheQueryResult(CacheQueryOutcome outcome);
61 ~CacheQueryResult();
62 blink::WebBluetoothError GetWebError() const;
63 device::BluetoothDevice* device;
Ken Rockot(use gerrit already) 2016/03/09 19:31:26 instead of intializers in each constructor just se
ortuno 2016/03/16 16:29:45 Done.
64 device::BluetoothGattService* service;
65 device::BluetoothGattCharacteristic* characteristic;
66 CacheQueryOutcome outcome;
67 };
68
69 // Queries the platform cache for a characteristic with
70 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|,
71 // |service| and |characteristic| fields if successful.
72 CacheQueryResult QueryCacheForCharacteristic(
73 const url::Origin& origin,
74 const std::string& characteristic_instance_id);
75
56 protected: 76 protected:
57 ~BluetoothDispatcherHost() override; 77 ~BluetoothDispatcherHost() override;
58 78
59 private: 79 private:
60 friend class base::DeleteHelper<BluetoothDispatcherHost>; 80 friend class base::DeleteHelper<BluetoothDispatcherHost>;
61 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 81 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
62 82
63 struct CacheQueryResult;
64 struct RequestDeviceSession; 83 struct RequestDeviceSession;
65 struct PrimaryServicesRequest; 84 struct PrimaryServicesRequest;
66 85
67 // Set |adapter_| to a BluetoothAdapter instance and register observers, 86 // Set |adapter_| to a BluetoothAdapter instance and register observers,
68 // releasing references to previous |adapter_|. 87 // releasing references to previous |adapter_|.
69 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); 88 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter);
70 89
71 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets 90 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets
72 // its timeout. 91 // its timeout.
73 void StartDeviceDiscovery(RequestDeviceSession* session, int chooser_id); 92 void StartDeviceDiscovery(RequestDeviceSession* session, int chooser_id);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 const std::string& characteristic_uuid); 141 const std::string& characteristic_uuid);
123 void OnGetCharacteristics(int thread_id, 142 void OnGetCharacteristics(int thread_id,
124 int request_id, 143 int request_id,
125 int frame_routing_id, 144 int frame_routing_id,
126 const std::string& service_instance_id, 145 const std::string& service_instance_id,
127 const std::string& characteristics_uuid); 146 const std::string& characteristics_uuid);
128 void OnReadValue(int thread_id, 147 void OnReadValue(int thread_id,
129 int request_id, 148 int request_id,
130 int frame_routing_id, 149 int frame_routing_id,
131 const std::string& characteristic_instance_id); 150 const std::string& characteristic_instance_id);
132 void OnWriteValue(int thread_id,
133 int request_id,
134 int frame_routing_id,
135 const std::string& characteristic_instance_id,
136 const std::vector<uint8_t>& value);
137 void OnStartNotifications(int thread_id, 151 void OnStartNotifications(int thread_id,
138 int request_id, 152 int request_id,
139 int frame_routing_id, 153 int frame_routing_id,
140 const std::string& characteristic_instance_id); 154 const std::string& characteristic_instance_id);
141 void OnStopNotifications(int thread_id, 155 void OnStopNotifications(int thread_id,
142 int request_id, 156 int request_id,
143 int frame_routing_id, 157 int frame_routing_id,
144 const std::string& characteristic_instance_id); 158 const std::string& characteristic_instance_id);
145 void OnRegisterCharacteristicObject( 159 void OnRegisterCharacteristicObject(
146 int thread_id, 160 int thread_id,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 217
204 // Callbacks for BluetoothGattCharacteristic::ReadRemoteCharacteristic. 218 // Callbacks for BluetoothGattCharacteristic::ReadRemoteCharacteristic.
205 void OnCharacteristicValueRead(int thread_id, 219 void OnCharacteristicValueRead(int thread_id,
206 int request_id, 220 int request_id,
207 const std::vector<uint8_t>& value); 221 const std::vector<uint8_t>& value);
208 void OnCharacteristicReadValueError( 222 void OnCharacteristicReadValueError(
209 int thread_id, 223 int thread_id,
210 int request_id, 224 int request_id,
211 device::BluetoothGattService::GattErrorCode); 225 device::BluetoothGattService::GattErrorCode);
212 226
213 // Callbacks for BluetoothGattCharacteristic::WriteRemoteCharacteristic.
214 void OnWriteValueSuccess(int thread_id, int request_id);
215 void OnWriteValueFailed(int thread_id,
216 int request_id,
217 device::BluetoothGattService::GattErrorCode);
218
219 // Callbacks for BluetoothGattCharacteristic::StartNotifySession. 227 // Callbacks for BluetoothGattCharacteristic::StartNotifySession.
220 void OnStartNotifySessionSuccess( 228 void OnStartNotifySessionSuccess(
221 int thread_id, 229 int thread_id,
222 int request_id, 230 int request_id,
223 scoped_ptr<device::BluetoothGattNotifySession> notify_session); 231 scoped_ptr<device::BluetoothGattNotifySession> notify_session);
224 void OnStartNotifySessionFailed( 232 void OnStartNotifySessionFailed(
225 int thread_id, 233 int thread_id,
226 int request_id, 234 int request_id,
227 device::BluetoothGattService::GattErrorCode error_code); 235 device::BluetoothGattService::GattErrorCode error_code);
228 236
(...skipping 11 matching lines...) Expand all
240 // send a response. 248 // send a response.
241 249
242 // Queries the platform cache for a Device with |device_id| for |origin|. 250 // Queries the platform cache for a Device with |device_id| for |origin|.
243 // Fills in the |outcome| field and the |device| field if successful. 251 // Fills in the |outcome| field and the |device| field if successful.
244 CacheQueryResult QueryCacheForDevice(const url::Origin& origin, 252 CacheQueryResult QueryCacheForDevice(const url::Origin& origin,
245 const std::string& device_id); 253 const std::string& device_id);
246 // Queries the platform cache for a Service with |service_instance_id|. Fills 254 // Queries the platform cache for a Service with |service_instance_id|. Fills
247 // in the |outcome| field, and |device| and |service| fields if successful. 255 // in the |outcome| field, and |device| and |service| fields if successful.
248 CacheQueryResult QueryCacheForService(const url::Origin& origin, 256 CacheQueryResult QueryCacheForService(const url::Origin& origin,
249 const std::string& service_instance_id); 257 const std::string& service_instance_id);
250 // Queries the platform cache for a characteristic with
251 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|,
252 // |service| and |characteristic| fields if successful.
253 CacheQueryResult QueryCacheForCharacteristic(
254 const url::Origin& origin,
255 const std::string& characteristic_instance_id);
256 258
257 // Adds the PrimaryServicesRequest to the vector of pending services requests 259 // Adds the PrimaryServicesRequest to the vector of pending services requests
258 // for that device. 260 // for that device.
259 void AddToPendingPrimaryServicesRequest( 261 void AddToPendingPrimaryServicesRequest(
260 const std::string& device_address, 262 const std::string& device_address,
261 const PrimaryServicesRequest& request); 263 const PrimaryServicesRequest& request);
262 264
263 // Returns the origin for the frame with "frame_routing_id" in 265 // Returns the origin for the frame with "frame_routing_id" in
264 // render_process_id_. 266 // render_process_id_.
265 url::Origin GetOrigin(int frame_routing_id); 267 url::Origin GetOrigin(int frame_routing_id);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // copies verify they are also used on the UI thread. 326 // copies verify they are also used on the UI thread.
325 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; 327 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_;
326 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; 328 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_;
327 329
328 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); 330 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost);
329 }; 331 };
330 332
331 } // namespace content 333 } // namespace content
332 334
333 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ 335 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698