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

Side by Side Diff: chrome/browser/chromeos/bluetooth/bluetooth_device_interface.h

Issue 10899037: Refactoring bluetooth API code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added #include <string> into bluetooth_adapter_dbus.cc. Created 8 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_INTERFACE_H_
bryeung 2012/09/07 18:35:57 This file can just be "bluetooth_device.h"
youngki 2012/09/13 18:05:02 Done.
6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_INTERFACE_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/string16.h"
12 #include "base/memory/ref_counted.h"
13
14 namespace chromeos {
15
16 class BluetoothServiceRecordDBus;
17 class BluetoothSocketPosix;
18
19 struct BluetoothOutOfBandPairingData;
20
21 // The BluetoothDeviceInterface represents a remote Bluetooth device, both its
22 // properties and capabilities as discovered by a local adapter and actions that
23 // may be performed on the remove device such as pairing, connection and
24 // disconnection.
25 class BluetoothDeviceInterface {
bryeung 2012/09/07 18:35:57 This can just be BluetoothDevice
youngki 2012/09/13 18:05:02 Done.
26 public:
27 virtual ~BluetoothDeviceInterface() {}
28
29 // Returns the Bluetooth of address the device. This should be used as
30 // a unique key to identify the device and copied where needed.
31 virtual const std::string& address() const = 0;
32
33 // Returns the name of the device suitable for displaying, this may
34 // be a synthesied string containing the address and localized type name
35 // if the device has no obtained name.
36 virtual string16 GetName() const = 0;
37
38 // Indicates whether the device is paired to the adapter, whether or not
39 // that pairing is permanent or temporary.
40 virtual bool IsPaired() const = 0;
41
42 // Indicates whether the device is bonded to the adapter, bonding is
43 // formed by pairing and exchanging high-security link keys so that
44 // connections may be encrypted.
45 virtual bool IsBonded() const = 0;
46
47 // Indicates whether the device is currently connected to the adapter
48 // and at least one service available for use.
49 virtual bool IsConnected() const = 0;
50
51 // The ErrorCallback is used for methods that can fail in which case it
52 // is called, in the success case the callback is simply not called.
53 typedef base::Callback<void()> ErrorCallback;
54
55 // Returns the services (as BluetoothServiceRecordDBus objects) that this
56 // device provides.
57 typedef ScopedVector<BluetoothServiceRecordDBus> ServiceRecordList;
58 typedef base::Callback<void(const ServiceRecordList&)> ServiceRecordsCallback;
59 virtual void GetServiceRecords(const ServiceRecordsCallback& callback,
60 const ErrorCallback& error_callback) = 0;
61
62 // Indicates whether this device provides the given service. |uuid| should
63 // be in canonical form (see bluetooth_utils::CanonicalUuid).
64 virtual bool ProvidesServiceWithUUID(const std::string& uuid) const = 0;
65
66 // The ProvidesServiceCallback is used by ProvidesServiceWithName to indicate
67 // whether or not a matching service was found.
68 typedef base::Callback<void(bool)> ProvidesServiceCallback;
69
70 // Indicates whether this device provides the given service.
71 virtual void ProvidesServiceWithName(
72 const std::string& name,
73 const ProvidesServiceCallback& callback) = 0;
74
75 // SocketCallback is used by ConnectToService to return a BluetoothSocketPosix
76 // to the caller, or NULL if there was an error. The socket will remain open
77 // until the last reference to the returned BluetoothSocketPosix is released.
78 typedef base::Callback<void(scoped_refptr<BluetoothSocketPosix>)>
79 SocketCallback;
80
81 // Attempts to open a socket to a service matching |uuid| on this device. If
82 // the connection is successful, |callback| is called with a
83 // BluetoothSocketPosix.
84 // Otherwise |callback| is called with NULL. The socket is closed as soon as
85 // all references to the BluetoothSocketPosix are released. Note that the
86 // BluetoothSocketPosix object can outlive both this BluetoothDeviceDBus and
87 // the BluetoothAdapterDBus for this device.
88 virtual void ConnectToService(const std::string& service_uuid,
89 const SocketCallback& callback) = 0;
90
91 // Sets the Out Of Band pairing data for this device to |data|. Exactly one
92 // of |callback| or |error_callback| will be run.
93 virtual void SetOutOfBandPairingData(
94 const BluetoothOutOfBandPairingData& data,
95 const base::Closure& callback,
96 const ErrorCallback& error_callback) = 0;
97
98 // Clears the Out Of Band pairing data for this device. Exactly one of
99 // |callback| or |error_callback| will be run.
100 virtual void ClearOutOfBandPairingData(
101 const base::Closure& callback,
102 const ErrorCallback& error_callback) = 0;
103 };
104
105 } // namespace chromeos
106
107 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_DEVICE_INTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698