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

Side by Side Diff: chrome/browser/automation/url_request_automation_job.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
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 "chrome/browser/automation/url_request_automation_job.h" 5 #include "chrome/browser/automation/url_request_automation_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 bool URLRequestAutomationJob::IsRedirectResponse( 222 bool URLRequestAutomationJob::IsRedirectResponse(
223 GURL* location, int* http_status_code) { 223 GURL* location, int* http_status_code) {
224 if (!net::HttpResponseHeaders::IsRedirectResponseCode(redirect_status_)) 224 if (!net::HttpResponseHeaders::IsRedirectResponseCode(redirect_status_))
225 return false; 225 return false;
226 226
227 *http_status_code = redirect_status_; 227 *http_status_code = redirect_status_;
228 *location = GURL(redirect_url_); 228 *location = GURL(redirect_url_);
229 return true; 229 return true;
230 } 230 }
231 231
232 uint64 URLRequestAutomationJob::GetUploadProgress() const { 232 net::UploadProgress URLRequestAutomationJob::GetUploadProgress() const {
233 if (request_ && request_->status().is_success()) { 233 if (!request_)
234 return net::UploadProgress();
235
236 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
237 if (!info)
238 return net::UploadProgress();
239
240 const uint64 size = info->GetUploadSize();
241 if (request_->status().is_success()) {
234 // We don't support incremental progress notifications in ChromeFrame. When 242 // We don't support incremental progress notifications in ChromeFrame. When
235 // we receive a response for the POST request from Chromeframe, it means 243 // we receive a response for the POST request from Chromeframe, it means
236 // that the upload is fully complete. 244 // that the upload is fully complete.
237 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); 245 return net::UploadProgress(size, size);
238 if (info) {
239 return info->GetUploadSize();
240 }
241 } 246 }
242 return 0; 247 return net::UploadProgress(0, size);
243 } 248 }
244 249
245 net::HostPortPair URLRequestAutomationJob::GetSocketAddress() const { 250 net::HostPortPair URLRequestAutomationJob::GetSocketAddress() const {
246 return socket_address_; 251 return socket_address_;
247 } 252 }
248 253
249 bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message, 254 bool URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message,
250 int* request_id) { 255 int* request_id) {
251 switch (message.type()) { 256 switch (message.type()) {
252 case AutomationMsg_RequestStarted::ID: 257 case AutomationMsg_RequestStarted::ID:
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (!is_done()) { 490 if (!is_done()) {
486 NotifyDone(request_status_); 491 NotifyDone(request_status_);
487 } 492 }
488 // Reset any pending reads. 493 // Reset any pending reads.
489 if (pending_buf_) { 494 if (pending_buf_) {
490 pending_buf_ = NULL; 495 pending_buf_ = NULL;
491 pending_buf_size_ = 0; 496 pending_buf_size_ = 0;
492 NotifyReadComplete(0); 497 NotifyReadComplete(0);
493 } 498 }
494 } 499 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/url_request_automation_job.h ('k') | content/browser/renderer_host/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698