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

Side by Side Diff: net/base/tcp_listen_socket.h

Issue 10389007: Change TCPListenSocket::SendInternal to use a non-blocking implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/base/tcp_listen_socket.cc » ('j') | net/base/tcp_listen_socket.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 15 #include "build/build_config.h"
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN)
18 #include <winsock2.h> 18 #include <winsock2.h>
19 #endif 19 #endif
20 #include <string> 20 #include <string>
21 #if defined(OS_WIN) 21 #if defined(OS_WIN)
22 #include "base/win/object_watcher.h" 22 #include "base/win/object_watcher.h"
23 #elif defined(OS_POSIX) 23 #elif defined(OS_POSIX)
24 #include "base/message_loop.h" 24 #include "base/message_loop.h"
25 #endif 25 #endif
26 26
27 #include "base/basictypes.h" 27 #include "base/basictypes.h"
28 #include "base/compiler_specific.h" 28 #include "base/compiler_specific.h"
29 #include "base/timer.h"
30 #include "net/base/backoff_entry.h"
29 #include "net/base/listen_socket.h" 31 #include "net/base/listen_socket.h"
30 #include "net/base/net_export.h" 32 #include "net/base/net_export.h"
31 33
32 #if defined(OS_POSIX) 34 #if defined(OS_POSIX)
33 typedef int SOCKET; 35 typedef int SOCKET;
34 #endif 36 #endif
35 37
36 namespace net { 38 namespace net {
37 39
38 // Implements a TCP socket interface. Note that this is ref counted. 40 // Implements a TCP socket interface. Note that this is ref counted.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 96 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
95 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 97 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
96 WaitState wait_state_; 98 WaitState wait_state_;
97 // The socket's libevent wrapper 99 // The socket's libevent wrapper
98 MessageLoopForIO::FileDescriptorWatcher watcher_; 100 MessageLoopForIO::FileDescriptorWatcher watcher_;
99 #endif 101 #endif
100 102
101 SOCKET socket_; 103 SOCKET socket_;
102 104
103 private: 105 private:
106 void SendData();
107
104 bool reads_paused_; 108 bool reads_paused_;
105 bool has_pending_reads_; 109 bool has_pending_reads_;
110 std::string send_data_;
111 bool send_data_error_;
112 net::BackoffEntry send_data_backoff_;
113
114 // Used to continue sending data asynchronously.
115 base::OneShotTimer<TCPListenSocket> send_timer_;
106 116
107 DISALLOW_COPY_AND_ASSIGN(TCPListenSocket); 117 DISALLOW_COPY_AND_ASSIGN(TCPListenSocket);
108 }; 118 };
109 119
110 } // namespace net 120 } // namespace net
111 121
112 #endif // NET_BASE_TCP_LISTEN_SOCKET_H_ 122 #endif // NET_BASE_TCP_LISTEN_SOCKET_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/tcp_listen_socket.cc » ('j') | net/base/tcp_listen_socket.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698