| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_BASE_TCP_CLIENT_SOCKET_WIN_H_ | 5 #ifndef NET_BASE_TCP_CLIENT_SOCKET_WIN_H_ |
| 6 #define NET_BASE_TCP_CLIENT_SOCKET_WIN_H_ | 6 #define NET_BASE_TCP_CLIENT_SOCKET_WIN_H_ |
| 7 | 7 |
| 8 #include <ws2tcpip.h> | 8 #include <ws2tcpip.h> |
| 9 | 9 |
| 10 #include "base/object_watcher.h" | 10 #include "base/object_watcher.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // ClientSocket methods: | 26 // ClientSocket methods: |
| 27 virtual int Connect(CompletionCallback* callback); | 27 virtual int Connect(CompletionCallback* callback); |
| 28 virtual void Disconnect(); | 28 virtual void Disconnect(); |
| 29 virtual bool IsConnected() const; | 29 virtual bool IsConnected() const; |
| 30 virtual bool IsConnectedAndIdle() const; | 30 virtual bool IsConnectedAndIdle() const; |
| 31 | 31 |
| 32 // Socket methods: | 32 // Socket methods: |
| 33 // Multiple outstanding requests are not supported. | 33 // Multiple outstanding requests are not supported. |
| 34 // Full duplex mode (reading and writing at the same time) is supported | 34 // Full duplex mode (reading and writing at the same time) is supported |
| 35 virtual int Read(char* buf, int buf_len, CompletionCallback* callback); | 35 virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 36 virtual int Write(const char* buf, int buf_len, CompletionCallback* callback); | 36 virtual int Write(IOBuffer* buf, int buf_len, CompletionCallback* callback); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 class ReadDelegate : public base::ObjectWatcher::Delegate { | 39 class ReadDelegate : public base::ObjectWatcher::Delegate { |
| 40 public: | 40 public: |
| 41 explicit ReadDelegate(TCPClientSocketWin* tcp_socket) | 41 explicit ReadDelegate(TCPClientSocketWin* tcp_socket) |
| 42 : tcp_socket_(tcp_socket) { } | 42 : tcp_socket_(tcp_socket) { } |
| 43 virtual ~ReadDelegate() { } | 43 virtual ~ReadDelegate() { } |
| 44 | 44 |
| 45 // base::ObjectWatcher::Delegate methods: | 45 // base::ObjectWatcher::Delegate methods: |
| 46 virtual void OnObjectSignaled(HANDLE object); | 46 virtual void OnObjectSignaled(HANDLE object); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 // The separate OVERLAPPED variables for asynchronous operation. | 83 // The separate OVERLAPPED variables for asynchronous operation. |
| 84 // |read_overlapped_| is used for both Connect() and Read(). | 84 // |read_overlapped_| is used for both Connect() and Read(). |
| 85 // |write_overlapped_| is only used for Write(); | 85 // |write_overlapped_| is only used for Write(); |
| 86 OVERLAPPED read_overlapped_; | 86 OVERLAPPED read_overlapped_; |
| 87 OVERLAPPED write_overlapped_; | 87 OVERLAPPED write_overlapped_; |
| 88 | 88 |
| 89 // The buffers used in Read() and Write(). | 89 // The buffers used in Read() and Write(). |
| 90 WSABUF read_buffer_; | 90 WSABUF read_buffer_; |
| 91 WSABUF write_buffer_; | 91 WSABUF write_buffer_; |
| 92 scoped_refptr<IOBuffer> read_iobuffer_; |
| 93 scoped_refptr<IOBuffer> write_iobuffer_; |
| 92 | 94 |
| 93 // |reader_| handles the signals from |read_watcher_|. | 95 // |reader_| handles the signals from |read_watcher_|. |
| 94 ReadDelegate reader_; | 96 ReadDelegate reader_; |
| 95 // |writer_| handles the signals from |write_watcher_|. | 97 // |writer_| handles the signals from |write_watcher_|. |
| 96 WriteDelegate writer_; | 98 WriteDelegate writer_; |
| 97 | 99 |
| 98 // |read_watcher_| watches for events from Connect() and Read(). | 100 // |read_watcher_| watches for events from Connect() and Read(). |
| 99 base::ObjectWatcher read_watcher_; | 101 base::ObjectWatcher read_watcher_; |
| 100 // |write_watcher_| watches for events from Write(); | 102 // |write_watcher_| watches for events from Write(); |
| 101 base::ObjectWatcher write_watcher_; | 103 base::ObjectWatcher write_watcher_; |
| 102 | 104 |
| 103 // External callback; called when connect or read is complete. | 105 // External callback; called when connect or read is complete. |
| 104 CompletionCallback* read_callback_; | 106 CompletionCallback* read_callback_; |
| 105 | 107 |
| 106 // External callback; called when write is complete. | 108 // External callback; called when write is complete. |
| 107 CompletionCallback* write_callback_; | 109 CompletionCallback* write_callback_; |
| 108 | 110 |
| 109 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); | 111 DISALLOW_COPY_AND_ASSIGN(TCPClientSocketWin); |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 } // namespace net | 114 } // namespace net |
| 113 | 115 |
| 114 #endif // NET_BASE_TCP_CLIENT_SOCKET_WIN_H_ | 116 #endif // NET_BASE_TCP_CLIENT_SOCKET_WIN_H_ |
| OLD | NEW |