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

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

Issue 13872017: Bluetooth: gather usage metrics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase since Cellular.* appeared under us 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_DEVICE_EXPERIMENTAL_CHROMEOS_H 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_EXPERIMENTAL_CHROMEOS_H
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_EXPERIMENTAL_CHROMEOS_H 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_EXPERIMENTAL_CHROMEOS_H
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h" 12 #include "chromeos/dbus/experimental_bluetooth_agent_service_provider.h"
13 #include "chromeos/dbus/experimental_bluetooth_device_client.h" 13 #include "chromeos/dbus/experimental_bluetooth_device_client.h"
14 #include "dbus/object_path.h" 14 #include "dbus/object_path.h"
15 #include "device/bluetooth/bluetooth_device.h" 15 #include "device/bluetooth/bluetooth_device.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 18
19 class BluetoothAdapterExperimentalChromeOS; 19 class BluetoothAdapterExperimentalChromeOS;
20 20
21 // The BluetoothDeviceExperimentalChromeOS class is an alternate implementation 21 // The BluetoothDeviceExperimentalChromeOS class is an alternate implementation
22 // of BluetoothDevice for the Chrome OS platform using the Bluetooth Smart 22 // of BluetoothDevice for the Chrome OS platform using the Bluetooth Smart
23 // capable backend. It will become the sole implementation for Chrome OS, and 23 // capable backend. It will become the sole implementation for Chrome OS, and
24 // be renamed to BluetoothDeviceChromeOS, once the backend is switched. 24 // be renamed to BluetoothDeviceChromeOS, once the backend is switched.
25 class BluetoothDeviceExperimentalChromeOS 25 class BluetoothDeviceExperimentalChromeOS
26 : public device::BluetoothDevice, 26 : public device::BluetoothDevice,
27 private chromeos::ExperimentalBluetoothAgentServiceProvider::Delegate { 27 private chromeos::ExperimentalBluetoothAgentServiceProvider::Delegate {
28 public: 28 public:
29 // BluetoothDevice override 29 // BluetoothDevice override
30 virtual uint32 GetBluetoothClass() const OVERRIDE;
30 virtual std::string GetAddress() const OVERRIDE; 31 virtual std::string GetAddress() const OVERRIDE;
32 virtual uint16 GetVendorID() const OVERRIDE;
33 virtual uint16 GetProductID() const OVERRIDE;
34 virtual uint16 GetDeviceID() const OVERRIDE;
31 virtual bool IsPaired() const OVERRIDE; 35 virtual bool IsPaired() const OVERRIDE;
32 virtual bool IsConnected() const OVERRIDE; 36 virtual bool IsConnected() const OVERRIDE;
33 virtual bool IsConnectable() const OVERRIDE; 37 virtual bool IsConnectable() const OVERRIDE;
34 virtual bool IsConnecting() const OVERRIDE; 38 virtual bool IsConnecting() const OVERRIDE;
35 virtual ServiceList GetServices() const OVERRIDE; 39 virtual ServiceList GetServices() const OVERRIDE;
36 virtual void GetServiceRecords( 40 virtual void GetServiceRecords(
37 const ServiceRecordsCallback& callback, 41 const ServiceRecordsCallback& callback,
38 const ErrorCallback& error_callback) OVERRIDE; 42 const ErrorCallback& error_callback) OVERRIDE;
39 virtual void ProvidesServiceWithName( 43 virtual void ProvidesServiceWithName(
40 const std::string& name, 44 const std::string& name,
(...skipping 24 matching lines...) Expand all
65 virtual void SetOutOfBandPairingData( 69 virtual void SetOutOfBandPairingData(
66 const device::BluetoothOutOfBandPairingData& data, 70 const device::BluetoothOutOfBandPairingData& data,
67 const base::Closure& callback, 71 const base::Closure& callback,
68 const ErrorCallback& error_callback) OVERRIDE; 72 const ErrorCallback& error_callback) OVERRIDE;
69 virtual void ClearOutOfBandPairingData( 73 virtual void ClearOutOfBandPairingData(
70 const base::Closure& callback, 74 const base::Closure& callback,
71 const ErrorCallback& error_callback) OVERRIDE; 75 const ErrorCallback& error_callback) OVERRIDE;
72 76
73 protected: 77 protected:
74 // BluetoothDevice override 78 // BluetoothDevice override
75 virtual uint32 GetBluetoothClass() const OVERRIDE;
76 virtual std::string GetDeviceName() const OVERRIDE; 79 virtual std::string GetDeviceName() const OVERRIDE;
77 80
78 private: 81 private:
79 friend class BluetoothAdapterExperimentalChromeOS; 82 friend class BluetoothAdapterExperimentalChromeOS;
80 83
81 BluetoothDeviceExperimentalChromeOS( 84 BluetoothDeviceExperimentalChromeOS(
82 BluetoothAdapterExperimentalChromeOS* adapter, 85 BluetoothAdapterExperimentalChromeOS* adapter,
83 const dbus::ObjectPath& object_path); 86 const dbus::ObjectPath& object_path);
84 virtual ~BluetoothDeviceExperimentalChromeOS(); 87 virtual ~BluetoothDeviceExperimentalChromeOS();
85 88
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // there is no matching completion call since this object is deleted in the 163 // there is no matching completion call since this object is deleted in the
161 // process of unpairing. 164 // process of unpairing.
162 void OnForgetError(const ErrorCallback& error_callback, 165 void OnForgetError(const ErrorCallback& error_callback,
163 const std::string& error_name, 166 const std::string& error_name,
164 const std::string& error_message); 167 const std::string& error_message);
165 168
166 // Run any outstanding pairing callbacks passing |status| as the result of 169 // Run any outstanding pairing callbacks passing |status| as the result of
167 // pairing. Returns true if any callbacks were run, false if not. 170 // pairing. Returns true if any callbacks were run, false if not.
168 bool RunPairingCallbacks(Status status); 171 bool RunPairingCallbacks(Status status);
169 172
173 // Record the result of pairing as a UMA histogram metric; |success| should
174 // be true if pairing succeeded, and |false| if not - in which case
175 // |error_code| specifies the reason for failure.
176 void RecordPairingResult(bool success, ConnectErrorCode error_code);
177
170 // Return the object path of the device; used by 178 // Return the object path of the device; used by
171 // BluetoothAdapterExperimentalChromeOS 179 // BluetoothAdapterExperimentalChromeOS
172 const dbus::ObjectPath& object_path() const { return object_path_; } 180 const dbus::ObjectPath& object_path() const { return object_path_; }
173 181
174 // The adapter that owns this device instance. 182 // The adapter that owns this device instance.
175 BluetoothAdapterExperimentalChromeOS* adapter_; 183 BluetoothAdapterExperimentalChromeOS* adapter_;
176 184
177 // The dbus object path of the device object. 185 // The dbus object path of the device object.
178 dbus::ObjectPath object_path_; 186 dbus::ObjectPath object_path_;
179 187
180 // Number of ongoing calls to Connect(). 188 // Number of ongoing calls to Connect().
181 int num_connecting_calls_; 189 int num_connecting_calls_;
182 190
183 // During pairing this is set to an object that we don't own, but on which 191 // During pairing this is set to an object that we don't own, but on which
184 // we can make method calls to request, display or confirm PIN Codes and 192 // we can make method calls to request, display or confirm PIN Codes and
185 // Passkeys. Generally it is the object that owns this one. 193 // Passkeys. Generally it is the object that owns this one.
186 PairingDelegate* pairing_delegate_; 194 PairingDelegate* pairing_delegate_;
187 195
196 // Flag to indicate whether a pairing delegate method has been called during
197 // pairing.
198 bool pairing_delegate_used_;
199
188 // During pairing this is set to an instance of a D-Bus agent object 200 // During pairing this is set to an instance of a D-Bus agent object
189 // intialized with our own class as its delegate. 201 // intialized with our own class as its delegate.
190 scoped_ptr<ExperimentalBluetoothAgentServiceProvider> agent_; 202 scoped_ptr<ExperimentalBluetoothAgentServiceProvider> agent_;
191 203
192 // During pairing these callbacks are set to those provided by method calls 204 // During pairing these callbacks are set to those provided by method calls
193 // made on us by |agent_| and are called by our own method calls such as 205 // made on us by |agent_| and are called by our own method calls such as
194 // SetPinCode() and SetPasskey(). 206 // SetPinCode() and SetPasskey().
195 PinCodeCallback pincode_callback_; 207 PinCodeCallback pincode_callback_;
196 PasskeyCallback passkey_callback_; 208 PasskeyCallback passkey_callback_;
197 ConfirmationCallback confirmation_callback_; 209 ConfirmationCallback confirmation_callback_;
198 210
199 // Note: This should remain the last member so it'll be destroyed and 211 // Note: This should remain the last member so it'll be destroyed and
200 // invalidate its weak pointers before any other members are destroyed. 212 // invalidate its weak pointers before any other members are destroyed.
201 base::WeakPtrFactory<BluetoothDeviceExperimentalChromeOS> weak_ptr_factory_; 213 base::WeakPtrFactory<BluetoothDeviceExperimentalChromeOS> weak_ptr_factory_;
202 214
203 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceExperimentalChromeOS); 215 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceExperimentalChromeOS);
204 }; 216 };
205 217
206 } // namespace chromeos 218 } // namespace chromeos
207 219
208 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_EXPERIMENTAL_CHROMEOS_H 220 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_EXPERIMENTAL_CHROMEOS_H
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.cc ('k') | device/bluetooth/bluetooth_device_experimental_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698