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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_device_win.cc ('k') | device/bluetooth/bluetooth_profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_profile.h
diff --git a/device/bluetooth/bluetooth_profile.h b/device/bluetooth/bluetooth_profile.h
new file mode 100644
index 0000000000000000000000000000000000000000..ecc437c3dc8cdbaa25a943318ce92963e0b2d1bf
--- /dev/null
+++ b/device/bluetooth/bluetooth_profile.h
@@ -0,0 +1,99 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_
+#define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_
+
+#include <string>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+
+namespace device {
+
+class BluetoothSocket;
+
+// BluetoothProfile represents an implementation of either a client or server
+// of a particular specified profile (aka service or protocol in other
+// standards).
+//
+// Profile implementations are created by registering them through the static
+// BluetoothProfile::Register() method and are always identified by a UUID
+// which in any method may be specified in the short or long form.
+//
+// The lifecycle of BluetoothProfile instances is managed by the implementation
+// but they are guaranteed to exist once provided to a Register() callback until
+// the instance's Unregister() method is called, so others may hold on to
+// pointers to them.
+class BluetoothProfile {
+ public:
+ // Options used to register a BluetoothProfile object.
+ struct Options {
+ Options();
+ ~Options();
+
+ // Human readable name of the Profile, e.g. "Health Device".
+ // Exported in the adapter's SDP or GATT tables where relevant.
+ std::string name;
+
+ // RFCOMM channel used by the profile.
+ // Exported in the adapter's SDP or GATT tables where relevant.
+ uint16 channel;
+
+ // L2CAP PSM number.
+ // Exported in the adapter's SDP or GATT tables where relevant.
+ uint16 psm;
+
+ // Specifies whether pairing (and encryption) is required to be able to
+ // connect. Defaults to false.
+ bool require_authentication;
+
+ // Specifies whether user authorization is required to be able to connect.
+ // Defaults to false.
+ bool require_authorization;
+
+ // Implemented version of the profile.
+ // Exported in the adapter's SDP or GATT tables where relevant.
+ uint16 version;
+
+ // Implemented feature set of the profile.
+ // Exported in the adapter's SDP or GATT tables where relevant.
+ uint16 features;
+ };
+
+ // Register an implementation of the profile with UUID |uuid| and
+ // additional details specified in |options|. The corresponding profile
+ // object will be created and returned by |callback|. If the profile cannot
+ // be registered, NULL will be passed.
+ //
+ // This pointer is not owned by the receiver, but will not be freed unless
+ // its Unregister() method is called.
+ typedef base::Callback<void(BluetoothProfile*)> ProfileCallback;
+ static void Register(const std::string& uuid,
+ const Options& options,
+ const ProfileCallback& callback);
+
+ // Unregister the profile. This deletes the profile object so, once called,
+ // any pointers to the profile should be discarded.
+ virtual void Unregister() = 0;
+
+ // Set the connection callback for the profile to |callback|, any successful
+ // connection initiated by BluetoothDevice::ConnectToProfile() or incoming
+ // connections from devices, will have a BluetoothSocket created and passed
+ // to this callback.
+ //
+ // The socket will be closed when all references are released; none of the
+ // BluetoothProfile, or BluetoothAdapter or BluetoothDevice objects are
+ // guaranteed to hold a reference so this may outlive all of them.
+ typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> SocketCallback;
+ virtual void SetConnectionCallback(const SocketCallback& callback) = 0;
+
+ private:
+ BluetoothProfile();
+ virtual ~BluetoothProfile();
+};
+
+} // namespace device
+
+#endif /* DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_H_ */
« 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