| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mojo/services/network/http_connection_impl.h" | 5 #include "mojo/services/network/http_connection_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 void HttpConnectionImpl::OnReceivedHttpRequest( | 134 void HttpConnectionImpl::OnReceivedHttpRequest( |
| 135 const net::HttpServerRequestInfo& info) { | 135 const net::HttpServerRequestInfo& info) { |
| 136 if (EncounteredConnectionError()) | 136 if (EncounteredConnectionError()) |
| 137 return; | 137 return; |
| 138 | 138 |
| 139 delegate_->OnReceivedRequest( | 139 delegate_->OnReceivedRequest( |
| 140 HttpRequest::From(info), [this](HttpResponsePtr response) { | 140 HttpRequest::From(info), [this](HttpResponsePtr response) { |
| 141 if (response->body.is_valid()) { | 141 if (response->body.is_valid()) { |
| 142 SimpleDataPipeReader* reader = new SimpleDataPipeReader; | 142 SimpleDataPipeReader* reader = new SimpleDataPipeReader; |
| 143 response_body_readers_.insert(reader); | 143 response_body_readers_.insert(reader); |
| 144 ScopedDataPipeConsumerHandle body = response->body.Pass(); |
| 144 reader->Start( | 145 reader->Start( |
| 145 response->body.Pass(), | 146 body.Pass(), |
| 146 base::Bind(&HttpConnectionImpl::OnFinishedReadingResponseBody, | 147 base::Bind(&HttpConnectionImpl::OnFinishedReadingResponseBody, |
| 147 base::Unretained(this), base::Passed(&response))); | 148 base::Unretained(this), base::Passed(&response))); |
| 148 } else { | 149 } else { |
| 149 OnFinishedReadingResponseBody(response.Pass(), nullptr, nullptr); | 150 OnFinishedReadingResponseBody(response.Pass(), nullptr, nullptr); |
| 150 } | 151 } |
| 151 }); | 152 }); |
| 152 } | 153 } |
| 153 | 154 |
| 154 void HttpConnectionImpl::OnReceivedWebSocketRequest( | 155 void HttpConnectionImpl::OnReceivedWebSocketRequest( |
| 155 const net::HttpServerRequestInfo& info) { | 156 const net::HttpServerRequestInfo& info) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 if (body) | 235 if (body) |
| 235 info.SetBody(*body, content_type); | 236 info.SetBody(*body, content_type); |
| 236 | 237 |
| 237 owner_->server()->SendResponse(connection_id_, info); | 238 owner_->server()->SendResponse(connection_id_, info); |
| 238 | 239 |
| 239 if (response_body_readers_.empty() && EncounteredConnectionError()) | 240 if (response_body_readers_.empty() && EncounteredConnectionError()) |
| 240 owner_->server()->Close(connection_id_); | 241 owner_->server()->Close(connection_id_); |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace mojo | 244 } // namespace mojo |
| OLD | NEW |