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

Side by Side Diff: net/socket/tcp_server_socket_libevent.h

Issue 10907154: Allow server sockets to rebind to same port if there is nothing actively listening on that port. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix content_unittests build Created 8 years, 3 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 | « net/socket/server_socket.h ('k') | net/socket/tcp_server_socket_libevent.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ 5 #ifndef NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_
6 #define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ 6 #define NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
11 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
12 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
13 #include "net/socket/server_socket.h" 13 #include "net/socket/server_socket.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 class IPEndPoint; 17 class IPEndPoint;
18 18
19 class NET_EXPORT_PRIVATE TCPServerSocketLibevent 19 class NET_EXPORT_PRIVATE TCPServerSocketLibevent
20 : public ServerSocket, 20 : public ServerSocket,
21 public base::NonThreadSafe, 21 public base::NonThreadSafe,
22 public MessageLoopForIO::Watcher { 22 public MessageLoopForIO::Watcher {
23 public: 23 public:
24 TCPServerSocketLibevent(net::NetLog* net_log, 24 TCPServerSocketLibevent(net::NetLog* net_log,
25 const net::NetLog::Source& source); 25 const net::NetLog::Source& source);
26 virtual ~TCPServerSocketLibevent(); 26 virtual ~TCPServerSocketLibevent();
27 27
28 // net::ServerSocket implementation. 28 // net::ServerSocket implementation.
29 virtual void AllowAddressReuse() OVERRIDE;
29 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE; 30 virtual int Listen(const net::IPEndPoint& address, int backlog) OVERRIDE;
30 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; 31 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
31 virtual int Accept(scoped_ptr<StreamSocket>* socket, 32 virtual int Accept(scoped_ptr<StreamSocket>* socket,
32 const CompletionCallback& callback) OVERRIDE; 33 const CompletionCallback& callback) OVERRIDE;
33 34
34 // MessageLoopForIO::Watcher implementation. 35 // MessageLoopForIO::Watcher implementation.
35 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; 36 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
36 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; 37 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
37 38
38 private: 39 private:
40 int SetSocketOptions();
39 int AcceptInternal(scoped_ptr<StreamSocket>* socket); 41 int AcceptInternal(scoped_ptr<StreamSocket>* socket);
40 void Close(); 42 void Close();
41 43
42 int socket_; 44 int socket_;
43 45
44 MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_; 46 MessageLoopForIO::FileDescriptorWatcher accept_socket_watcher_;
45 47
46 scoped_ptr<StreamSocket>* accept_socket_; 48 scoped_ptr<StreamSocket>* accept_socket_;
47 CompletionCallback accept_callback_; 49 CompletionCallback accept_callback_;
48 50
51 bool reuse_address_;
52
49 BoundNetLog net_log_; 53 BoundNetLog net_log_;
50 }; 54 };
51 55
52 } // namespace net 56 } // namespace net
53 57
54 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_ 58 #endif // NET_SOCKET_TCP_SERVER_SOCKET_LIBEVENT_H_
OLDNEW
« no previous file with comments | « net/socket/server_socket.h ('k') | net/socket/tcp_server_socket_libevent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698