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

Side by Side Diff: net/url_request/url_request.cc

Issue 2298823002: Resetting the HttpRequestInfo pointers in HttpNetworkTransaction and streams (Closed)
Patch Set: Rebased, removed upload progress plumbing, feedback. (Rebased till refs/heads/master@{#417381}) Created 4 years, 3 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
OLDNEW
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/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 if (!job_.get()) { 355 if (!job_.get()) {
356 // We haven't started or the request was cancelled 356 // We haven't started or the request was cancelled
357 return UploadProgress(); 357 return UploadProgress();
358 } 358 }
359 if (final_upload_progress_.position()) { 359 if (final_upload_progress_.position()) {
360 // The first job completed and none of the subsequent series of 360 // The first job completed and none of the subsequent series of
361 // GETs when following redirects will upload anything, so we return the 361 // GETs when following redirects will upload anything, so we return the
362 // cached results from the initial job, the POST. 362 // cached results from the initial job, the POST.
363 return final_upload_progress_; 363 return final_upload_progress_;
364 } 364 }
365 return job_->GetUploadProgress(); 365 if (upload_data_stream_) {
366 return upload_data_stream_->GetUploadProgress();
367 }
368 return UploadProgress();
366 } 369 }
367 370
368 void URLRequest::GetResponseHeaderByName(const string& name, 371 void URLRequest::GetResponseHeaderByName(const string& name,
369 string* value) const { 372 string* value) const {
370 DCHECK(value); 373 DCHECK(value);
371 if (response_info_.headers.get()) { 374 if (response_info_.headers.get()) {
372 response_info_.headers->GetNormalizedHeader(name, value); 375 response_info_.headers->GetNormalizedHeader(name, value);
373 } else { 376 } else {
374 value->clear(); 377 value->clear();
375 } 378 }
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 } 957 }
955 958
956 if (!redirect_info.new_url.is_valid()) 959 if (!redirect_info.new_url.is_valid())
957 return ERR_INVALID_URL; 960 return ERR_INVALID_URL;
958 961
959 if (!job_->IsSafeRedirect(redirect_info.new_url)) { 962 if (!job_->IsSafeRedirect(redirect_info.new_url)) {
960 DVLOG(1) << "disallowing redirect: unsafe protocol"; 963 DVLOG(1) << "disallowing redirect: unsafe protocol";
961 return ERR_UNSAFE_REDIRECT; 964 return ERR_UNSAFE_REDIRECT;
962 } 965 }
963 966
964 if (!final_upload_progress_.position()) 967 if (!final_upload_progress_.position() && upload_data_stream_)
965 final_upload_progress_ = job_->GetUploadProgress(); 968 final_upload_progress_ = upload_data_stream_->GetUploadProgress();
966 PrepareToRestart(); 969 PrepareToRestart();
967 970
968 if (redirect_info.new_method != method_) { 971 if (redirect_info.new_method != method_) {
969 // TODO(davidben): This logic still needs to be replicated at the consumers. 972 // TODO(davidben): This logic still needs to be replicated at the consumers.
970 if (method_ == "POST") { 973 if (method_ == "POST") {
971 // If being switched from POST, must remove Origin header. 974 // If being switched from POST, must remove Origin header.
972 // TODO(jww): This is Origin header removal is probably layering violation 975 // TODO(jww): This is Origin header removal is probably layering violation
973 // and 976 // and
974 // should be refactored into //content. See https://crbug.com/471397. 977 // should be refactored into //content. See https://crbug.com/471397.
975 extra_request_headers_.RemoveHeader(HttpRequestHeaders::kOrigin); 978 extra_request_headers_.RemoveHeader(HttpRequestHeaders::kOrigin);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1234 out->clear(); 1237 out->clear();
1235 } 1238 }
1236 1239
1237 void URLRequest::set_status(URLRequestStatus status) { 1240 void URLRequest::set_status(URLRequestStatus status) {
1238 DCHECK(status_.is_io_pending() || status_.is_success() || 1241 DCHECK(status_.is_io_pending() || status_.is_success() ||
1239 (!status.is_success() && !status.is_io_pending())); 1242 (!status.is_success() && !status.is_io_pending()));
1240 status_ = status; 1243 status_ = status;
1241 } 1244 }
1242 1245
1243 } // namespace net 1246 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698