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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void TCPListenSocket::Accept() { | 100 void TCPListenSocket::Accept() { |
101 SocketDescriptor conn = AcceptSocket(); | 101 SocketDescriptor conn = AcceptSocket(); |
102 if (conn == kInvalidSocket) | 102 if (conn == kInvalidSocket) |
103 return; | 103 return; |
104 scoped_ptr<TCPListenSocket> sock( | 104 scoped_ptr<TCPListenSocket> sock( |
105 new TCPListenSocket(conn, socket_delegate_)); | 105 new TCPListenSocket(conn, socket_delegate_)); |
106 // It's up to the delegate to AddRef if it wants to keep it around. | 106 // It's up to the delegate to AddRef if it wants to keep it around. |
107 #if defined(OS_POSIX) | 107 #if defined(OS_POSIX) |
108 sock->WatchSocket(WAITING_READ); | 108 sock->WatchSocket(WAITING_READ); |
109 #endif | 109 #endif |
110 socket_delegate_->DidAccept(this, sock.PassAs<StreamListenSocket>()); | 110 socket_delegate_->DidAccept(this, sock.Pass()); |
111 } | 111 } |
112 | 112 |
113 TCPListenSocketFactory::TCPListenSocketFactory(const string& ip, int port) | 113 TCPListenSocketFactory::TCPListenSocketFactory(const string& ip, int port) |
114 : ip_(ip), | 114 : ip_(ip), |
115 port_(port) { | 115 port_(port) { |
116 } | 116 } |
117 | 117 |
118 TCPListenSocketFactory::~TCPListenSocketFactory() {} | 118 TCPListenSocketFactory::~TCPListenSocketFactory() {} |
119 | 119 |
120 scoped_ptr<StreamListenSocket> TCPListenSocketFactory::CreateAndListen( | 120 scoped_ptr<StreamListenSocket> TCPListenSocketFactory::CreateAndListen( |
121 StreamListenSocket::Delegate* delegate) const { | 121 StreamListenSocket::Delegate* delegate) const { |
122 return TCPListenSocket::CreateAndListen(ip_, port_, delegate) | 122 return TCPListenSocket::CreateAndListen(ip_, port_, delegate); |
123 .PassAs<StreamListenSocket>(); | |
124 } | 123 } |
125 | 124 |
126 } // namespace net | 125 } // namespace net |
OLD | NEW |