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

Side by Side Diff: device/bluetooth/bluetooth_adapter_chromeos.h

Issue 1347193004: Refactor DBusThreadManager to split away BT clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter_chromeos.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "chromeos/dbus/bluetooth_adapter_client.h"
16 #include "chromeos/dbus/bluetooth_agent_service_provider.h"
17 #include "chromeos/dbus/bluetooth_device_client.h"
18 #include "chromeos/dbus/bluetooth_input_client.h"
19 #include "chromeos/dbus/bluetooth_profile_manager_client.h"
20 #include "chromeos/dbus/bluetooth_profile_service_provider.h"
21 #include "dbus/object_path.h" 15 #include "dbus/object_path.h"
22 #include "device/bluetooth/bluetooth_adapter.h" 16 #include "device/bluetooth/bluetooth_adapter.h"
23 #include "device/bluetooth/bluetooth_audio_sink.h" 17 #include "device/bluetooth/bluetooth_audio_sink.h"
24 #include "device/bluetooth/bluetooth_device.h" 18 #include "device/bluetooth/bluetooth_device.h"
25 #include "device/bluetooth/bluetooth_discovery_session.h" 19 #include "device/bluetooth/bluetooth_discovery_session.h"
26 #include "device/bluetooth/bluetooth_export.h" 20 #include "device/bluetooth/bluetooth_export.h"
21 #include "device/bluetooth/dbus/bluetooth_adapter_client.h"
22 #include "device/bluetooth/dbus/bluetooth_agent_service_provider.h"
23 #include "device/bluetooth/dbus/bluetooth_device_client.h"
24 #include "device/bluetooth/dbus/bluetooth_input_client.h"
25 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h"
26 #include "device/bluetooth/dbus/bluetooth_profile_service_provider.h"
27 27
28 namespace base { 28 namespace base {
29 class SequencedTaskRunner; 29 class SequencedTaskRunner;
30 } // namespace base 30 } // namespace base
31 31
32 namespace device { 32 namespace device {
33 class BluetoothSocketThread; 33 class BluetoothSocketThread;
34 } // namespace device 34 } // namespace device
35 35
36 namespace chromeos { 36 namespace chromeos {
(...skipping 16 matching lines...) Expand all
53 // single-threaded calls, and posts tasks to the UI thread. 53 // single-threaded calls, and posts tasks to the UI thread.
54 // 54 //
55 // Methods tolerate a shutdown scenario where BluetoothAdapterChromeOS::Shutdown 55 // Methods tolerate a shutdown scenario where BluetoothAdapterChromeOS::Shutdown
56 // causes IsPresent to return false just before the dbus system is shutdown but 56 // causes IsPresent to return false just before the dbus system is shutdown but
57 // while references to the BluetoothAdapterChromeOS object still exists. 57 // while references to the BluetoothAdapterChromeOS object still exists.
58 // 58 //
59 // When adding methods to this class verify shutdown behavior in 59 // When adding methods to this class verify shutdown behavior in
60 // BluetoothChromeOSTest, Shutdown. 60 // BluetoothChromeOSTest, Shutdown.
61 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS 61 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS
62 : public device::BluetoothAdapter, 62 : public device::BluetoothAdapter,
63 public chromeos::BluetoothAdapterClient::Observer, 63 public bluez::BluetoothAdapterClient::Observer,
64 public chromeos::BluetoothDeviceClient::Observer, 64 public bluez::BluetoothDeviceClient::Observer,
65 public chromeos::BluetoothInputClient::Observer, 65 public bluez::BluetoothInputClient::Observer,
66 public chromeos::BluetoothAgentServiceProvider::Delegate { 66 public bluez::BluetoothAgentServiceProvider::Delegate {
67 public: 67 public:
68 typedef base::Callback<void(const std::string& error_message)> 68 typedef base::Callback<void(const std::string& error_message)>
69 ErrorCompletionCallback; 69 ErrorCompletionCallback;
70 typedef base::Callback<void(BluetoothAdapterProfileChromeOS* profile)> 70 typedef base::Callback<void(BluetoothAdapterProfileChromeOS* profile)>
71 ProfileRegisteredCallback; 71 ProfileRegisteredCallback;
72 72
73 static base::WeakPtr<BluetoothAdapter> CreateAdapter(); 73 static base::WeakPtr<BluetoothAdapter> CreateAdapter();
74 74
75 // BluetoothAdapter: 75 // BluetoothAdapter:
76 void Shutdown() override; 76 void Shutdown() override;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 // Request a profile on the adapter for a custom service with a 150 // Request a profile on the adapter for a custom service with a
151 // specific UUID for the device at |device_path| to be sent to |delegate|. 151 // specific UUID for the device at |device_path| to be sent to |delegate|.
152 // If |device_path| is the empty string, incoming connections will be 152 // If |device_path| is the empty string, incoming connections will be
153 // assigned to |delegate|. When the profile is 153 // assigned to |delegate|. When the profile is
154 // successfully registered, |success_callback| will be called with a pointer 154 // successfully registered, |success_callback| will be called with a pointer
155 // to the profile which is managed by BluetoothAdapterChromeOS. On failure, 155 // to the profile which is managed by BluetoothAdapterChromeOS. On failure,
156 // |error_callback| will be called. 156 // |error_callback| will be called.
157 void UseProfile(const device::BluetoothUUID& uuid, 157 void UseProfile(const device::BluetoothUUID& uuid,
158 const dbus::ObjectPath& device_path, 158 const dbus::ObjectPath& device_path,
159 const BluetoothProfileManagerClient::Options& options, 159 const bluez::BluetoothProfileManagerClient::Options& options,
160 BluetoothProfileServiceProvider::Delegate* delegate, 160 bluez::BluetoothProfileServiceProvider::Delegate* delegate,
161 const ProfileRegisteredCallback& success_callback, 161 const ProfileRegisteredCallback& success_callback,
162 const ErrorCompletionCallback& error_callback); 162 const ErrorCompletionCallback& error_callback);
163 163
164 // Release use of a profile by a device. 164 // Release use of a profile by a device.
165 void ReleaseProfile(const dbus::ObjectPath& device_path, 165 void ReleaseProfile(const dbus::ObjectPath& device_path,
166 BluetoothAdapterProfileChromeOS* profile); 166 BluetoothAdapterProfileChromeOS* profile);
167 167
168 protected: 168 protected:
169 // BluetoothAdapter: 169 // BluetoothAdapter:
170 void RemovePairingDelegateInternal( 170 void RemovePairingDelegateInternal(
(...skipping 15 matching lines...) Expand all
186 DiscoverySessionErrorCallback> DiscoveryParamTuple; 186 DiscoverySessionErrorCallback> DiscoveryParamTuple;
187 typedef std::queue<DiscoveryParamTuple> DiscoveryCallbackQueue; 187 typedef std::queue<DiscoveryParamTuple> DiscoveryCallbackQueue;
188 188
189 // Callback pair for the profile registration queue. 189 // Callback pair for the profile registration queue.
190 typedef std::pair<base::Closure, ErrorCompletionCallback> 190 typedef std::pair<base::Closure, ErrorCompletionCallback>
191 RegisterProfileCompletionPair; 191 RegisterProfileCompletionPair;
192 192
193 BluetoothAdapterChromeOS(); 193 BluetoothAdapterChromeOS();
194 ~BluetoothAdapterChromeOS() override; 194 ~BluetoothAdapterChromeOS() override;
195 195
196 // BluetoothAdapterClient::Observer override. 196 // bluez::BluetoothAdapterClient::Observer override.
197 void AdapterAdded(const dbus::ObjectPath& object_path) override; 197 void AdapterAdded(const dbus::ObjectPath& object_path) override;
198 void AdapterRemoved(const dbus::ObjectPath& object_path) override; 198 void AdapterRemoved(const dbus::ObjectPath& object_path) override;
199 void AdapterPropertyChanged(const dbus::ObjectPath& object_path, 199 void AdapterPropertyChanged(const dbus::ObjectPath& object_path,
200 const std::string& property_name) override; 200 const std::string& property_name) override;
201 201
202 // BluetoothDeviceClient::Observer override. 202 // bluez::BluetoothDeviceClient::Observer override.
203 void DeviceAdded(const dbus::ObjectPath& object_path) override; 203 void DeviceAdded(const dbus::ObjectPath& object_path) override;
204 void DeviceRemoved(const dbus::ObjectPath& object_path) override; 204 void DeviceRemoved(const dbus::ObjectPath& object_path) override;
205 void DevicePropertyChanged(const dbus::ObjectPath& object_path, 205 void DevicePropertyChanged(const dbus::ObjectPath& object_path,
206 const std::string& property_name) override; 206 const std::string& property_name) override;
207 207
208 // BluetoothInputClient::Observer override. 208 // bluez::BluetoothInputClient::Observer override.
209 void InputPropertyChanged(const dbus::ObjectPath& object_path, 209 void InputPropertyChanged(const dbus::ObjectPath& object_path,
210 const std::string& property_name) override; 210 const std::string& property_name) override;
211 211
212 // BluetoothAgentServiceProvider::Delegate override. 212 // bluez::BluetoothAgentServiceProvider::Delegate override.
213 void Released() override; 213 void Released() override;
214 void RequestPinCode(const dbus::ObjectPath& device_path, 214 void RequestPinCode(const dbus::ObjectPath& device_path,
215 const PinCodeCallback& callback) override; 215 const PinCodeCallback& callback) override;
216 void DisplayPinCode(const dbus::ObjectPath& device_path, 216 void DisplayPinCode(const dbus::ObjectPath& device_path,
217 const std::string& pincode) override; 217 const std::string& pincode) override;
218 void RequestPasskey(const dbus::ObjectPath& device_path, 218 void RequestPasskey(const dbus::ObjectPath& device_path,
219 const PasskeyCallback& callback) override; 219 const PasskeyCallback& callback) override;
220 void DisplayPasskey(const dbus::ObjectPath& device_path, 220 void DisplayPasskey(const dbus::ObjectPath& device_path,
221 uint32 passkey, 221 uint32 passkey,
222 uint16 entered) override; 222 uint16 entered) override;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 void OnSetDiscoveryFilterError( 325 void OnSetDiscoveryFilterError(
326 const base::Closure& callback, 326 const base::Closure& callback,
327 const DiscoverySessionErrorCallback& error_callback, 327 const DiscoverySessionErrorCallback& error_callback,
328 const std::string& error_name, 328 const std::string& error_name,
329 const std::string& error_message); 329 const std::string& error_message);
330 330
331 // Called by dbus:: on completion of the D-Bus method to register a profile. 331 // Called by dbus:: on completion of the D-Bus method to register a profile.
332 void OnRegisterProfile(const device::BluetoothUUID& uuid, 332 void OnRegisterProfile(const device::BluetoothUUID& uuid,
333 scoped_ptr<BluetoothAdapterProfileChromeOS> profile); 333 scoped_ptr<BluetoothAdapterProfileChromeOS> profile);
334 334
335 void SetProfileDelegate(const device::BluetoothUUID& uuid, 335 void SetProfileDelegate(
336 const dbus::ObjectPath& device_path, 336 const device::BluetoothUUID& uuid,
337 BluetoothProfileServiceProvider::Delegate* delegate, 337 const dbus::ObjectPath& device_path,
338 const ProfileRegisteredCallback& success_callback, 338 bluez::BluetoothProfileServiceProvider::Delegate* delegate,
339 const ErrorCompletionCallback& error_callback); 339 const ProfileRegisteredCallback& success_callback,
340 const ErrorCompletionCallback& error_callback);
340 void OnRegisterProfileError(const device::BluetoothUUID& uuid, 341 void OnRegisterProfileError(const device::BluetoothUUID& uuid,
341 const std::string& error_name, 342 const std::string& error_name,
342 const std::string& error_message); 343 const std::string& error_message);
343 344
344 // Called by BluetoothAdapterProfileChromeOS when no users of a profile 345 // Called by BluetoothAdapterProfileChromeOS when no users of a profile
345 // remain. 346 // remain.
346 void RemoveProfile(const device::BluetoothUUID& uuid); 347 void RemoveProfile(const device::BluetoothUUID& uuid);
347 348
348 // Processes the queued discovery requests. For each DiscoveryParamTuple in 349 // Processes the queued discovery requests. For each DiscoveryParamTuple in
349 // the queue, this method will try to add a new discovery session. This method 350 // the queue, this method will try to add a new discovery session. This method
(...skipping 19 matching lines...) Expand all
369 // requested discovery, dropping our count to 0 won't necessarily result in 370 // requested discovery, dropping our count to 0 won't necessarily result in
370 // the controller actually stopping discovery if, for example, an application 371 // the controller actually stopping discovery if, for example, an application
371 // other than Chrome, such as bt_console, was also used to start discovery. 372 // other than Chrome, such as bt_console, was also used to start discovery.
372 DiscoveryCallbackQueue discovery_request_queue_; 373 DiscoveryCallbackQueue discovery_request_queue_;
373 374
374 // Object path of the adapter we track. 375 // Object path of the adapter we track.
375 dbus::ObjectPath object_path_; 376 dbus::ObjectPath object_path_;
376 377
377 // Instance of the D-Bus agent object used for pairing, initialized with 378 // Instance of the D-Bus agent object used for pairing, initialized with
378 // our own class as its delegate. 379 // our own class as its delegate.
379 scoped_ptr<BluetoothAgentServiceProvider> agent_; 380 scoped_ptr<bluez::BluetoothAgentServiceProvider> agent_;
380 381
381 // UI thread task runner and socket thread object used to create sockets. 382 // UI thread task runner and socket thread object used to create sockets.
382 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 383 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
383 scoped_refptr<device::BluetoothSocketThread> socket_thread_; 384 scoped_refptr<device::BluetoothSocketThread> socket_thread_;
384 385
385 // The profiles we have registered with the bluetooth daemon. 386 // The profiles we have registered with the bluetooth daemon.
386 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_; 387 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_;
387 388
388 // Queue of delegates waiting for a profile to register. 389 // Queue of delegates waiting for a profile to register.
389 std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*> 390 std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*>
390 profile_queues_; 391 profile_queues_;
391 392
392 scoped_ptr<device::BluetoothDiscoveryFilter> current_filter_; 393 scoped_ptr<device::BluetoothDiscoveryFilter> current_filter_;
393 394
394 // Note: This should remain the last member so it'll be destroyed and 395 // Note: This should remain the last member so it'll be destroyed and
395 // invalidate its weak pointers before any other members are destroyed. 396 // invalidate its weak pointers before any other members are destroyed.
396 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; 397 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_;
397 398
398 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); 399 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS);
399 }; 400 };
400 401
401 } // namespace chromeos 402 } // namespace chromeos
402 403
403 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ 404 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698