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

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

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix threading ownership related to ApiResourceManager<BluetoothApiSocket> and BluetoothSocketEventD… Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "net/base/net_log.h"
14 15
15 namespace device { 16 namespace device {
16 17
17 class BluetoothProfile; 18 class BluetoothProfile;
18 class BluetoothServiceRecord; 19 class BluetoothServiceRecord;
19 class BluetoothSocket; 20 class BluetoothSocket;
20 21
21 struct BluetoothOutOfBandPairingData; 22 struct BluetoothOutOfBandPairingData;
22 23
23 // BluetoothDevice represents a remote Bluetooth device, both its properties and 24 // BluetoothDevice represents a remote Bluetooth device, both its properties and
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // were called after the corresponding call to Connect(). 234 // were called after the corresponding call to Connect().
234 virtual bool IsConnecting() const = 0; 235 virtual bool IsConnecting() const = 0;
235 236
236 // Returns the services (as UUID strings) that this device provides. 237 // Returns the services (as UUID strings) that this device provides.
237 // TODO(youngki): Rename this to GetProfiles(). 238 // TODO(youngki): Rename this to GetProfiles().
238 typedef std::vector<std::string> ServiceList; 239 typedef std::vector<std::string> ServiceList;
239 virtual ServiceList GetServices() const = 0; 240 virtual ServiceList GetServices() const = 0;
240 241
241 // The ErrorCallback is used for methods that can fail in which case it 242 // The ErrorCallback is used for methods that can fail in which case it
242 // is called, in the success case the callback is simply not called. 243 // is called, in the success case the callback is simply not called.
243 typedef base::Callback<void()> ErrorCallback; 244 typedef base::Callback<void(const std::string&)> ErrorCallback;
244 245
245 // The ConnectErrorCallback is used for methods that can fail with an error, 246 // The ConnectErrorCallback is used for methods that can fail with an error,
246 // passed back as an error code argument to this callback. 247 // passed back as an error code argument to this callback.
247 // In the success case this callback is not called. 248 // In the success case this callback is not called.
248 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback; 249 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback;
249 250
250 // Returns the services (as BluetoothServiceRecord objects) that this device 251 // Returns the services (as BluetoothServiceRecord objects) that this device
251 // provides. 252 // provides.
252 typedef ScopedVector<BluetoothServiceRecord> ServiceRecordList; 253 typedef ScopedVector<BluetoothServiceRecord> ServiceRecordList;
253 typedef base::Callback<void(const ServiceRecordList&)> ServiceRecordsCallback; 254 typedef base::Callback<void(const ServiceRecordList&)> ServiceRecordsCallback;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // all references to the BluetoothSocket are released. Note that the 350 // all references to the BluetoothSocket are released. Note that the
350 // BluetoothSocket object can outlive both this BluetoothDevice and the 351 // BluetoothSocket object can outlive both this BluetoothDevice and the
351 // BluetoothAdapter for this device. 352 // BluetoothAdapter for this device.
352 virtual void ConnectToService(const std::string& service_uuid, 353 virtual void ConnectToService(const std::string& service_uuid,
353 const SocketCallback& callback) = 0; 354 const SocketCallback& callback) = 0;
354 355
355 // Attempts to initiate an outgoing connection to this device for the profile 356 // Attempts to initiate an outgoing connection to this device for the profile
356 // identified by |profile|, on success the profile's connection callback 357 // identified by |profile|, on success the profile's connection callback
357 // will be called as well as |callback|; on failure |error_callback| will be 358 // will be called as well as |callback|; on failure |error_callback| will be
358 // called. 359 // called.
359 virtual void ConnectToProfile(BluetoothProfile* profile, 360 virtual void ConnectToProfile(
360 const base::Closure& callback, 361 BluetoothProfile* profile,
361 const ErrorCallback& error_callback) = 0; 362 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
363 scoped_refptr<base::SequencedTaskRunner> file_task_runner,
364 net::NetLog* net_log,
365 const net::NetLog::Source& source,
keybuk 2014/03/14 21:13:48 What's the justification for these added parameter
rpaquay 2014/03/14 21:48:09 That is a good point, the task runners definitely
rpaquay 2014/03/20 00:48:18 Done.
366 const base::Closure& callback,
367 const ErrorCallback& error_callback) = 0;
362 368
363 // Sets the Out Of Band pairing data for this device to |data|. Exactly one 369 // Sets the Out Of Band pairing data for this device to |data|. Exactly one
364 // of |callback| or |error_callback| will be run. 370 // of |callback| or |error_callback| will be run.
365 virtual void SetOutOfBandPairingData( 371 virtual void SetOutOfBandPairingData(
366 const BluetoothOutOfBandPairingData& data, 372 const BluetoothOutOfBandPairingData& data,
367 const base::Closure& callback, 373 const base::Closure& callback,
368 const ErrorCallback& error_callback) = 0; 374 const ErrorCallback& error_callback) = 0;
369 375
370 // Clears the Out Of Band pairing data for this device. Exactly one of 376 // Clears the Out Of Band pairing data for this device. Exactly one of
371 // |callback| or |error_callback| will be run. 377 // |callback| or |error_callback| will be run.
372 virtual void ClearOutOfBandPairingData( 378 virtual void ClearOutOfBandPairingData(
373 const base::Closure& callback, 379 const base::Closure& callback,
374 const ErrorCallback& error_callback) = 0; 380 const ErrorCallback& error_callback) = 0;
375 381
376 protected: 382 protected:
377 BluetoothDevice(); 383 BluetoothDevice();
378 384
379 // Returns the internal name of the Bluetooth device, used by GetName(). 385 // Returns the internal name of the Bluetooth device, used by GetName().
380 virtual std::string GetDeviceName() const = 0; 386 virtual std::string GetDeviceName() const = 0;
381 387
382 private: 388 private:
383 // Returns a localized string containing the device's bluetooth address and 389 // Returns a localized string containing the device's bluetooth address and
384 // a device type for display when |name_| is empty. 390 // a device type for display when |name_| is empty.
385 base::string16 GetAddressWithLocalizedDeviceTypeName() const; 391 base::string16 GetAddressWithLocalizedDeviceTypeName() const;
386 }; 392 };
387 393
388 } // namespace device 394 } // namespace device
389 395
390 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 396 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698