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

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: Address scheib's comments Created 4 years, 8 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
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_dispatcher_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(ortuno): We temporarily make this a public struct so that
59 // both BluetoothDispatcherHost and WebBluetoothServiceImpl can use it,
60 // while we move functions from BluetoothDispatcherHost to
61 // WebBluetoothServiceImpl.
62 // https://crbug.com/508771
63 struct CacheQueryResult {
64 CacheQueryResult();
65 CacheQueryResult(CacheQueryOutcome outcome);
66 ~CacheQueryResult();
67 blink::WebBluetoothError GetWebError() const;
68 device::BluetoothDevice* device = nullptr;
69 device::BluetoothGattService* service = nullptr;
70 device::BluetoothGattCharacteristic* characteristic = nullptr;
71 CacheQueryOutcome outcome = CacheQueryOutcome::SUCCESS;
72 };
73
74 // Queries the platform cache for a characteristic with
75 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|,
76 // |service| and |characteristic| fields if successful.
77 CacheQueryResult QueryCacheForCharacteristic(
78 const url::Origin& origin,
79 const std::string& characteristic_instance_id);
80
56 protected: 81 protected:
57 ~BluetoothDispatcherHost() override; 82 ~BluetoothDispatcherHost() override;
58 83
59 private: 84 private:
60 friend class base::DeleteHelper<BluetoothDispatcherHost>; 85 friend class base::DeleteHelper<BluetoothDispatcherHost>;
61 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 86 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
62 87
63 struct CacheQueryResult;
64 struct RequestDeviceSession; 88 struct RequestDeviceSession;
65 struct PrimaryServicesRequest; 89 struct PrimaryServicesRequest;
66 90
67 // Set |adapter_| to a BluetoothAdapter instance and register observers, 91 // Set |adapter_| to a BluetoothAdapter instance and register observers,
68 // releasing references to previous |adapter_|. 92 // releasing references to previous |adapter_|.
69 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); 93 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter);
70 94
71 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets 95 // Makes sure a BluetoothDiscoverySession is active for |session|, and resets
72 // its timeout. 96 // its timeout.
73 void StartDeviceDiscovery(RequestDeviceSession* session, int chooser_id); 97 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); 146 const std::string& characteristic_uuid);
123 void OnGetCharacteristics(int thread_id, 147 void OnGetCharacteristics(int thread_id,
124 int request_id, 148 int request_id,
125 int frame_routing_id, 149 int frame_routing_id,
126 const std::string& service_instance_id, 150 const std::string& service_instance_id,
127 const std::string& characteristics_uuid); 151 const std::string& characteristics_uuid);
128 void OnReadValue(int thread_id, 152 void OnReadValue(int thread_id,
129 int request_id, 153 int request_id,
130 int frame_routing_id, 154 int frame_routing_id,
131 const std::string& characteristic_instance_id); 155 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, 156 void OnStartNotifications(int thread_id,
138 int request_id, 157 int request_id,
139 int frame_routing_id, 158 int frame_routing_id,
140 const std::string& characteristic_instance_id); 159 const std::string& characteristic_instance_id);
141 void OnStopNotifications(int thread_id, 160 void OnStopNotifications(int thread_id,
142 int request_id, 161 int request_id,
143 int frame_routing_id, 162 int frame_routing_id,
144 const std::string& characteristic_instance_id); 163 const std::string& characteristic_instance_id);
145 void OnRegisterCharacteristicObject( 164 void OnRegisterCharacteristicObject(
146 int thread_id, 165 int thread_id,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 223
205 // Callbacks for BluetoothGattCharacteristic::ReadRemoteCharacteristic. 224 // Callbacks for BluetoothGattCharacteristic::ReadRemoteCharacteristic.
206 void OnCharacteristicValueRead(int thread_id, 225 void OnCharacteristicValueRead(int thread_id,
207 int request_id, 226 int request_id,
208 const std::vector<uint8_t>& value); 227 const std::vector<uint8_t>& value);
209 void OnCharacteristicReadValueError( 228 void OnCharacteristicReadValueError(
210 int thread_id, 229 int thread_id,
211 int request_id, 230 int request_id,
212 device::BluetoothGattService::GattErrorCode); 231 device::BluetoothGattService::GattErrorCode);
213 232
214 // Callbacks for BluetoothGattCharacteristic::WriteRemoteCharacteristic.
215 void OnWriteValueSuccess(int thread_id, int request_id);
216 void OnWriteValueFailed(int thread_id,
217 int request_id,
218 device::BluetoothGattService::GattErrorCode);
219
220 // Callbacks for BluetoothGattCharacteristic::StartNotifySession. 233 // Callbacks for BluetoothGattCharacteristic::StartNotifySession.
221 void OnStartNotifySessionSuccess( 234 void OnStartNotifySessionSuccess(
222 int thread_id, 235 int thread_id,
223 int request_id, 236 int request_id,
224 scoped_ptr<device::BluetoothGattNotifySession> notify_session); 237 scoped_ptr<device::BluetoothGattNotifySession> notify_session);
225 void OnStartNotifySessionFailed( 238 void OnStartNotifySessionFailed(
226 int thread_id, 239 int thread_id,
227 int request_id, 240 int request_id,
228 device::BluetoothGattService::GattErrorCode error_code); 241 device::BluetoothGattService::GattErrorCode error_code);
229 242
(...skipping 11 matching lines...) Expand all
241 // send a response. 254 // send a response.
242 255
243 // Queries the platform cache for a Device with |device_id| for |origin|. 256 // Queries the platform cache for a Device with |device_id| for |origin|.
244 // Fills in the |outcome| field and the |device| field if successful. 257 // Fills in the |outcome| field and the |device| field if successful.
245 CacheQueryResult QueryCacheForDevice(const url::Origin& origin, 258 CacheQueryResult QueryCacheForDevice(const url::Origin& origin,
246 const std::string& device_id); 259 const std::string& device_id);
247 // Queries the platform cache for a Service with |service_instance_id|. Fills 260 // Queries the platform cache for a Service with |service_instance_id|. Fills
248 // in the |outcome| field, and |device| and |service| fields if successful. 261 // in the |outcome| field, and |device| and |service| fields if successful.
249 CacheQueryResult QueryCacheForService(const url::Origin& origin, 262 CacheQueryResult QueryCacheForService(const url::Origin& origin,
250 const std::string& service_instance_id); 263 const std::string& service_instance_id);
251 // Queries the platform cache for a characteristic with
252 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|,
253 // |service| and |characteristic| fields if successful.
254 CacheQueryResult QueryCacheForCharacteristic(
255 const url::Origin& origin,
256 const std::string& characteristic_instance_id);
257 264
258 // Adds the PrimaryServicesRequest to the vector of pending services requests 265 // Adds the PrimaryServicesRequest to the vector of pending services requests
259 // for that device. 266 // for that device.
260 void AddToPendingPrimaryServicesRequest( 267 void AddToPendingPrimaryServicesRequest(
261 const std::string& device_address, 268 const std::string& device_address,
262 const PrimaryServicesRequest& request); 269 const PrimaryServicesRequest& request);
263 270
264 // Returns the origin for the frame with "frame_routing_id" in 271 // Returns the origin for the frame with "frame_routing_id" in
265 // render_process_id_. 272 // render_process_id_.
266 url::Origin GetOrigin(int frame_routing_id); 273 url::Origin GetOrigin(int frame_routing_id);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 // copies verify they are also used on the UI thread. 332 // copies verify they are also used on the UI thread.
326 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; 333 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_;
327 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; 334 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_;
328 335
329 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); 336 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost);
330 }; 337 };
331 338
332 } // namespace content 339 } // namespace content
333 340
334 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ 341 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/bluetooth/bluetooth_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698