OLD | NEW |
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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const base::Closure& callback, | 69 const base::Closure& callback, |
70 const ErrorCallback& error_callback) OVERRIDE; | 70 const ErrorCallback& error_callback) OVERRIDE; |
71 | 71 |
72 protected: | 72 protected: |
73 // BluetoothDevice override | 73 // BluetoothDevice override |
74 virtual uint32 GetBluetoothClass() const OVERRIDE; | 74 virtual uint32 GetBluetoothClass() const OVERRIDE; |
75 virtual std::string GetDeviceName() const OVERRIDE; | 75 virtual std::string GetDeviceName() const OVERRIDE; |
76 | 76 |
77 private: | 77 private: |
78 friend class BluetoothAdapterExperimentalChromeOS; | 78 friend class BluetoothAdapterExperimentalChromeOS; |
| 79 friend class MetricsLog; |
79 | 80 |
80 BluetoothDeviceExperimentalChromeOS( | 81 BluetoothDeviceExperimentalChromeOS( |
81 BluetoothAdapterExperimentalChromeOS* adapter, | 82 BluetoothAdapterExperimentalChromeOS* adapter, |
82 const dbus::ObjectPath& object_path); | 83 const dbus::ObjectPath& object_path); |
83 virtual ~BluetoothDeviceExperimentalChromeOS(); | 84 virtual ~BluetoothDeviceExperimentalChromeOS(); |
84 | 85 |
85 // ExperimentalBluetoothAgentServiceProvider::Delegate override. | 86 // ExperimentalBluetoothAgentServiceProvider::Delegate override. |
86 virtual void Release() OVERRIDE; | 87 virtual void Release() OVERRIDE; |
87 virtual void RequestPinCode(const dbus::ObjectPath& device_path, | 88 virtual void RequestPinCode(const dbus::ObjectPath& device_path, |
88 const PinCodeCallback& callback) OVERRIDE; | 89 const PinCodeCallback& callback) OVERRIDE; |
89 virtual void DisplayPinCode(const dbus::ObjectPath& device_path, | 90 virtual void DisplayPinCode(const dbus::ObjectPath& device_path, |
90 const std::string& pincode) OVERRIDE; | 91 const std::string& pincode) OVERRIDE; |
91 virtual void RequestPasskey(const dbus::ObjectPath& device_path, | 92 virtual void RequestPasskey(const dbus::ObjectPath& device_path, |
92 const PasskeyCallback& callback) OVERRIDE; | 93 const PasskeyCallback& callback) OVERRIDE; |
93 virtual void DisplayPasskey(const dbus::ObjectPath& device_path, | 94 virtual void DisplayPasskey(const dbus::ObjectPath& device_path, |
94 uint32 passkey, int16 entered) OVERRIDE; | 95 uint32 passkey, int16 entered) OVERRIDE; |
95 virtual void RequestConfirmation(const dbus::ObjectPath& device_path, | 96 virtual void RequestConfirmation(const dbus::ObjectPath& device_path, |
96 uint32 passkey, | 97 uint32 passkey, |
97 const ConfirmationCallback& callback) | 98 const ConfirmationCallback& callback) |
98 OVERRIDE; | 99 OVERRIDE; |
99 virtual void RequestAuthorization(const dbus::ObjectPath& device_path, | 100 virtual void RequestAuthorization(const dbus::ObjectPath& device_path, |
100 const ConfirmationCallback& callback) | 101 const ConfirmationCallback& callback) |
101 OVERRIDE; | 102 OVERRIDE; |
102 virtual void AuthorizeService(const dbus::ObjectPath& device_path, | 103 virtual void AuthorizeService(const dbus::ObjectPath& device_path, |
103 const std::string& uuid, | 104 const std::string& uuid, |
104 const ConfirmationCallback& callback) OVERRIDE; | 105 const ConfirmationCallback& callback) OVERRIDE; |
105 virtual void Cancel() OVERRIDE; | 106 virtual void Cancel() OVERRIDE; |
106 | 107 |
| 108 // Used by MetricsLog to obtain the device information. |
| 109 std::string GetModalias() const; |
| 110 |
107 // Internal method to initiate a connection to this device, and methods called | 111 // Internal method to initiate a connection to this device, and methods called |
108 // by dbus:: on completion of the D-Bus method call. | 112 // by dbus:: on completion of the D-Bus method call. |
109 void ConnectInternal(const base::Closure& callback, | 113 void ConnectInternal(const base::Closure& callback, |
110 const ConnectErrorCallback& error_callback); | 114 const ConnectErrorCallback& error_callback); |
111 void OnConnect(const base::Closure& callback); | 115 void OnConnect(const base::Closure& callback); |
112 void OnConnectError(const ConnectErrorCallback& error_callback, | 116 void OnConnectError(const ConnectErrorCallback& error_callback, |
113 const std::string& error_name, | 117 const std::string& error_name, |
114 const std::string& error_message); | 118 const std::string& error_message); |
115 | 119 |
116 // Called by dbus:: on completion of the D-Bus method call to register the | 120 // Called by dbus:: on completion of the D-Bus method call to register the |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 // 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 |
160 // process of unpairing. | 164 // process of unpairing. |
161 void OnForgetError(const ErrorCallback& error_callback, | 165 void OnForgetError(const ErrorCallback& error_callback, |
162 const std::string& error_name, | 166 const std::string& error_name, |
163 const std::string& error_message); | 167 const std::string& error_message); |
164 | 168 |
165 // Run any outstanding pairing callbacks passing |status| as the result of | 169 // Run any outstanding pairing callbacks passing |status| as the result of |
166 // pairing. Returns true if any callbacks were run, false if not. | 170 // pairing. Returns true if any callbacks were run, false if not. |
167 bool RunPairingCallbacks(Status status); | 171 bool RunPairingCallbacks(Status status); |
168 | 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 |
169 // Return the object path of the device; used by | 178 // Return the object path of the device; used by |
170 // BluetoothAdapterExperimentalChromeOS | 179 // BluetoothAdapterExperimentalChromeOS |
171 const dbus::ObjectPath& object_path() const { return object_path_; } | 180 const dbus::ObjectPath& object_path() const { return object_path_; } |
172 | 181 |
173 // The adapter that owns this device instance. | 182 // The adapter that owns this device instance. |
174 BluetoothAdapterExperimentalChromeOS* adapter_; | 183 BluetoothAdapterExperimentalChromeOS* adapter_; |
175 | 184 |
176 // The dbus object path of the device object. | 185 // The dbus object path of the device object. |
177 dbus::ObjectPath object_path_; | 186 dbus::ObjectPath object_path_; |
178 | 187 |
179 // Number of ongoing calls to Connect(). | 188 // Number of ongoing calls to Connect(). |
180 int num_connecting_calls_; | 189 int num_connecting_calls_; |
181 | 190 |
182 // 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 |
183 // 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 |
184 // Passkeys. Generally it is the object that owns this one. | 193 // Passkeys. Generally it is the object that owns this one. |
185 PairingDelegate* pairing_delegate_; | 194 PairingDelegate* pairing_delegate_; |
186 | 195 |
| 196 // Flag to indicate whether a pairing delegate method has been called during |
| 197 // pairing. |
| 198 bool pairing_delegate_used_; |
| 199 |
187 // 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 |
188 // intialized with our own class as its delegate. | 201 // intialized with our own class as its delegate. |
189 scoped_ptr<ExperimentalBluetoothAgentServiceProvider> agent_; | 202 scoped_ptr<ExperimentalBluetoothAgentServiceProvider> agent_; |
190 | 203 |
191 // 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 |
192 // 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 |
193 // SetPinCode() and SetPasskey(). | 206 // SetPinCode() and SetPasskey(). |
194 PinCodeCallback pincode_callback_; | 207 PinCodeCallback pincode_callback_; |
195 PasskeyCallback passkey_callback_; | 208 PasskeyCallback passkey_callback_; |
196 ConfirmationCallback confirmation_callback_; | 209 ConfirmationCallback confirmation_callback_; |
197 | 210 |
198 // 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 |
199 // invalidate its weak pointers before any other members are destroyed. | 212 // invalidate its weak pointers before any other members are destroyed. |
200 base::WeakPtrFactory<BluetoothDeviceExperimentalChromeOS> weak_ptr_factory_; | 213 base::WeakPtrFactory<BluetoothDeviceExperimentalChromeOS> weak_ptr_factory_; |
201 | 214 |
202 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceExperimentalChromeOS); | 215 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceExperimentalChromeOS); |
203 }; | 216 }; |
204 | 217 |
205 } // namespace chromeos | 218 } // namespace chromeos |
206 | 219 |
207 #endif /* DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_EXPERIMENTAL_CHROMEOS_H */ | 220 #endif /* DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_EXPERIMENTAL_CHROMEOS_H */ |
OLD | NEW |