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

Unified Diff: device/bluetooth/bluetooth_socket_experimental_chromeos.h

Issue 14487002: Bluetooth: Profile support for Chrome OS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add unit tests, and class comments Created 7 years, 7 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
Index: device/bluetooth/bluetooth_socket_experimental_chromeos.h
diff --git a/device/bluetooth/bluetooth_socket_experimental_chromeos.h b/device/bluetooth/bluetooth_socket_experimental_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..c0e1af0b069c65ab200c551dbd7c2674c20a6fba
--- /dev/null
+++ b/device/bluetooth/bluetooth_socket_experimental_chromeos.h
@@ -0,0 +1,75 @@
+// 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_SOCKET_EXPERIMENTAL_CHROMEOS_H_
+#define DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_EXPERIMENTAL_CHROMEOS_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "chromeos/chromeos_export.h"
+#include "device/bluetooth/bluetooth_socket.h"
+
+namespace dbus {
+
+class FileDescriptor;
+
+} // namespace dbus
+
+namespace net {
+
+class DrainableIOBuffer;
+class GrowableIOBuffer;
+
+} // namespace net
+
+namespace chromeos {
+
+// The BluetoothSocketExperimentalChromeOS class is an alternate implementation
+// of BluetoothSocket for the Chrome OS platform using the Bluetooth Smart
+// capable backend. It will become the sole implementation for Chrome OS, and
+// be renamed to BluetoothSocketChromeOS, once the backend is switched.
+class CHROMEOS_EXPORT BluetoothSocketExperimentalChromeOS
+ : public device::BluetoothSocket {
+ public:
+ // BluetoothSocket override.
+ virtual bool Receive(net::GrowableIOBuffer* buffer) OVERRIDE;
+ virtual bool Send(net::DrainableIOBuffer* buffer) OVERRIDE;
+ virtual std::string GetLastErrorMessage() const OVERRIDE;
+
+ // Create an instance of a BluetoothSocket from the passed file descriptor
+ // received over D-Bus in |fd|, the descriptor will be taken from that object
+ // and ownership passed to the returned object.
+ static scoped_refptr<device::BluetoothSocket> Create(
+ dbus::FileDescriptor* fd);
+
+ protected:
+ virtual ~BluetoothSocketExperimentalChromeOS();
+
+ private:
+ BluetoothSocketExperimentalChromeOS(int fd);
+
+ // The different socket types have different reading patterns; l2cap sockets
+ // have to be read with boundaries between datagrams preserved while rfcomm
+ // sockets do not.
+ enum SocketType {
+ L2CAP,
+ RFCOMM
+ };
+
+ // File descriptor and socket type of the socket.
+ const int fd_;
+ SocketType socket_type_;
+
+ // Last error message, set during Receive() and Send() and retrieved using
+ // GetLastErrorMessage().
+ std::string error_message_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothSocketExperimentalChromeOS);
+};
+
+} // namespace chromeos
+
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_EXPERIMENTAL_CHROMEOS_H_

Powered by Google App Engine
This is Rietveld 408576698