Chromium Code Reviews| 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/server/http_server.h" | 5 #include "net/server/http_server.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 | 146 |
| 147 int HttpServer::HandleAcceptResult(int rv) { | 147 int HttpServer::HandleAcceptResult(int rv) { |
| 148 if (rv < 0) { | 148 if (rv < 0) { |
| 149 LOG(ERROR) << "Accept error: rv=" << rv; | 149 LOG(ERROR) << "Accept error: rv=" << rv; |
| 150 return rv; | 150 return rv; |
| 151 } | 151 } |
| 152 | 152 |
| 153 HttpConnection* connection = | 153 HttpConnection* connection = |
| 154 new HttpConnection(++last_id_, accepted_socket_.Pass()); | 154 new HttpConnection(++last_id_, accepted_socket_.Pass()); |
| 155 id_to_connection_[connection->id()] = connection; | 155 id_to_connection_[connection->id()] = connection; |
| 156 delegate_->OnConnect(connection->id()); | |
|
mmenke
2014/09/23 22:29:31
Should allow the embedder to close the connection
samuong
2014/09/24 00:07:13
Done.
| |
| 156 DoReadLoop(connection); | 157 DoReadLoop(connection); |
| 157 return OK; | 158 return OK; |
| 158 } | 159 } |
| 159 | 160 |
| 160 void HttpServer::DoReadLoop(HttpConnection* connection) { | 161 void HttpServer::DoReadLoop(HttpConnection* connection) { |
| 161 int rv; | 162 int rv; |
| 162 do { | 163 do { |
| 163 HttpConnection::ReadIOBuffer* read_buf = connection->read_buf(); | 164 HttpConnection::ReadIOBuffer* read_buf = connection->read_buf(); |
| 164 // Increases read buffer size if necessary. | 165 // Increases read buffer size if necessary. |
| 165 if (read_buf->RemainingCapacity() == 0 && !read_buf->IncreaseCapacity()) { | 166 if (read_buf->RemainingCapacity() == 0 && !read_buf->IncreaseCapacity()) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 | 454 |
| 454 // This is called after any delegate callbacks are called to check if Close() | 455 // This is called after any delegate callbacks are called to check if Close() |
| 455 // has been called during callback processing. Using the pointer of connection, | 456 // has been called during callback processing. Using the pointer of connection, |
| 456 // |connection| is safe here because Close() deletes the connection in next run | 457 // |connection| is safe here because Close() deletes the connection in next run |
| 457 // loop. | 458 // loop. |
| 458 bool HttpServer::HasClosedConnection(HttpConnection* connection) { | 459 bool HttpServer::HasClosedConnection(HttpConnection* connection) { |
| 459 return FindConnection(connection->id()) != connection; | 460 return FindConnection(connection->id()) != connection; |
| 460 } | 461 } |
| 461 | 462 |
| 462 } // namespace net | 463 } // namespace net |
| OLD | NEW |