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

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

Issue 13927010: Bluetooth: implement BlueZ 5 backend for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_EXPERIMENTAL_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
12 #include "chromeos/dbus/experimental_bluetooth_device_client.h"
13 #include "dbus/object_path.h"
11 #include "device/bluetooth/bluetooth_adapter.h" 14 #include "device/bluetooth/bluetooth_adapter.h"
12 15
13 namespace device { 16 namespace device {
14 17
15 class BluetoothAdapterFactory; 18 class BluetoothAdapterFactory;
16 19
17 } // namespace device 20 } // namespace device
18 21
19 namespace chromeos { 22 namespace chromeos {
20 23
24 class BluetoothDeviceExperimentalChromeOS;
25
21 // The BluetoothAdapterExperimentalChromeOS class is an alternate implementation 26 // The BluetoothAdapterExperimentalChromeOS class is an alternate implementation
22 // of BluetoothAdapter for the Chrome OS platform using the Bluetooth Smart 27 // of BluetoothAdapter for the Chrome OS platform using the Bluetooth Smart
23 // capable backend. It will become the sole implementation for Chrome OS, and 28 // capable backend. It will become the sole implementation for Chrome OS, and
24 // be renamed to BluetoothAdapterChromeOS, once the backend is switched, 29 // be renamed to BluetoothAdapterChromeOS, once the backend is switched,
25 class BluetoothAdapterExperimentalChromeOS 30 class BluetoothAdapterExperimentalChromeOS
26 : public device::BluetoothAdapter { 31 : public device::BluetoothAdapter,
32 private chromeos::ExperimentalBluetoothAdapterClient::Observer,
33 private chromeos::ExperimentalBluetoothDeviceClient::Observer {
27 public: 34 public:
28 // BluetoothAdapter override 35 // BluetoothAdapter override
29 virtual void AddObserver( 36 virtual void AddObserver(
30 device::BluetoothAdapter::Observer* observer) OVERRIDE; 37 device::BluetoothAdapter::Observer* observer) OVERRIDE;
31 virtual void RemoveObserver( 38 virtual void RemoveObserver(
32 device::BluetoothAdapter::Observer* observer) OVERRIDE; 39 device::BluetoothAdapter::Observer* observer) OVERRIDE;
33 virtual std::string GetAddress() const OVERRIDE; 40 virtual std::string GetAddress() const OVERRIDE;
34 virtual std::string GetName() const OVERRIDE; 41 virtual std::string GetName() const OVERRIDE;
35 virtual bool IsInitialized() const OVERRIDE; 42 virtual bool IsInitialized() const OVERRIDE;
36 virtual bool IsPresent() const OVERRIDE; 43 virtual bool IsPresent() const OVERRIDE;
37 virtual bool IsPowered() const OVERRIDE; 44 virtual bool IsPowered() const OVERRIDE;
38 virtual void SetPowered( 45 virtual void SetPowered(
39 bool powered, 46 bool powered,
40 const base::Closure& callback, 47 const base::Closure& callback,
41 const ErrorCallback& error_callback) OVERRIDE; 48 const ErrorCallback& error_callback) OVERRIDE;
42 virtual bool IsDiscovering() const OVERRIDE; 49 virtual bool IsDiscovering() const OVERRIDE;
43 virtual void StartDiscovering( 50 virtual void StartDiscovering(
44 const base::Closure& callback, 51 const base::Closure& callback,
45 const ErrorCallback& error_callback) OVERRIDE; 52 const ErrorCallback& error_callback) OVERRIDE;
46 virtual void StopDiscovering( 53 virtual void StopDiscovering(
47 const base::Closure& callback, 54 const base::Closure& callback,
48 const ErrorCallback& error_callback) OVERRIDE; 55 const ErrorCallback& error_callback) OVERRIDE;
49 virtual void ReadLocalOutOfBandPairingData( 56 virtual void ReadLocalOutOfBandPairingData(
50 const device::BluetoothAdapter::BluetoothOutOfBandPairingDataCallback& 57 const device::BluetoothAdapter::BluetoothOutOfBandPairingDataCallback&
51 callback, 58 callback,
52 const ErrorCallback& error_callback) OVERRIDE; 59 const ErrorCallback& error_callback) OVERRIDE;
53 60
54 private: 61 private:
55 friend class device::BluetoothAdapterFactory; 62 friend class device::BluetoothAdapterFactory;
63 friend class BluetoothDeviceExperimentalChromeOS;
56 64
57 BluetoothAdapterExperimentalChromeOS(); 65 BluetoothAdapterExperimentalChromeOS();
58 virtual ~BluetoothAdapterExperimentalChromeOS(); 66 virtual ~BluetoothAdapterExperimentalChromeOS();
59 67
68 // ExperimentalBluetoothAdapterClient::Observer override.
69 virtual void AdapterAdded(const dbus::ObjectPath& object_path) OVERRIDE;
70 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) OVERRIDE;
71 virtual void AdapterPropertyChanged(
72 const dbus::ObjectPath& object_path,
73 const std::string& property_name) OVERRIDE;
74
75 // ExperimentalBluetoothDeviceClient::Observer override.
76 virtual void DeviceAdded(const dbus::ObjectPath& object_path) OVERRIDE;
77 virtual void DeviceRemoved(const dbus::ObjectPath& object_path) OVERRIDE;
78 virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path,
79 const std::string& property_name) OVERRIDE;
80
81 BluetoothDeviceExperimentalChromeOS* GetDeviceWithPath(
82 const dbus::ObjectPath& object_path);
83
84 void SetAdapter(const dbus::ObjectPath& object_path);
85 void RemoveAdapter();
86
87 void PoweredChanged(bool powered);
88 void DiscoveringChanged(bool discovering);
89 void PresentChanged(bool present);
90
91 void OnSetPowered(const base::Closure& callback,
92 const ErrorCallback& error_callback,
93 bool success);
94
95 void OnStartDiscovery(const base::Closure& callback);
96 void OnStartDiscoveryError(const ErrorCallback& error_callback,
97 const std::string& error_name,
98 const std::string& error_message);
99
100 void OnStopDiscovery(const base::Closure& callback);
101 void OnStopDiscoveryError(const ErrorCallback& error_callback,
102 const std::string& error_name,
103 const std::string& error_message);
104
105 dbus::ObjectPath object_path_;
106
107 // List of observers interested in event notifications from us.
108 ObserverList<device::BluetoothAdapter::Observer> observers_;
109
60 // Note: This should remain the last member so it'll be destroyed and 110 // Note: This should remain the last member so it'll be destroyed and
61 // invalidate its weak pointers before any other members are destroyed. 111 // invalidate its weak pointers before any other members are destroyed.
62 base::WeakPtrFactory<BluetoothAdapterExperimentalChromeOS> weak_ptr_factory_; 112 base::WeakPtrFactory<BluetoothAdapterExperimentalChromeOS> weak_ptr_factory_;
63 113
64 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterExperimentalChromeOS); 114 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterExperimentalChromeOS);
65 }; 115 };
66 116
67 } // namespace chromeos 117 } // namespace chromeos
68 118
69 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_ 119 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698