| 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/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "content/common/bluetooth/bluetooth_error.h" | 10 #include "content/common/bluetooth/bluetooth_error.h" |
| 11 #include "content/public/browser/browser_message_filter.h" | 11 #include "content/public/browser/browser_message_filter.h" |
| 12 #include "device/bluetooth/bluetooth_adapter.h" | 12 #include "device/bluetooth/bluetooth_adapter.h" |
| 13 #include "device/bluetooth/bluetooth_gatt_connection.h" | 13 #include "device/bluetooth/bluetooth_gatt_connection.h" |
| 14 | 14 |
| 15 namespace device { |
| 16 class BluetoothUUID; |
| 17 } |
| 18 |
| 15 namespace content { | 19 namespace content { |
| 16 | 20 |
| 21 class BluetoothScanFilter; |
| 22 |
| 17 // Dispatches and sends bluetooth related messages sent to/from a child | 23 // Dispatches and sends bluetooth related messages sent to/from a child |
| 18 // process BluetoothDispatcher from/to the main browser process. | 24 // process BluetoothDispatcher from/to the main browser process. |
| 19 // | 25 // |
| 20 // Intended to be instantiated by the RenderProcessHost and installed as | 26 // Intended to be instantiated by the RenderProcessHost and installed as |
| 21 // a filter on the channel. BrowserMessageFilter is refcounted and typically | 27 // a filter on the channel. BrowserMessageFilter is refcounted and typically |
| 22 // lives as long as it is installed on a channel. | 28 // lives as long as it is installed on a channel. |
| 23 // | 29 // |
| 24 // UI Thread Note: | 30 // UI Thread Note: |
| 25 // BluetoothDispatcherHost is constructed, operates, and destroyed on the UI | 31 // BluetoothDispatcherHost is constructed, operates, and destroyed on the UI |
| 26 // thread because BluetoothAdapter and related objects live there. | 32 // thread because BluetoothAdapter and related objects live there. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 void SetBluetoothAdapterForTesting( | 44 void SetBluetoothAdapterForTesting( |
| 39 scoped_refptr<device::BluetoothAdapter> mock_adapter); | 45 scoped_refptr<device::BluetoothAdapter> mock_adapter); |
| 40 | 46 |
| 41 protected: | 47 protected: |
| 42 ~BluetoothDispatcherHost() override; | 48 ~BluetoothDispatcherHost() override; |
| 43 | 49 |
| 44 private: | 50 private: |
| 45 friend class base::DeleteHelper<BluetoothDispatcherHost>; | 51 friend class base::DeleteHelper<BluetoothDispatcherHost>; |
| 46 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 52 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 47 | 53 |
| 54 struct DiscoverySessionOptions; |
| 55 |
| 48 // Set |adapter_| to a BluetoothAdapter instance and register observers, | 56 // Set |adapter_| to a BluetoothAdapter instance and register observers, |
| 49 // releasing references to previous |adapter_|. | 57 // releasing references to previous |adapter_|. |
| 50 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); | 58 void set_adapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 51 | 59 |
| 52 // IPC Handlers, see definitions in bluetooth_messages.h. | 60 // IPC Handlers, see definitions in bluetooth_messages.h. |
| 53 void OnRequestDevice(int thread_id, int request_id); | 61 void OnRequestDevice( |
| 62 int thread_id, |
| 63 int request_id, |
| 64 const std::vector<content::BluetoothScanFilter>& filters, |
| 65 const std::vector<device::BluetoothUUID>& optional_services); |
| 54 void OnConnectGATT(int thread_id, int request_id, | 66 void OnConnectGATT(int thread_id, int request_id, |
| 55 const std::string& device_instance_id); | 67 const std::string& device_instance_id); |
| 56 void OnGetPrimaryService(int thread_id, | 68 void OnGetPrimaryService(int thread_id, |
| 57 int request_id, | 69 int request_id, |
| 58 const std::string& device_instance_id, | 70 const std::string& device_instance_id, |
| 59 const std::string& service_uuid); | 71 const std::string& service_uuid); |
| 60 | 72 |
| 61 // Callbacks for BluetoothAdapter::StartDiscoverySession. | 73 // Callbacks for BluetoothAdapter::StartDiscoverySession. |
| 62 void OnDiscoverySessionStarted( | 74 void OnDiscoverySessionStarted( |
| 63 int thread_id, | 75 int thread_id, |
| 64 int request_id, | 76 int request_id, |
| 77 scoped_ptr<DiscoverySessionOptions> options, |
| 65 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | 78 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 66 void OnDiscoverySessionStartedError(int thread_id, int request_id); | 79 void OnDiscoverySessionStartedError(int thread_id, int request_id); |
| 67 | 80 |
| 68 // Stop in progress discovery session. | 81 // Stop in progress discovery session. |
| 69 void StopDiscoverySession( | 82 void StopDiscoverySession( |
| 70 int thread_id, | 83 int thread_id, |
| 71 int request_id, | 84 int request_id, |
| 85 scoped_ptr<DiscoverySessionOptions> options, |
| 72 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | 86 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); |
| 73 | 87 |
| 74 // Callbacks for BluetoothDiscoverySession::Stop. | 88 // Callbacks for BluetoothDiscoverySession::Stop. |
| 75 void OnDiscoverySessionStopped(int thread_id, int request_id); | 89 void OnDiscoverySessionStopped(int thread_id, |
| 90 int request_id, |
| 91 scoped_ptr<DiscoverySessionOptions> options); |
| 76 void OnDiscoverySessionStoppedError(int thread_id, int request_id); | 92 void OnDiscoverySessionStoppedError(int thread_id, int request_id); |
| 77 | 93 |
| 78 // Callbacks for BluetoothDevice::CreateGattConnection | 94 // Callbacks for BluetoothDevice::CreateGattConnection |
| 79 void OnGATTConnectionCreated( | 95 void OnGATTConnectionCreated( |
| 80 int thread_id, | 96 int thread_id, |
| 81 int request_id, | 97 int request_id, |
| 82 const std::string& device_instance_id, | 98 const std::string& device_instance_id, |
| 83 scoped_ptr<device::BluetoothGattConnection> connection); | 99 scoped_ptr<device::BluetoothGattConnection> connection); |
| 84 void OnCreateGATTConnectionError( | 100 void OnCreateGATTConnectionError( |
| 85 int thread_id, | 101 int thread_id, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 103 | 119 |
| 104 // Must be last member, see base/memory/weak_ptr.h documentation | 120 // Must be last member, see base/memory/weak_ptr.h documentation |
| 105 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 121 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
| 106 | 122 |
| 107 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 123 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 108 }; | 124 }; |
| 109 | 125 |
| 110 } // namespace content | 126 } // namespace content |
| 111 | 127 |
| 112 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 128 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |