Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Side by Side Diff: mojo/services/network/http_connection_impl.cc

Issue 1138443004: Fix crash in network_service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698