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

Unified Diff: trunk/src/device/bluetooth/bluetooth_socket_win.h

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
Index: trunk/src/device/bluetooth/bluetooth_socket_win.h
===================================================================
--- trunk/src/device/bluetooth/bluetooth_socket_win.h (revision 262179)
+++ trunk/src/device/bluetooth/bluetooth_socket_win.h (working copy)
@@ -7,124 +7,43 @@
#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);
+ static scoped_refptr<BluetoothSocket> CreateBluetoothSocket(
+ const BluetoothServiceRecord& service_record);
- // 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);
+ // BluetoothSocket override
+ virtual bool Receive(net::GrowableIOBuffer* buffer) OVERRIDE;
+ virtual bool Send(net::DrainableIOBuffer* buffer) OVERRIDE;
+ virtual std::string GetLastErrorMessage() const OVERRIDE;
- // 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;
-
protected:
virtual ~BluetoothSocketWin();
private:
- struct WriteRequest {
- scoped_refptr<net::IOBuffer> buffer;
- int buffer_size;
- SendCompletionCallback success_callback;
- ErrorCompletionCallback error_callback;
- };
+ explicit BluetoothSocketWin(SOCKET fd);
- BluetoothSocketWin(scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<BluetoothSocketThreadWin> socket_thread,
- net::NetLog* net_log,
- const net::NetLog::Source& source);
+ const SOCKET fd_;
+ std::string error_message_;
- 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_;
-
DISALLOW_COPY_AND_ASSIGN(BluetoothSocketWin);
};
« no previous file with comments | « trunk/src/device/bluetooth/bluetooth_socket_thread_win.cc ('k') | trunk/src/device/bluetooth/bluetooth_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698