Make DesktopResizer use ScreenResolution to facilitate DPI-awareness.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_profile.h
blob4ff2480c21d336171cca3335d9819f7375e840e1
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.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
13 namespace device {
15 class BluetoothDevice;
16 class BluetoothProfileMac;
17 class BluetoothSocket;
18 class MockBluetoothProfile;
20 // BluetoothProfile represents an implementation of either a client or server
21 // of a particular specified profile (aka service or protocol in other
22 // standards).
24 // Profile implementations are created by registering them through the static
25 // BluetoothProfile::Register() method and are always identified by a UUID
26 // which in any method may be specified in the short or long form.
28 // The lifecycle of BluetoothProfile instances is managed by the implementation
29 // but they are guaranteed to exist once provided to a Register() callback until
30 // the instance's Unregister() method is called, so others may hold on to
31 // pointers to them.
32 class BluetoothProfile {
33 public:
34 // Options used to register a BluetoothProfile object.
35 struct Options {
36 Options();
37 ~Options();
39 // Human readable name of the Profile, e.g. "Health Device".
40 // Exported in the adapter's SDP or GATT tables where relevant.
41 std::string name;
43 // RFCOMM channel used by the profile.
44 // Exported in the adapter's SDP or GATT tables where relevant.
45 uint16 channel;
47 // L2CAP PSM number.
48 // Exported in the adapter's SDP or GATT tables where relevant.
49 uint16 psm;
51 // Specifies whether pairing (and encryption) is required to be able to
52 // connect. Defaults to false.
53 bool require_authentication;
55 // Specifies whether user authorization is required to be able to connect.
56 // Defaults to false.
57 bool require_authorization;
59 // Specifies whether this profile will be automatically connected if any
60 // other profile of a device conects to the host.
61 // Defaults to false.
62 bool auto_connect;
64 // Implemented version of the profile.
65 // Exported in the adapter's SDP or GATT tables where relevant.
66 uint16 version;
68 // Implemented feature set of the profile.
69 // Exported in the adapter's SDP or GATT tables where relevant.
70 uint16 features;
73 // Register an implementation of the profile with UUID |uuid| and
74 // additional details specified in |options|. The corresponding profile
75 // object will be created and returned by |callback|. If the profile cannot
76 // be registered, NULL will be passed.
78 // This pointer is not owned by the receiver, but will not be freed unless
79 // its Unregister() method is called.
80 typedef base::Callback<void(BluetoothProfile*)> ProfileCallback;
81 static void Register(const std::string& uuid,
82 const Options& options,
83 const ProfileCallback& callback);
85 // Unregister the profile. This deletes the profile object so, once called,
86 // any pointers to the profile should be discarded.
87 virtual void Unregister() = 0;
89 // Set the connection callback for the profile to |callback|, any successful
90 // connection initiated by BluetoothDevice::ConnectToProfile() or incoming
91 // connections from devices, will have a BluetoothSocket created and passed
92 // to this callback.
94 // The socket will be closed when all references are released; none of the
95 // BluetoothProfile, or BluetoothAdapter or BluetoothDevice objects are
96 // guaranteed to hold a reference so this may outlive all of them.
97 typedef base::Callback<void(
98 const BluetoothDevice*,
99 scoped_refptr<BluetoothSocket>)> ConnectionCallback;
100 virtual void SetConnectionCallback(const ConnectionCallback& callback) = 0;
102 protected:
103 BluetoothProfile();
104 virtual ~BluetoothProfile();
107 } // namespace device
109 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_