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

Unified Diff: chrome/browser/chromeos/bluetooth/bluetooth_device.cc

Issue 10007008: Add support for creating bluetooth RFCOMM sockets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding disconnect Created 8 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
Index: chrome/browser/chromeos/bluetooth/bluetooth_device.cc
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
index d5c7a708169a0e93a0258c61c5d5209f57ebdad9..d08a8d4358bdef9b7f5f7bbe81bb73e0c1a982bd 100644
--- a/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_device.cc
@@ -4,23 +4,26 @@
#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
+#include <map>
#include <string>
#include <vector>
#include "base/bind.h"
#include "base/logging.h"
+#include "base/memory/weak_ptr.h"
#include "base/string16.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h"
+#include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h"
#include "chrome/browser/chromeos/dbus/bluetooth_adapter_client.h"
#include "chrome/browser/chromeos/dbus/bluetooth_agent_service_provider.h"
#include "chrome/browser/chromeos/dbus/bluetooth_device_client.h"
#include "chrome/browser/chromeos/dbus/bluetooth_input_client.h"
+#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/dbus/introspectable_client.h"
#include "chrome/browser/chromeos/dbus/introspect_util.h"
-#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "dbus/bus.h"
#include "dbus/object_path.h"
#include "grit/generated_resources.h"
@@ -397,6 +400,7 @@ void BluetoothDevice::DisconnectCallback(ErrorCallback error_callback,
}
void BluetoothDevice::Forget(ErrorCallback error_callback) {
+ CloseAllSockets();
DBusThreadManager::Get()->GetBluetoothAdapterClient()->
RemoveDevice(adapter_->object_path_,
object_path_,
@@ -405,6 +409,41 @@ void BluetoothDevice::Forget(ErrorCallback error_callback) {
error_callback));
}
+void BluetoothDevice::CloseAllSockets() {
+ for (SocketMap::const_iterator i = socket_map_.begin();
+ i != socket_map_.end(); ++i) {
+ BluetoothSocket* socket = i->second;
+ socket->Close();
+ delete socket;
keybuk 2012/04/16 22:25:36 Could this be encapsulated as simply dropping the
+ }
+ socket_map_.clear();
+}
+
+base::WeakPtr<BluetoothSocket> BluetoothDevice::OpenSocket(
+ const std::string &service_uuid) {
keybuk 2012/04/16 22:25:36 nit: "& " not " &"
+ // TODO(keybuk): dbus stuff
+ LOG(ERROR) << "NIY: returning dummy socket for now";
+
+ int socket_id = -1;
+ BluetoothSocket* socket = new BluetoothSocket(this, service_uuid, socket_id);
+ socket_map_[socket_id] = socket;
+ return socket->AsWeakPtr();
+}
+
+void BluetoothDevice::CloseSocket(int socket_id) {
+ SocketMap::iterator it = socket_map_.find(socket_id);
+
+ if (it == socket_map_.end()) {
+ return;
+ }
+
+ BluetoothSocket* socket = it->second;
+ socket->Close();
+ delete socket;
keybuk 2012/04/16 22:25:36 As above, could this be a drop of a reference rath
+
+ socket_map_.erase(it);
+}
+
void BluetoothDevice::ForgetCallback(ErrorCallback error_callback,
const dbus::ObjectPath& adapter_path,
bool success) {

Powered by Google App Engine
This is Rietveld 408576698