OLD | NEW |
---|---|
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_DEVICE_CHROMEOS_H | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/sequenced_task_runner.h" | |
13 #include "chromeos/dbus/bluetooth_device_client.h" | 15 #include "chromeos/dbus/bluetooth_device_client.h" |
14 #include "chromeos/dbus/bluetooth_gatt_service_client.h" | 16 #include "chromeos/dbus/bluetooth_gatt_service_client.h" |
15 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
16 #include "device/bluetooth/bluetooth_device.h" | 18 #include "device/bluetooth/bluetooth_device.h" |
17 | 19 |
20 namespace device { | |
21 class BluetoothSocketThread; | |
22 } // namespace device | |
23 | |
18 namespace chromeos { | 24 namespace chromeos { |
19 | 25 |
20 class BluetoothAdapterChromeOS; | 26 class BluetoothAdapterChromeOS; |
21 class BluetoothPairingChromeOS; | 27 class BluetoothPairingChromeOS; |
22 | 28 |
23 // The BluetoothDeviceChromeOS class implements BluetoothDevice for the | 29 // The BluetoothDeviceChromeOS class implements BluetoothDevice for the |
24 // Chrome OS platform. | 30 // Chrome OS platform. |
25 class BluetoothDeviceChromeOS | 31 class BluetoothDeviceChromeOS |
26 : public device::BluetoothDevice, | 32 : public device::BluetoothDevice, |
27 public BluetoothGattServiceClient::Observer { | 33 public BluetoothGattServiceClient::Observer { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 // Returns the current pairing object or NULL if no pairing is in progress. | 89 // Returns the current pairing object or NULL if no pairing is in progress. |
84 BluetoothPairingChromeOS* GetPairing() const; | 90 BluetoothPairingChromeOS* GetPairing() const; |
85 | 91 |
86 protected: | 92 protected: |
87 // BluetoothDevice override | 93 // BluetoothDevice override |
88 virtual std::string GetDeviceName() const OVERRIDE; | 94 virtual std::string GetDeviceName() const OVERRIDE; |
89 | 95 |
90 private: | 96 private: |
91 friend class BluetoothAdapterChromeOS; | 97 friend class BluetoothAdapterChromeOS; |
92 | 98 |
93 BluetoothDeviceChromeOS(BluetoothAdapterChromeOS* adapter, | 99 BluetoothDeviceChromeOS( |
94 const dbus::ObjectPath& object_path); | 100 BluetoothAdapterChromeOS* adapter, |
101 const dbus::ObjectPath& object_path, | |
102 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_, | |
armansito
2014/05/01 00:14:25
Shouldn't have underscores at the end of function
keybuk
2014/05/01 00:24:09
Done.
| |
103 scoped_refptr<device::BluetoothSocketThread> socket_thread_); | |
95 virtual ~BluetoothDeviceChromeOS(); | 104 virtual ~BluetoothDeviceChromeOS(); |
96 | 105 |
97 // BluetoothGattServiceClient::Observer overrides. | 106 // BluetoothGattServiceClient::Observer overrides. |
98 virtual void GattServiceAdded(const dbus::ObjectPath& object_path) OVERRIDE; | 107 virtual void GattServiceAdded(const dbus::ObjectPath& object_path) OVERRIDE; |
99 virtual void GattServiceRemoved(const dbus::ObjectPath& object_path) OVERRIDE; | 108 virtual void GattServiceRemoved(const dbus::ObjectPath& object_path) OVERRIDE; |
100 | 109 |
101 // Internal method to initiate a connection to this device, and methods called | 110 // Internal method to initiate a connection to this device, and methods called |
102 // by dbus:: on completion of the D-Bus method call. | 111 // by dbus:: on completion of the D-Bus method call. |
103 void ConnectInternal(bool after_pairing, | 112 void ConnectInternal(bool after_pairing, |
104 const base::Closure& callback, | 113 const base::Closure& callback, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 | 171 |
163 // The dbus object path of the device object. | 172 // The dbus object path of the device object. |
164 dbus::ObjectPath object_path_; | 173 dbus::ObjectPath object_path_; |
165 | 174 |
166 // List of observers interested in event notifications from us. | 175 // List of observers interested in event notifications from us. |
167 ObserverList<device::BluetoothDevice::Observer> observers_; | 176 ObserverList<device::BluetoothDevice::Observer> observers_; |
168 | 177 |
169 // Number of ongoing calls to Connect(). | 178 // Number of ongoing calls to Connect(). |
170 int num_connecting_calls_; | 179 int num_connecting_calls_; |
171 | 180 |
181 // UI thread task runner and socket thread object used to create sockets. | |
182 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | |
183 scoped_refptr<device::BluetoothSocketThread> socket_thread_; | |
184 | |
172 // During pairing this is set to an object that we don't own, but on which | 185 // During pairing this is set to an object that we don't own, but on which |
173 // we can make method calls to request, display or confirm PIN Codes and | 186 // we can make method calls to request, display or confirm PIN Codes and |
174 // Passkeys. Generally it is the object that owns this one. | 187 // Passkeys. Generally it is the object that owns this one. |
175 scoped_ptr<BluetoothPairingChromeOS> pairing_; | 188 scoped_ptr<BluetoothPairingChromeOS> pairing_; |
176 | 189 |
177 // Note: This should remain the last member so it'll be destroyed and | 190 // Note: This should remain the last member so it'll be destroyed and |
178 // invalidate its weak pointers before any other members are destroyed. | 191 // invalidate its weak pointers before any other members are destroyed. |
179 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; | 192 base::WeakPtrFactory<BluetoothDeviceChromeOS> weak_ptr_factory_; |
180 | 193 |
181 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); | 194 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceChromeOS); |
182 }; | 195 }; |
183 | 196 |
184 } // namespace chromeos | 197 } // namespace chromeos |
185 | 198 |
186 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H | 199 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_CHROMEOS_H |
OLD | NEW |