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/tools/fetch/http_listen_socket.h" | 5 #include "net/tools/fetch/http_listen_socket.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 void HttpListenSocket::Accept() { | 25 void HttpListenSocket::Accept() { |
26 SocketDescriptor conn = net::TCPListenSocket::AcceptSocket(); | 26 SocketDescriptor conn = net::TCPListenSocket::AcceptSocket(); |
27 DCHECK_NE(conn, net::TCPListenSocket::kInvalidSocket); | 27 DCHECK_NE(conn, net::TCPListenSocket::kInvalidSocket); |
28 if (conn == net::TCPListenSocket::kInvalidSocket) { | 28 if (conn == net::TCPListenSocket::kInvalidSocket) { |
29 // TODO | 29 // TODO |
30 } else { | 30 } else { |
31 scoped_refptr<HttpListenSocket> sock( | 31 scoped_refptr<HttpListenSocket> sock( |
32 new HttpListenSocket(conn, delegate_)); | 32 new HttpListenSocket(conn, delegate_)); |
33 // It's up to the delegate to AddRef if it wants to keep it around. | 33 // It's up to the delegate to AddRef if it wants to keep it around. |
34 DidAccept(this, sock); | 34 DidAccept(this, sock.get()); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 // static | 38 // static |
39 scoped_refptr<HttpListenSocket> HttpListenSocket::CreateAndListen( | 39 scoped_refptr<HttpListenSocket> HttpListenSocket::CreateAndListen( |
40 const std::string& ip, | 40 const std::string& ip, |
41 int port, | 41 int port, |
42 HttpListenSocket::Delegate* delegate) { | 42 HttpListenSocket::Delegate* delegate) { |
43 SocketDescriptor s = net::TCPListenSocket::CreateAndBind(ip, port); | 43 SocketDescriptor s = net::TCPListenSocket::CreateAndBind(ip, port); |
44 if (s == net::TCPListenSocket::kInvalidSocket) { | 44 if (s == net::TCPListenSocket::kInvalidSocket) { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 // End of headers. | 239 // End of headers. |
240 response += "\r\n"; | 240 response += "\r\n"; |
241 | 241 |
242 // Add data. | 242 // Add data. |
243 response += data; | 243 response += data; |
244 | 244 |
245 // Write it all out. | 245 // Write it all out. |
246 this->Send(response, false); | 246 this->Send(response, false); |
247 } | 247 } |
OLD | NEW |