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

Unified Diff: device/bluetooth/bluetooth_socket_win.h

Issue 267633003: Reimplement BluetoothSocketChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments #1 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: device/bluetooth/bluetooth_socket_win.h
diff --git a/device/bluetooth/bluetooth_socket_win.h b/device/bluetooth/bluetooth_socket_win.h
index 0b4ac901366ee3cd9b94deebac41cb887c6a1a62..0a7bd5cfb484e0db55ccce3fd2d636db92707b6b 100644
--- a/device/bluetooth/bluetooth_socket_win.h
+++ b/device/bluetooth/bluetooth_socket_win.h
@@ -7,32 +7,21 @@
#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 "device/bluetooth/bluetooth_socket_net.h"
#include "net/base/ip_endpoint.h"
-#include "net/base/net_log.h"
#include "net/socket/tcp_socket.h"
-namespace net {
-class IOBuffer;
-class IOBufferWithSize;
-} // 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.
+// The BluetoothSocketChromeOS class implements BluetoothSocket for the
rpaquay 2014/05/01 15:23:58 BluetoothSocketWin?
keybuk 2014/05/01 18:07:16 Done.
+// Windows platform.
class BluetoothSocketWin : public BluetoothSocket {
rpaquay 2014/05/01 15:23:58 BluetoothSocketNet?
keybuk 2014/05/01 18:07:16 Done.
public:
typedef base::Callback<void(scoped_refptr<BluetoothSocketWin>,
@@ -40,7 +29,7 @@ class BluetoothSocketWin : public BluetoothSocket {
static scoped_refptr<BluetoothSocketWin> CreateBluetoothSocket(
scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
- scoped_refptr<BluetoothSocketThreadWin> socket_thread,
+ scoped_refptr<BluetoothSocketThread> socket_thread,
net::NetLog* net_log,
const net::NetLog::Source& source);
@@ -63,72 +52,17 @@ class BluetoothSocketWin : public BluetoothSocket {
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 buffer_size,
- 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 ServiceRegData;
- 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,
+ scoped_refptr<BluetoothSocketThread> 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 buffer_size,
- 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);
-
void DoStartService(const BluetoothUUID& uuid,
const std::string& name,
int rfcomm_channel,
@@ -140,19 +74,10 @@ class BluetoothSocketWin : public BluetoothSocket {
void OnAcceptOnUI(scoped_ptr<net::TCPSocket> accept_socket,
const net::IPEndPoint& peer_address);
- 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_;
scoped_ptr<ServiceRegData> service_reg_data_;
scoped_ptr<net::TCPSocket> accept_socket_;

Powered by Google App Engine
This is Rietveld 408576698