Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_adapter_experimental_chromeos.h
blob80dce8407bf21ca97d9fbb4111157feecb330236
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_
8 #include <string>
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 "chromeos/dbus/experimental_bluetooth_input_client.h"
14 #include "dbus/object_path.h"
15 #include "device/bluetooth/bluetooth_adapter.h"
17 namespace device {
19 class BluetoothAdapterFactory;
21 } // namespace device
23 namespace chromeos {
25 class BluetoothDeviceExperimentalChromeOS;
26 class BluetoothExperimentalChromeOSTest;
28 // The BluetoothAdapterExperimentalChromeOS class is an alternate implementation
29 // of BluetoothAdapter for the Chrome OS platform using the Bluetooth Smart
30 // capable backend. It will become the sole implementation for Chrome OS, and
31 // be renamed to BluetoothAdapterChromeOS, once the backend is switched,
32 class BluetoothAdapterExperimentalChromeOS
33 : public device::BluetoothAdapter,
34 private chromeos::ExperimentalBluetoothAdapterClient::Observer,
35 private chromeos::ExperimentalBluetoothDeviceClient::Observer,
36 private chromeos::ExperimentalBluetoothInputClient::Observer {
37 public:
38 // BluetoothAdapter override
39 virtual void AddObserver(
40 device::BluetoothAdapter::Observer* observer) OVERRIDE;
41 virtual void RemoveObserver(
42 device::BluetoothAdapter::Observer* observer) OVERRIDE;
43 virtual std::string GetAddress() const OVERRIDE;
44 virtual std::string GetName() const OVERRIDE;
45 virtual bool IsInitialized() const OVERRIDE;
46 virtual bool IsPresent() const OVERRIDE;
47 virtual bool IsPowered() const OVERRIDE;
48 virtual void SetPowered(
49 bool powered,
50 const base::Closure& callback,
51 const ErrorCallback& error_callback) OVERRIDE;
52 virtual bool IsDiscovering() const OVERRIDE;
53 virtual void StartDiscovering(
54 const base::Closure& callback,
55 const ErrorCallback& error_callback) OVERRIDE;
56 virtual void StopDiscovering(
57 const base::Closure& callback,
58 const ErrorCallback& error_callback) OVERRIDE;
59 virtual void ReadLocalOutOfBandPairingData(
60 const device::BluetoothAdapter::BluetoothOutOfBandPairingDataCallback&
61 callback,
62 const ErrorCallback& error_callback) OVERRIDE;
64 private:
65 friend class device::BluetoothAdapterFactory;
66 friend class BluetoothDeviceExperimentalChromeOS;
67 friend class BluetoothExperimentalChromeOSTest;
68 friend class BluetoothProfileExperimentalChromeOS;
69 friend class BluetoothProfileChromeOSTest;
71 BluetoothAdapterExperimentalChromeOS();
72 virtual ~BluetoothAdapterExperimentalChromeOS();
74 // ExperimentalBluetoothAdapterClient::Observer override.
75 virtual void AdapterAdded(const dbus::ObjectPath& object_path) OVERRIDE;
76 virtual void AdapterRemoved(const dbus::ObjectPath& object_path) OVERRIDE;
77 virtual void AdapterPropertyChanged(
78 const dbus::ObjectPath& object_path,
79 const std::string& property_name) OVERRIDE;
81 // ExperimentalBluetoothDeviceClient::Observer override.
82 virtual void DeviceAdded(const dbus::ObjectPath& object_path) OVERRIDE;
83 virtual void DeviceRemoved(const dbus::ObjectPath& object_path) OVERRIDE;
84 virtual void DevicePropertyChanged(const dbus::ObjectPath& object_path,
85 const std::string& property_name) OVERRIDE;
87 // ExperimentalBluetoothInputClient::Observer override.
88 virtual void InputPropertyChanged(const dbus::ObjectPath& object_path,
89 const std::string& property_name) OVERRIDE;
91 // Internal method used to locate the device object by object path
92 // (the devices map and BluetoothDevice methods are by address)
93 BluetoothDeviceExperimentalChromeOS* GetDeviceWithPath(
94 const dbus::ObjectPath& object_path);
96 // Set the tracked adapter to the one in |object_path|, this object will
97 // subsequently operate on that adapter until it is removed.
98 void SetAdapter(const dbus::ObjectPath& object_path);
100 // Set the adapter name to one chosen from the system information, and method
101 // called by dbus:: on completion of the alias property change.
102 void SetAdapterName();
103 void OnSetAlias(bool success);
105 // Remove the currently tracked adapter. IsPresent() will return false after
106 // this is called.
107 void RemoveAdapter();
109 // Announce to observers a change in the adapter state.
110 void PoweredChanged(bool powered);
111 void DiscoveringChanged(bool discovering);
112 void PresentChanged(bool present);
114 // Announce to observers a change in device state that is not reflected by
115 // its D-Bus properties.
116 void NotifyDeviceChanged(BluetoothDeviceExperimentalChromeOS* device);
118 // Called by dbus:: on completion of the powered property change.
119 void OnSetPowered(const base::Closure& callback,
120 const ErrorCallback& error_callback,
121 bool success);
123 // Called by dbus:: on completion of the D-Bus method call to start discovery.
124 void OnStartDiscovery(const base::Closure& callback);
125 void OnStartDiscoveryError(const ErrorCallback& error_callback,
126 const std::string& error_name,
127 const std::string& error_message);
129 // Called by dbus:: on completion of the D-Bus method call to stop discovery.
130 void OnStopDiscovery(const base::Closure& callback);
131 void OnStopDiscoveryError(const ErrorCallback& error_callback,
132 const std::string& error_name,
133 const std::string& error_message);
135 // Object path of the adapter we track.
136 dbus::ObjectPath object_path_;
138 // List of observers interested in event notifications from us.
139 ObserverList<device::BluetoothAdapter::Observer> observers_;
141 // Note: This should remain the last member so it'll be destroyed and
142 // invalidate its weak pointers before any other members are destroyed.
143 base::WeakPtrFactory<BluetoothAdapterExperimentalChromeOS> weak_ptr_factory_;
145 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterExperimentalChromeOS);
148 } // namespace chromeos
150 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_EXPERIMENTAL_CHROMEOS_H_