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

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

Issue 10830182: net: Return size of upload as well as position from URLRequest::GetUploadProgress() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _ Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_ftp_job.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 : context_(context), 139 : context_(context),
140 net_log_(BoundNetLog::Make(context->net_log(), 140 net_log_(BoundNetLog::Make(context->net_log(),
141 NetLog::SOURCE_URL_REQUEST)), 141 NetLog::SOURCE_URL_REQUEST)),
142 url_chain_(1, url), 142 url_chain_(1, url),
143 method_("GET"), 143 method_("GET"),
144 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE), 144 referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
145 load_flags_(LOAD_NORMAL), 145 load_flags_(LOAD_NORMAL),
146 delegate_(delegate), 146 delegate_(delegate),
147 is_pending_(false), 147 is_pending_(false),
148 redirect_limit_(kMaxRedirects), 148 redirect_limit_(kMaxRedirects),
149 final_upload_progress_(0),
150 priority_(LOWEST), 149 priority_(LOWEST),
151 identifier_(GenerateURLRequestIdentifier()), 150 identifier_(GenerateURLRequestIdentifier()),
152 blocked_on_delegate_(false), 151 blocked_on_delegate_(false),
153 ALLOW_THIS_IN_INITIALIZER_LIST(before_request_callback_( 152 ALLOW_THIS_IN_INITIALIZER_LIST(before_request_callback_(
154 base::Bind(&URLRequest::BeforeRequestComplete, 153 base::Bind(&URLRequest::BeforeRequestComplete,
155 base::Unretained(this)))), 154 base::Unretained(this)))),
156 has_notified_completion_(false), 155 has_notified_completion_(false),
157 creation_time_(base::TimeTicks::Now()) { 156 creation_time_(base::TimeTicks::Now()) {
158 SIMPLE_STATS_COUNTER("URLRequestCount"); 157 SIMPLE_STATS_COUNTER("URLRequestCount");
159 158
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 278
280 LoadStateWithParam URLRequest::GetLoadState() const { 279 LoadStateWithParam URLRequest::GetLoadState() const {
281 if (blocked_on_delegate_) { 280 if (blocked_on_delegate_) {
282 return LoadStateWithParam(LOAD_STATE_WAITING_FOR_DELEGATE, 281 return LoadStateWithParam(LOAD_STATE_WAITING_FOR_DELEGATE,
283 load_state_param_); 282 load_state_param_);
284 } 283 }
285 return LoadStateWithParam(job_ ? job_->GetLoadState() : LOAD_STATE_IDLE, 284 return LoadStateWithParam(job_ ? job_->GetLoadState() : LOAD_STATE_IDLE,
286 string16()); 285 string16());
287 } 286 }
288 287
289 uint64 URLRequest::GetUploadProgress() const { 288 UploadProgress URLRequest::GetUploadProgress() const {
290 if (!job_) { 289 if (!job_) {
291 // We haven't started or the request was cancelled 290 // We haven't started or the request was cancelled
292 return 0; 291 return UploadProgress();
293 } 292 }
294 if (final_upload_progress_) { 293 if (final_upload_progress_.position) {
295 // The first job completed and none of the subsequent series of 294 // The first job completed and none of the subsequent series of
296 // GETs when following redirects will upload anything, so we return the 295 // GETs when following redirects will upload anything, so we return the
297 // cached results from the initial job, the POST. 296 // cached results from the initial job, the POST.
298 return final_upload_progress_; 297 return final_upload_progress_;
299 } 298 }
300 return job_->GetUploadProgress(); 299 return job_->GetUploadProgress();
301 } 300 }
302 301
303 void URLRequest::GetResponseHeaderById(int id, string* value) { 302 void URLRequest::GetResponseHeaderById(int id, string* value) {
304 DCHECK(job_); 303 DCHECK(job_);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 // Suppress the referrer if we're redirecting out of https. 736 // Suppress the referrer if we're redirecting out of https.
738 if (referrer_policy_ == 737 if (referrer_policy_ ==
739 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE && 738 CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE &&
740 GURL(referrer_).SchemeIsSecure() && !location.SchemeIsSecure()) { 739 GURL(referrer_).SchemeIsSecure() && !location.SchemeIsSecure()) {
741 referrer_.clear(); 740 referrer_.clear();
742 } 741 }
743 742
744 url_chain_.push_back(location); 743 url_chain_.push_back(location);
745 --redirect_limit_; 744 --redirect_limit_;
746 745
747 if (!final_upload_progress_) 746 if (!final_upload_progress_.position)
748 final_upload_progress_ = job_->GetUploadProgress(); 747 final_upload_progress_ = job_->GetUploadProgress();
749 748
750 PrepareToRestart(); 749 PrepareToRestart();
751 Start(); 750 Start();
752 return OK; 751 return OK;
753 } 752 }
754 753
755 const URLRequestContext* URLRequest::context() const { 754 const URLRequestContext* URLRequest::context() const {
756 return context_; 755 return context_;
757 } 756 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 new base::debug::StackTrace(NULL, 0); 920 new base::debug::StackTrace(NULL, 0);
922 *stack_trace_copy = stack_trace; 921 *stack_trace_copy = stack_trace;
923 stack_trace_.reset(stack_trace_copy); 922 stack_trace_.reset(stack_trace_copy);
924 } 923 }
925 924
926 const base::debug::StackTrace* URLRequest::stack_trace() const { 925 const base::debug::StackTrace* URLRequest::stack_trace() const {
927 return stack_trace_.get(); 926 return stack_trace_.get();
928 } 927 }
929 928
930 } // namespace net 929 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_ftp_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698