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_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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "content/public/browser/bluetooth_chooser.h" | 11 #include "content/public/browser/bluetooth_chooser.h" |
12 #include "content/public/browser/browser_message_filter.h" | 12 #include "content/public/browser/browser_message_filter.h" |
13 #include "device/bluetooth/bluetooth_adapter.h" | 13 #include "device/bluetooth/bluetooth_adapter.h" |
14 #include "device/bluetooth/bluetooth_gatt_connection.h" | 14 #include "device/bluetooth/bluetooth_gatt_connection.h" |
15 #include "device/bluetooth/bluetooth_gatt_service.h" | 15 #include "device/bluetooth/bluetooth_gatt_service.h" |
16 | 16 |
17 namespace device { | 17 namespace device { |
18 class BluetoothUUID; | 18 class BluetoothUUID; |
19 } | 19 } |
20 | 20 |
| 21 namespace blink { |
| 22 enum class WebBluetoothError; |
| 23 } |
| 24 |
21 namespace content { | 25 namespace content { |
22 | 26 |
23 struct BluetoothScanFilter; | 27 struct BluetoothScanFilter; |
24 | 28 |
25 // Dispatches and sends bluetooth related messages sent to/from a child | 29 // Dispatches and sends bluetooth related messages sent to/from a child |
26 // process BluetoothDispatcher from/to the main browser process. | 30 // process BluetoothDispatcher from/to the main browser process. |
27 // | 31 // |
28 // Intended to be instantiated by the RenderProcessHost and installed as | 32 // Intended to be instantiated by the RenderProcessHost and installed as |
29 // a filter on the channel. BrowserMessageFilter is refcounted and typically | 33 // a filter on the channel. BrowserMessageFilter is refcounted and typically |
30 // lives as long as it is installed on a channel. | 34 // lives as long as it is installed on a channel. |
(...skipping 17 matching lines...) Expand all Loading... |
48 | 52 |
49 protected: | 53 protected: |
50 ~BluetoothDispatcherHost() override; | 54 ~BluetoothDispatcherHost() override; |
51 | 55 |
52 private: | 56 private: |
53 friend class base::DeleteHelper<BluetoothDispatcherHost>; | 57 friend class base::DeleteHelper<BluetoothDispatcherHost>; |
54 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 58 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
55 | 59 |
56 struct RequestDeviceSession; | 60 struct RequestDeviceSession; |
57 | 61 |
| 62 enum class CacheQueryOutcome { |
| 63 SUCCESS = 0, |
| 64 BAD_RENDERER = 1, |
| 65 NO_DEVICE = 2, |
| 66 NO_SERVICE = 3, |
| 67 NO_CHARACTERISTIC = 4 |
| 68 }; |
| 69 |
| 70 blink::WebBluetoothError CacheQueryOutcomeToWebBluetoothError( |
| 71 CacheQueryOutcome outcome); |
| 72 std::pair<CacheQueryOutcome, device::BluetoothDevice*> QueryForDevice( |
| 73 const std::string& device_instance_id); |
| 74 std::pair<CacheQueryOutcome, device::BluetoothGattService*> QueryForService( |
| 75 const std::string& service_instance_id); |
| 76 std::pair<CacheQueryOutcome, device::BluetoothGattCharacteristic*> |
| 77 QueryForCharacteristic(const std::string& characteristic_instance_id); |
| 78 |
58 // Set |adapter_| to a BluetoothAdapter instance and register observers, | 79 // Set |adapter_| to a BluetoothAdapter instance and register observers, |
59 // releasing references to previous |adapter_|. | 80 // releasing references to previous |adapter_|. |
60 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); | 81 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
61 | 82 |
62 // Stops all BluetoothDiscoverySessions being run for requestDevice() | 83 // Stops all BluetoothDiscoverySessions being run for requestDevice() |
63 // choosers. | 84 // choosers. |
64 void StopDeviceDiscovery(); | 85 void StopDeviceDiscovery(); |
65 | 86 |
66 // BluetoothAdapter::Observer: | 87 // BluetoothAdapter::Observer: |
67 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, | 88 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 206 |
186 // Must be last member, see base/memory/weak_ptr.h documentation | 207 // Must be last member, see base/memory/weak_ptr.h documentation |
187 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 208 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
188 | 209 |
189 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 210 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
190 }; | 211 }; |
191 | 212 |
192 } // namespace content | 213 } // namespace content |
193 | 214 |
194 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 215 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
OLD | NEW |