summaryrefslogtreecommitdiffstats
path: root/device/bluetooth/bluetooth_socket_win.h
diff options
context:
space:
mode:
authorscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 19:58:52 +0000
committerscottmg@chromium.org <scottmg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-07 19:58:52 +0000
commitdc85cefeac3ce32fe326af854676f4d0ca3bd90a (patch)
tree73fc7ff21bc50d1c36c8c082397f7f6651d23c76 /device/bluetooth/bluetooth_socket_win.h
parent4b22d0aac0b8300ea268a92ae071235902efad83 (diff)
downloadchromium_src-dc85cefeac3ce32fe326af854676f4d0ca3bd90a.zip
chromium_src-dc85cefeac3ce32fe326af854676f4d0ca3bd90a.tar.gz
chromium_src-dc85cefeac3ce32fe326af854676f4d0ca3bd90a.tar.bz2
Revert 262175 "* Replace "read" method with onReceiveXxx events."
Failed compile on Linux CrOS Full: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Full/builds/2043/steps/compile/logs/stdio > * Replace "read" method with onReceiveXxx events. > * Few minor changes to idl file. > * Socket implementation on Windows fully implemented and with (hopefully) correct threading usage. > * ChromeOS and MacOS socket implementation empty for now (they will come in later CLs). > > BUG=336824,340363, 340413, 343651, 344081 > > Review URL: https://codereview.chromium.org/180163009 TBR=rpaquay@chromium.org Review URL: https://codereview.chromium.org/227493006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/bluetooth/bluetooth_socket_win.h')
-rw-r--r--device/bluetooth/bluetooth_socket_win.h115
1 files changed, 17 insertions, 98 deletions
diff --git a/device/bluetooth/bluetooth_socket_win.h b/device/bluetooth/bluetooth_socket_win.h
index 94f3df2..41713e7 100644
--- a/device/bluetooth/bluetooth_socket_win.h
+++ b/device/bluetooth/bluetooth_socket_win.h
@@ -7,123 +7,42 @@
#include <WinSock2.h>
-#include <queue>
#include <string>
-#include "base/memory/linked_ptr.h"
#include "base/memory/ref_counted.h"
-#include "base/threading/thread_checker.h"
-#include "device/bluetooth/bluetooth_service_record_win.h"
#include "device/bluetooth/bluetooth_socket.h"
-#include "net/base/net_log.h"
-#include "net/socket/tcp_socket.h"
namespace net {
-class IOBuffer;
-class IOBufferWithSize;
+
+class DrainableIOBuffer;
+class GrowableIOBuffer;
+
} // namespace net
namespace device {
class BluetoothServiceRecord;
-class BluetoothSocketThreadWin;
-// This class is an implementation of BluetoothSocket class for the Windows
-// platform. All public methods (including the factory method) must be called
-// on the UI thread, while underlying socket operations are performed on a
-// separated thread.
+// This class is an implementation of BluetoothSocket class for Windows
+// platform.
class BluetoothSocketWin : public BluetoothSocket {
public:
- static scoped_refptr<BluetoothSocketWin> CreateBluetoothSocket(
- const BluetoothServiceRecord& service_record,
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<BluetoothSocketThreadWin> socket_thread,
- net::NetLog* net_log,
- const net::NetLog::Source& source);
-
- // Connect to the peer device and calls |success_callback| when the
- // connection has been established successfully. If an error occurs, calls
- // |error_callback| with a system error message.
- void Connect(const base::Closure& success_callback,
- const ErrorCompletionCallback& error_callback);
-
- // Overriden from BluetoothSocket:
- virtual void Close() OVERRIDE;
-
- virtual void Disconnect(const base::Closure& callback) OVERRIDE;
-
- virtual void Receive(int count,
- const ReceiveCompletionCallback& success_callback,
- const ReceiveErrorCompletionCallback& error_callback)
- OVERRIDE;
- virtual void Send(scoped_refptr<net::IOBuffer> buffer,
- int buffer_size,
- const SendCompletionCallback& success_callback,
- const ErrorCompletionCallback& error_callback) OVERRIDE;
+ static scoped_refptr<BluetoothSocket> CreateBluetoothSocket(
+ const BluetoothServiceRecord& service_record);
+
+ // BluetoothSocket override
+ virtual bool Receive(net::GrowableIOBuffer* buffer) OVERRIDE;
+ virtual bool Send(net::DrainableIOBuffer* buffer) OVERRIDE;
+ virtual std::string GetLastErrorMessage() const OVERRIDE;
protected:
virtual ~BluetoothSocketWin();
private:
- struct WriteRequest {
- scoped_refptr<net::IOBuffer> buffer;
- int buffer_size;
- SendCompletionCallback success_callback;
- ErrorCompletionCallback error_callback;
- };
-
- BluetoothSocketWin(scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<BluetoothSocketThreadWin> socket_thread,
- net::NetLog* net_log,
- const net::NetLog::Source& source);
-
- void DoClose();
- void DoConnect(const base::Closure& success_callback,
- const ErrorCompletionCallback& error_callback);
- void DoDisconnect(const base::Closure& callback);
- void DoReceive(int count,
- const ReceiveCompletionCallback& success_callback,
- const ReceiveErrorCompletionCallback& error_callback);
- void DoSend(scoped_refptr<net::IOBuffer> buffer,
- int buffer_size,
- const SendCompletionCallback& success_callback,
- const ErrorCompletionCallback& error_callback);
-
- void PostSuccess(const base::Closure& callback);
- void PostErrorCompletion(const ErrorCompletionCallback& callback,
- const std::string& error);
- void PostReceiveCompletion(const ReceiveCompletionCallback& callback,
- int io_buffer_size,
- scoped_refptr<net::IOBuffer> io_buffer);
- void PostReceiveErrorCompletion(
- const ReceiveErrorCompletionCallback& callback,
- ErrorReason reason,
- const std::string& error_message);
- void PostSendCompletion(const SendCompletionCallback& callback,
- int bytes_written);
-
- void SendFrontWriteRequest();
- void OnSocketWriteComplete(const SendCompletionCallback& success_callback,
- const ErrorCompletionCallback& error_callback,
- int net_status);
- void OnSocketReadComplete(
- const ReceiveCompletionCallback& success_callback,
- const ReceiveErrorCompletionCallback& error_callback,
- int send_result);
-
- scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
- scoped_refptr<BluetoothSocketThreadWin> socket_thread_;
- net::NetLog* net_log_;
- const net::NetLog::Source source_;
- std::string device_address_;
- bool supports_rfcomm_;
- uint8 rfcomm_channel_;
- BTH_ADDR bth_addr_;
- scoped_ptr<net::TCPSocket> tcp_socket_;
- // Queue of pending writes. The buffer at the front of the queue is the one
- // being written.
- std::queue<linked_ptr<WriteRequest> > write_queue_;
- scoped_refptr<net::IOBufferWithSize> read_buffer_;
+ explicit BluetoothSocketWin(SOCKET fd);
+
+ const SOCKET fd_;
+ std::string error_message_;
DISALLOW_COPY_AND_ASSIGN(BluetoothSocketWin);
};