| OLD | NEW |
| 1 // Copyright (c) 2010 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 #include <map> | 5 #include "net/server/http_server.h" |
| 6 | |
| 7 #ifdef _WIN32 | |
| 8 #include <winsock2.h> | |
| 9 #else | |
| 10 #include <arpa/inet.h> | |
| 11 #endif | |
| 12 | 6 |
| 13 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 14 #include "base/logging.h" | 8 #include "base/logging.h" |
| 15 #include "base/md5.h" | 9 #include "base/md5.h" |
| 16 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 17 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 19 #include "net/server/http_server.h" | 13 #include "build/build_config.h" |
| 20 #include "net/server/http_server_request_info.h" | 14 #include "net/server/http_server_request_info.h" |
| 21 | 15 |
| 16 #if defined(OS_WIN) |
| 17 #include <winsock2.h> |
| 18 #else |
| 19 #include <arpa/inet.h> |
| 20 #endif |
| 21 |
| 22 namespace net { |
| 23 |
| 22 int HttpServer::Connection::lastId_ = 0; | 24 int HttpServer::Connection::lastId_ = 0; |
| 25 |
| 23 HttpServer::HttpServer(const std::string& host, | 26 HttpServer::HttpServer(const std::string& host, |
| 24 int port, | 27 int port, |
| 25 HttpServer::Delegate* del) | 28 HttpServer::Delegate* del) |
| 26 : delegate_(del) { | 29 : delegate_(del) { |
| 27 server_ = ListenSocket::Listen(host, port, this); | 30 server_ = ListenSocket::Listen(host, port, this); |
| 28 } | 31 } |
| 29 | 32 |
| 30 HttpServer::~HttpServer() { | 33 HttpServer::~HttpServer() { |
| 31 IdToConnectionMap copy = id_to_connection_; | 34 IdToConnectionMap copy = id_to_connection_; |
| 32 for (IdToConnectionMap::iterator it = copy.begin(); it != copy.end(); ++it) | 35 for (IdToConnectionMap::iterator it = copy.begin(); it != copy.end(); ++it) |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return NULL; | 429 return NULL; |
| 427 return it->second; | 430 return it->second; |
| 428 } | 431 } |
| 429 | 432 |
| 430 HttpServer::Connection* HttpServer::FindConnection(ListenSocket* socket) { | 433 HttpServer::Connection* HttpServer::FindConnection(ListenSocket* socket) { |
| 431 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); | 434 SocketToConnectionMap::iterator it = socket_to_connection_.find(socket); |
| 432 if (it == socket_to_connection_.end()) | 435 if (it == socket_to_connection_.end()) |
| 433 return NULL; | 436 return NULL; |
| 434 return it->second; | 437 return it->second; |
| 435 } | 438 } |
| 439 |
| 440 } // namespace net |
| OLD | NEW |