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

Unified Diff: trunk/src/device/bluetooth/bluetooth_profile_win.cc

Issue 227493006: Revert 262175 "* Replace "read" method with onReceiveXxx events." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 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 | « trunk/src/device/bluetooth/bluetooth_profile_win.h ('k') | trunk/src/device/bluetooth/bluetooth_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/device/bluetooth/bluetooth_profile_win.cc
===================================================================
--- trunk/src/device/bluetooth/bluetooth_profile_win.cc (revision 262179)
+++ trunk/src/device/bluetooth/bluetooth_profile_win.cc (working copy)
@@ -4,66 +4,11 @@
#include "device/bluetooth/bluetooth_profile_win.h"
-#include "base/bind.h"
#include "base/memory/ref_counted.h"
-#include "base/sequenced_task_runner.h"
-#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_device_win.h"
#include "device/bluetooth/bluetooth_service_record.h"
-#include "device/bluetooth/bluetooth_socket_thread_win.h"
#include "device/bluetooth/bluetooth_socket_win.h"
-namespace {
-
-using device::BluetoothAdapter;
-using device::BluetoothDevice;
-using device::BluetoothProfileWin;
-using device::BluetoothSocket;
-using device::BluetoothSocketWin;
-
-const char kNoConnectionCallback[] = "Connection callback not set";
-const char kProfileNotFound[] = "Profile not found";
-
-void OnConnectSuccessUIWithAdapter(
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- const base::Closure& callback,
- const BluetoothProfileWin::ConnectionCallback& connection_callback,
- const std::string& device_address,
- scoped_refptr<BluetoothSocketWin> socket,
- scoped_refptr<BluetoothAdapter> adapter) {
- DCHECK(ui_task_runner->RunsTasksOnCurrentThread());
- const BluetoothDevice* device = adapter->GetDevice(device_address);
- if (device) {
- connection_callback.Run(device, socket);
- callback.Run();
- }
-}
-
-void OnConnectSuccessUI(
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- const base::Closure& callback,
- const BluetoothProfileWin::ConnectionCallback& connection_callback,
- const std::string& device_address,
- scoped_refptr<BluetoothSocketWin> socket) {
- DCHECK(ui_task_runner->RunsTasksOnCurrentThread());
- device::BluetoothAdapterFactory::GetAdapter(
- base::Bind(&OnConnectSuccessUIWithAdapter,
- ui_task_runner,
- callback,
- connection_callback,
- device_address,
- socket));
-}
-
-void OnConnectErrorUI(scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- const BluetoothProfileWin::ErrorCallback& error_callback,
- const std::string& error) {
- DCHECK(ui_task_runner->RunsTasksOnCurrentThread());
- error_callback.Run(error);
-}
-
-} // namespace
-
namespace device {
BluetoothProfileWin::BluetoothProfileWin(const BluetoothUUID& uuid,
@@ -83,37 +28,20 @@
connection_callback_ = callback;
}
-void BluetoothProfileWin::Connect(
- const BluetoothDeviceWin* device,
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<BluetoothSocketThreadWin> socket_thread,
- net::NetLog* net_log,
- const net::NetLog::Source& source,
- const base::Closure& success_callback,
- const ErrorCallback& error_callback) {
- DCHECK(ui_task_runner->RunsTasksOnCurrentThread());
- if (connection_callback_.is_null()) {
- error_callback.Run(kNoConnectionCallback);
- return;
- }
+bool BluetoothProfileWin::Connect(const BluetoothDeviceWin* device) {
+ if (connection_callback_.is_null())
+ return false;
const BluetoothServiceRecord* record = device->GetServiceRecord(uuid_);
- if (!record) {
- error_callback.Run(kProfileNotFound);
- return;
+ if (record) {
+ scoped_refptr<BluetoothSocket> socket(
+ BluetoothSocketWin::CreateBluetoothSocket(*record));
+ if (socket.get() != NULL) {
+ connection_callback_.Run(device, socket);
+ return true;
+ }
}
-
- scoped_refptr<BluetoothSocketWin> socket(
- BluetoothSocketWin::CreateBluetoothSocket(
- *record, ui_task_runner, socket_thread, net_log, source));
-
- socket->Connect(base::Bind(&OnConnectSuccessUI,
- ui_task_runner,
- success_callback,
- connection_callback_,
- device->GetAddress(),
- socket),
- error_callback);
+ return false;
}
} // namespace device
« no previous file with comments | « trunk/src/device/bluetooth/bluetooth_profile_win.h ('k') | trunk/src/device/bluetooth/bluetooth_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698