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 #include "net/socket/tcp_listen_socket.h" | 5 #include "net/socket/tcp_listen_socket.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 // winsock2.h must be included first in order to ensure it is included before | 8 // winsock2.h must be included first in order to ensure it is included before |
9 // windows.h. | 9 // windows.h. |
10 #include <winsock2.h> | 10 #include <winsock2.h> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void TCPListenSocket::Accept() { | 103 void TCPListenSocket::Accept() { |
104 SocketDescriptor conn = AcceptSocket(); | 104 SocketDescriptor conn = AcceptSocket(); |
105 if (conn == kInvalidSocket) | 105 if (conn == kInvalidSocket) |
106 return; | 106 return; |
107 scoped_refptr<TCPListenSocket> sock( | 107 scoped_refptr<TCPListenSocket> sock( |
108 new TCPListenSocket(conn, socket_delegate_)); | 108 new TCPListenSocket(conn, socket_delegate_)); |
109 // It's up to the delegate to AddRef if it wants to keep it around. | 109 // It's up to the delegate to AddRef if it wants to keep it around. |
110 #if defined(OS_POSIX) | 110 #if defined(OS_POSIX) |
111 sock->WatchSocket(WAITING_READ); | 111 sock->WatchSocket(WAITING_READ); |
112 #endif | 112 #endif |
113 socket_delegate_->DidAccept(this, sock); | 113 socket_delegate_->DidAccept(this, sock.get()); |
114 } | 114 } |
115 | 115 |
116 TCPListenSocketFactory::TCPListenSocketFactory(const string& ip, int port) | 116 TCPListenSocketFactory::TCPListenSocketFactory(const string& ip, int port) |
117 : ip_(ip), | 117 : ip_(ip), |
118 port_(port) { | 118 port_(port) { |
119 } | 119 } |
120 | 120 |
121 TCPListenSocketFactory::~TCPListenSocketFactory() {} | 121 TCPListenSocketFactory::~TCPListenSocketFactory() {} |
122 | 122 |
123 scoped_refptr<StreamListenSocket> TCPListenSocketFactory::CreateAndListen( | 123 scoped_refptr<StreamListenSocket> TCPListenSocketFactory::CreateAndListen( |
124 StreamListenSocket::Delegate* delegate) const { | 124 StreamListenSocket::Delegate* delegate) const { |
125 return TCPListenSocket::CreateAndListen(ip_, port_, delegate); | 125 return TCPListenSocket::CreateAndListen(ip_, port_, delegate); |
126 } | 126 } |
127 | 127 |
128 } // namespace net | 128 } // namespace net |
OLD | NEW |