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

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

Issue 13862023: Add abstract BluetoothProfile class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add constructor and destructor for Options 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
« no previous file with comments | « device/bluetooth/bluetooth_device_win.cc ('k') | device/bluetooth/bluetooth_profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12
13 namespace device {
14
15 class BluetoothSocket;
16
17 // BluetoothProfile represents an implementation of either a client or server
18 // of a particular specified profile (aka service or protocol in other
19 // standards).
20 //
21 // Profile implementations are created by registering them through the static
22 // BluetoothProfile::Register() method and are always identified by a UUID
23 // which in any method may be specified in the short or long form.
24 //
25 // The lifecycle of BluetoothProfile instances is managed by the implementation
26 // but they are guaranteed to exist once provided to a Register() callback until
27 // the instance's Unregister() method is called, so others may hold on to
28 // pointers to them.
29 class BluetoothProfile {
30 public:
31 // Options used to register a BluetoothProfile object.
32 struct Options {
33 Options();
34 ~Options();
35
36 // Human readable name of the Profile, e.g. "Health Device".
37 // Exported in the adapter's SDP or GATT tables where relevant.
38 std::string name;
39
40 // RFCOMM channel used by the profile.
41 // Exported in the adapter's SDP or GATT tables where relevant.
42 uint16 channel;
43
44 // L2CAP PSM number.
45 // Exported in the adapter's SDP or GATT tables where relevant.
46 uint16 psm;
47
48 // Specifies whether pairing (and encryption) is required to be able to
49 // connect. Defaults to false.
50 bool require_authentication;
51
52 // Specifies whether user authorization is required to be able to connect.
53 // Defaults to false.
54 bool require_authorization;
55
56 // Implemented version of the profile.
57 // Exported in the adapter's SDP or GATT tables where relevant.
58 uint16 version;
59
60 // Implemented feature set of the profile.
61 // Exported in the adapter's SDP or GATT tables where relevant.
62 uint16 features;
63 };
64
65 // Register an implementation of the profile with UUID |uuid| and
66 // additional details specified in |options|. The corresponding profile
67 // object will be created and returned by |callback|. If the profile cannot
68 // be registered, NULL will be passed.
69 //
70 // This pointer is not owned by the receiver, but will not be freed unless
71 // its Unregister() method is called.
72 typedef base::Callback<void(BluetoothProfile*)> ProfileCallback;
73 static void Register(const std::string& uuid,
74 const Options& options,
75 const ProfileCallback& callback);
76
77 // Unregister the profile. This deletes the profile object so, once called,
78 // any pointers to the profile should be discarded.
79 virtual void Unregister() = 0;
80
81 // Set the connection callback for the profile to |callback|, any successful
82 // connection initiated by BluetoothDevice::ConnectToProfile() or incoming
83 // connections from devices, will have a BluetoothSocket created and passed
84 // to this callback.
85 //
86 // The socket will be closed when all references are released; none of the
87 // BluetoothProfile, or BluetoothAdapter or BluetoothDevice objects are
88 // guaranteed to hold a reference so this may outlive all of them.
89 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> SocketCallback;
90 virtual void SetConnectionCallback(const SocketCallback& callback) = 0;
91
92 private:
93 BluetoothProfile();
94 virtual ~BluetoothProfile();
95 };
96
97 } // namespace device
98
99 #endif /* DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_ */
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_win.cc ('k') | device/bluetooth/bluetooth_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698