Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // TCP/IP server that handles IO asynchronously in the specified MessageLoop. | 5 // TCP/IP server that handles IO asynchronously in the specified MessageLoop. |
| 6 // These objects are NOT thread safe. They use WSAEVENT handles to monitor | 6 // These objects are NOT thread safe. They use WSAEVENT handles to monitor |
| 7 // activity in a given MessageLoop. This means that callbacks will | 7 // activity in a given MessageLoop. This means that callbacks will |
| 8 // happen in that loop's thread always and that all other methods (including | 8 // happen in that loop's thread always and that all other methods (including |
| 9 // constructors and destructors) should also be called from the same thread. | 9 // constructors and destructors) should also be called from the same thread. |
| 10 | 10 |
| 11 #ifndef NET_BASE_TCP_LISTEN_SOCKET_H_ | 11 #ifndef NET_BASE_TCP_LISTEN_SOCKET_H_ |
| 12 #define NET_BASE_TCP_LISTEN_SOCKET_H_ | 12 #define NET_BASE_TCP_LISTEN_SOCKET_H_ |
| 13 #pragma once | 13 #pragma once |
| 14 | 14 |
| 15 #include <vector> | |
| 16 | |
| 15 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 16 | 18 |
| 17 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 18 #include <winsock2.h> | 20 #include <winsock2.h> |
| 19 #endif | 21 #endif |
| 20 #include <string> | 22 #include <string> |
| 21 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 22 #include "base/win/object_watcher.h" | 24 #include "base/win/object_watcher.h" |
| 23 #elif defined(OS_POSIX) | 25 #elif defined(OS_POSIX) |
| 24 #include "base/message_loop.h" | 26 #include "base/message_loop.h" |
| 25 #endif | 27 #endif |
| 26 | 28 |
| 27 #include "base/basictypes.h" | 29 #include "base/basictypes.h" |
| 28 #include "base/compiler_specific.h" | 30 #include "base/compiler_specific.h" |
| 31 #include "base/memory/ref_counted.h" | |
| 32 #include "base/timer.h" | |
| 33 #include "net/base/backoff_entry.h" | |
| 34 #include "net/base/io_buffer.h" | |
| 29 #include "net/base/listen_socket.h" | 35 #include "net/base/listen_socket.h" |
| 30 #include "net/base/net_export.h" | 36 #include "net/base/net_export.h" |
| 31 | 37 |
| 32 #if defined(OS_POSIX) | 38 #if defined(OS_POSIX) |
| 33 typedef int SOCKET; | 39 typedef int SOCKET; |
| 34 #endif | 40 #endif |
| 35 | 41 |
| 36 namespace net { | 42 namespace net { |
| 37 | 43 |
| 38 // Implements a TCP socket interface. Note that this is ref counted. | 44 // Implements a TCP socket interface. Note that this is ref counted. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 100 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; |
| 95 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 101 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; |
| 96 WaitState wait_state_; | 102 WaitState wait_state_; |
| 97 // The socket's libevent wrapper | 103 // The socket's libevent wrapper |
| 98 MessageLoopForIO::FileDescriptorWatcher watcher_; | 104 MessageLoopForIO::FileDescriptorWatcher watcher_; |
| 99 #endif | 105 #endif |
| 100 | 106 |
| 101 SOCKET socket_; | 107 SOCKET socket_; |
| 102 | 108 |
| 103 private: | 109 private: |
| 110 void SendData(); | |
| 111 | |
| 104 bool reads_paused_; | 112 bool reads_paused_; |
| 105 bool has_pending_reads_; | 113 bool has_pending_reads_; |
| 114 std::vector<scoped_refptr<DrainableIOBuffer> > send_buffers_; | |
|
mmenke
2012/05/09 19:20:08
Out of paranoia, might be best to make this a list
Marshall
2012/05/10 16:28:05
Done.
| |
| 115 int send_pending_size_; | |
| 116 bool send_error_; | |
| 117 net::BackoffEntry send_backoff_; | |
| 118 | |
| 119 // Used to continue sending data asynchronously. | |
| 120 base::OneShotTimer<TCPListenSocket> send_timer_; | |
| 106 | 121 |
| 107 DISALLOW_COPY_AND_ASSIGN(TCPListenSocket); | 122 DISALLOW_COPY_AND_ASSIGN(TCPListenSocket); |
| 108 }; | 123 }; |
| 109 | 124 |
| 110 } // namespace net | 125 } // namespace net |
| 111 | 126 |
| 112 #endif // NET_BASE_TCP_LISTEN_SOCKET_H_ | 127 #endif // NET_BASE_TCP_LISTEN_SOCKET_H_ |
| OLD | NEW |