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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | 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 "net/url_request/url_fetcher_core.h" 5 #include "net/url_request/url_fetcher_core.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 15 matching lines...) Expand all
26 #include "net/url_request/url_request_context_getter.h" 26 #include "net/url_request/url_request_context_getter.h"
27 #include "net/url_request/url_request_throttler_manager.h" 27 #include "net/url_request/url_request_throttler_manager.h"
28 28
29 namespace { 29 namespace {
30 30
31 const int kBufferSize = 4096; 31 const int kBufferSize = 4096;
32 const int kUploadProgressTimerInterval = 100; 32 const int kUploadProgressTimerInterval = 100;
33 bool g_interception_enabled = false; 33 bool g_interception_enabled = false;
34 bool g_ignore_certificate_requests = false; 34 bool g_ignore_certificate_requests = false;
35 35
36 void EmptyCompletionCallback(int result) {} 36 void EmptyCompletionCallback(int result) {
37 }
37 38
38 } // namespace 39 } // namespace
39 40
40 namespace net { 41 namespace net {
41 42
42 // URLFetcherCore::Registry --------------------------------------------------- 43 // URLFetcherCore::Registry ---------------------------------------------------
43 44
44 URLFetcherCore::Registry::Registry() {} 45 URLFetcherCore::Registry::Registry() {
45 URLFetcherCore::Registry::~Registry() {} 46 }
47 URLFetcherCore::Registry::~Registry() {
48 }
46 49
47 void URLFetcherCore::Registry::AddURLFetcherCore(URLFetcherCore* core) { 50 void URLFetcherCore::Registry::AddURLFetcherCore(URLFetcherCore* core) {
48 DCHECK(!ContainsKey(fetchers_, core)); 51 DCHECK(!ContainsKey(fetchers_, core));
49 fetchers_.insert(core); 52 fetchers_.insert(core);
50 } 53 }
51 54
52 void URLFetcherCore::Registry::RemoveURLFetcherCore(URLFetcherCore* core) { 55 void URLFetcherCore::Registry::RemoveURLFetcherCore(URLFetcherCore* core) {
53 DCHECK(ContainsKey(fetchers_, core)); 56 DCHECK(ContainsKey(fetchers_, core));
54 fetchers_.erase(core); 57 fetchers_.erase(core);
55 } 58 }
56 59
57 void URLFetcherCore::Registry::CancelAll() { 60 void URLFetcherCore::Registry::CancelAll() {
58 while (!fetchers_.empty()) 61 while (!fetchers_.empty())
59 (*fetchers_.begin())->CancelURLRequest(ERR_ABORTED); 62 (*fetchers_.begin())->CancelURLRequest(ERR_ABORTED);
60 } 63 }
61 64
62 // URLFetcherCore ------------------------------------------------------------- 65 // URLFetcherCore -------------------------------------------------------------
63 66
64 // static 67 // static
65 base::LazyInstance<URLFetcherCore::Registry> 68 base::LazyInstance<URLFetcherCore::Registry> URLFetcherCore::g_registry =
66 URLFetcherCore::g_registry = LAZY_INSTANCE_INITIALIZER; 69 LAZY_INSTANCE_INITIALIZER;
67 70
68 URLFetcherCore::URLFetcherCore(URLFetcher* fetcher, 71 URLFetcherCore::URLFetcherCore(URLFetcher* fetcher,
69 const GURL& original_url, 72 const GURL& original_url,
70 URLFetcher::RequestType request_type, 73 URLFetcher::RequestType request_type,
71 URLFetcherDelegate* d) 74 URLFetcherDelegate* d)
72 : fetcher_(fetcher), 75 : fetcher_(fetcher),
73 original_url_(original_url), 76 original_url_(original_url),
74 request_type_(request_type), 77 request_type_(request_type),
75 delegate_(d), 78 delegate_(d),
76 delegate_task_runner_(base::ThreadTaskRunnerHandle::Get()), 79 delegate_task_runner_(base::ThreadTaskRunnerHandle::Get()),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 upload_content_type_ = upload_content_type; 168 upload_content_type_ = upload_content_type;
166 upload_file_path_ = file_path; 169 upload_file_path_ = file_path;
167 upload_range_offset_ = range_offset; 170 upload_range_offset_ = range_offset;
168 upload_range_length_ = range_length; 171 upload_range_length_ = range_length;
169 upload_file_task_runner_ = file_task_runner; 172 upload_file_task_runner_ = file_task_runner;
170 upload_content_set_ = true; 173 upload_content_set_ = true;
171 } 174 }
172 175
173 void URLFetcherCore::SetChunkedUpload(const std::string& content_type) { 176 void URLFetcherCore::SetChunkedUpload(const std::string& content_type) {
174 DCHECK(is_chunked_upload_ || 177 DCHECK(is_chunked_upload_ ||
175 (upload_content_type_.empty() && 178 (upload_content_type_.empty() && upload_content_.empty()));
176 upload_content_.empty()));
177 179
178 // Empty |content_type| is not allowed here, because it is impossible 180 // Empty |content_type| is not allowed here, because it is impossible
179 // to ensure non-empty upload content as it is not yet supplied. 181 // to ensure non-empty upload content as it is not yet supplied.
180 DCHECK(!content_type.empty()); 182 DCHECK(!content_type.empty());
181 183
182 upload_content_type_ = content_type; 184 upload_content_type_ = content_type;
183 upload_content_.clear(); 185 upload_content_.clear();
184 is_chunked_upload_ = true; 186 is_chunked_upload_ = true;
185 } 187 }
186 188
187 void URLFetcherCore::AppendChunkToUpload(const std::string& content, 189 void URLFetcherCore::AppendChunkToUpload(const std::string& content,
188 bool is_last_chunk) { 190 bool is_last_chunk) {
189 DCHECK(delegate_task_runner_.get()); 191 DCHECK(delegate_task_runner_.get());
190 DCHECK(network_task_runner_.get()); 192 DCHECK(network_task_runner_.get());
191 network_task_runner_->PostTask( 193 network_task_runner_->PostTask(
192 FROM_HERE, 194 FROM_HERE,
193 base::Bind(&URLFetcherCore::CompleteAddingUploadDataChunk, this, content, 195 base::Bind(&URLFetcherCore::CompleteAddingUploadDataChunk,
196 this,
197 content,
194 is_last_chunk)); 198 is_last_chunk));
195 } 199 }
196 200
197 void URLFetcherCore::SetLoadFlags(int load_flags) { 201 void URLFetcherCore::SetLoadFlags(int load_flags) {
198 load_flags_ = load_flags; 202 load_flags_ = load_flags;
199 } 203 }
200 204
201 int URLFetcherCore::GetLoadFlags() const { 205 int URLFetcherCore::GetLoadFlags() const {
202 return load_flags_; 206 return load_flags_;
203 } 207 }
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 DCHECK_EQ(request, request_.get()); 409 DCHECK_EQ(request, request_.get());
406 DCHECK(network_task_runner_->BelongsToCurrentThread()); 410 DCHECK(network_task_runner_->BelongsToCurrentThread());
407 411
408 if (g_ignore_certificate_requests) { 412 if (g_ignore_certificate_requests) {
409 request->ContinueWithCertificate(NULL); 413 request->ContinueWithCertificate(NULL);
410 } else { 414 } else {
411 request->Cancel(); 415 request->Cancel();
412 } 416 }
413 } 417 }
414 418
415 void URLFetcherCore::OnReadCompleted(URLRequest* request, 419 void URLFetcherCore::OnReadCompleted(URLRequest* request, int bytes_read) {
416 int bytes_read) {
417 DCHECK(request == request_); 420 DCHECK(request == request_);
418 DCHECK(network_task_runner_->BelongsToCurrentThread()); 421 DCHECK(network_task_runner_->BelongsToCurrentThread());
419 422
420 if (!stopped_on_redirect_) 423 if (!stopped_on_redirect_)
421 url_ = request->url(); 424 url_ = request->url();
422 URLRequestThrottlerManager* throttler_manager = 425 URLRequestThrottlerManager* throttler_manager =
423 request->context()->throttler_manager(); 426 request->context()->throttler_manager();
424 if (throttler_manager) { 427 if (throttler_manager) {
425 url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_); 428 url_throttler_entry_ = throttler_manager->RegisterRequestUrl(url_);
426 } 429 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 request_->set_stack_trace(stack_trace_); 514 request_->set_stack_trace(stack_trace_);
512 int flags = request_->load_flags() | load_flags_; 515 int flags = request_->load_flags() | load_flags_;
513 if (!g_interception_enabled) 516 if (!g_interception_enabled)
514 flags = flags | LOAD_DISABLE_INTERCEPT; 517 flags = flags | LOAD_DISABLE_INTERCEPT;
515 518
516 if (is_chunked_upload_) 519 if (is_chunked_upload_)
517 request_->EnableChunkedUpload(); 520 request_->EnableChunkedUpload();
518 request_->SetLoadFlags(flags); 521 request_->SetLoadFlags(flags);
519 request_->SetReferrer(referrer_); 522 request_->SetReferrer(referrer_);
520 request_->set_referrer_policy(referrer_policy_); 523 request_->set_referrer_policy(referrer_policy_);
521 request_->set_first_party_for_cookies(first_party_for_cookies_.is_empty() ? 524 request_->set_first_party_for_cookies(first_party_for_cookies_.is_empty()
522 original_url_ : first_party_for_cookies_); 525 ? original_url_
526 : first_party_for_cookies_);
523 if (url_request_data_key_ && !url_request_create_data_callback_.is_null()) { 527 if (url_request_data_key_ && !url_request_create_data_callback_.is_null()) {
524 request_->SetUserData(url_request_data_key_, 528 request_->SetUserData(url_request_data_key_,
525 url_request_create_data_callback_.Run()); 529 url_request_create_data_callback_.Run());
526 } 530 }
527 531
528 switch (request_type_) { 532 switch (request_type_) {
529 case URLFetcher::GET: 533 case URLFetcher::GET:
530 break; 534 break;
531 535
532 case URLFetcher::POST: 536 case URLFetcher::POST:
533 case URLFetcher::PUT: 537 case URLFetcher::PUT:
534 case URLFetcher::PATCH: 538 case URLFetcher::PATCH:
535 // Upload content must be set. 539 // Upload content must be set.
536 DCHECK(is_chunked_upload_ || upload_content_set_); 540 DCHECK(is_chunked_upload_ || upload_content_set_);
537 541
538 request_->set_method( 542 request_->set_method(request_type_ == URLFetcher::POST
539 request_type_ == URLFetcher::POST ? "POST" : 543 ? "POST"
540 request_type_ == URLFetcher::PUT ? "PUT" : "PATCH"); 544 : request_type_ == URLFetcher::PUT ? "PUT"
545 : "PATCH");
541 if (!upload_content_type_.empty()) { 546 if (!upload_content_type_.empty()) {
542 extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType, 547 extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType,
543 upload_content_type_); 548 upload_content_type_);
544 } 549 }
545 if (!upload_content_.empty()) { 550 if (!upload_content_.empty()) {
546 scoped_ptr<UploadElementReader> reader(new UploadBytesElementReader( 551 scoped_ptr<UploadElementReader> reader(new UploadBytesElementReader(
547 upload_content_.data(), upload_content_.size())); 552 upload_content_.data(), upload_content_.size()));
548 request_->set_upload(make_scoped_ptr( 553 request_->set_upload(make_scoped_ptr(
549 UploadDataStream::CreateWithReader(reader.Pass(), 0))); 554 UploadDataStream::CreateWithReader(reader.Pass(), 0)));
550 } else if (!upload_file_path_.empty()) { 555 } else if (!upload_file_path_.empty()) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 623 }
619 if (original_url_throttler_entry_.get() != NULL) { 624 if (original_url_throttler_entry_.get() != NULL) {
620 delay = original_url_throttler_entry_->ReserveSendingTimeForNextRequest( 625 delay = original_url_throttler_entry_->ReserveSendingTimeForNextRequest(
621 GetBackoffReleaseTime()); 626 GetBackoffReleaseTime());
622 } 627 }
623 628
624 if (delay == 0) { 629 if (delay == 0) {
625 StartURLRequest(); 630 StartURLRequest();
626 } else { 631 } else {
627 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 632 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
628 FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequest, this), 633 FROM_HERE,
634 base::Bind(&URLFetcherCore::StartURLRequest, this),
629 base::TimeDelta::FromMilliseconds(delay)); 635 base::TimeDelta::FromMilliseconds(delay));
630 } 636 }
631 } 637 }
632 638
633 void URLFetcherCore::CancelURLRequest(int error) { 639 void URLFetcherCore::CancelURLRequest(int error) {
634 DCHECK(network_task_runner_->BelongsToCurrentThread()); 640 DCHECK(network_task_runner_->BelongsToCurrentThread());
635 641
636 if (request_.get()) { 642 if (request_.get()) {
637 request_->CancelWithError(error); 643 request_->CancelWithError(error);
638 ReleaseRequest(); 644 ReleaseRequest();
(...skipping 12 matching lines...) Expand all
651 // references to URLFetcher::Core at this point so it may take a while to 657 // references to URLFetcher::Core at this point so it may take a while to
652 // delete the object, but we cannot delay the destruction of the request 658 // delete the object, but we cannot delay the destruction of the request
653 // context. 659 // context.
654 request_context_getter_ = NULL; 660 request_context_getter_ = NULL;
655 first_party_for_cookies_ = GURL(); 661 first_party_for_cookies_ = GURL();
656 url_request_data_key_ = NULL; 662 url_request_data_key_ = NULL;
657 url_request_create_data_callback_.Reset(); 663 url_request_create_data_callback_.Reset();
658 was_cancelled_ = true; 664 was_cancelled_ = true;
659 } 665 }
660 666
661 void URLFetcherCore::OnCompletedURLRequest( 667 void URLFetcherCore::OnCompletedURLRequest(base::TimeDelta backoff_delay) {
662 base::TimeDelta backoff_delay) {
663 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 668 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
664 669
665 // Save the status and backoff_delay so that delegates can read it. 670 // Save the status and backoff_delay so that delegates can read it.
666 if (delegate_) { 671 if (delegate_) {
667 backoff_delay_ = backoff_delay; 672 backoff_delay_ = backoff_delay;
668 InformDelegateFetchIsComplete(); 673 InformDelegateFetchIsComplete();
669 } 674 }
670 } 675 }
671 676
672 void URLFetcherCore::InformDelegateFetchIsComplete() { 677 void URLFetcherCore::InformDelegateFetchIsComplete() {
(...skipping 28 matching lines...) Expand all
701 } 706 }
702 // If the file was successfully closed, then the URL request is complete. 707 // If the file was successfully closed, then the URL request is complete.
703 RetryOrCompleteUrlFetch(); 708 RetryOrCompleteUrlFetch();
704 } 709 }
705 710
706 void URLFetcherCore::RetryOrCompleteUrlFetch() { 711 void URLFetcherCore::RetryOrCompleteUrlFetch() {
707 DCHECK(network_task_runner_->BelongsToCurrentThread()); 712 DCHECK(network_task_runner_->BelongsToCurrentThread());
708 base::TimeDelta backoff_delay; 713 base::TimeDelta backoff_delay;
709 714
710 // Checks the response from server. 715 // Checks the response from server.
711 if (response_code_ >= 500 || 716 if (response_code_ >= 500 || status_.error() == ERR_TEMPORARILY_THROTTLED) {
712 status_.error() == ERR_TEMPORARILY_THROTTLED) {
713 // When encountering a server error, we will send the request again 717 // When encountering a server error, we will send the request again
714 // after backoff time. 718 // after backoff time.
715 ++num_retries_on_5xx_; 719 ++num_retries_on_5xx_;
716 720
717 // Note that backoff_delay may be 0 because (a) the 721 // Note that backoff_delay may be 0 because (a) the
718 // URLRequestThrottlerManager and related code does not 722 // URLRequestThrottlerManager and related code does not
719 // necessarily back off on the first error, (b) it only backs off 723 // necessarily back off on the first error, (b) it only backs off
720 // on some of the 5xx status codes, (c) not all URLRequestContexts 724 // on some of the 5xx status codes, (c) not all URLRequestContexts
721 // have a throttler manager. 725 // have a throttler manager.
722 base::TimeTicks backoff_release_time = GetBackoffReleaseTime(); 726 base::TimeTicks backoff_release_time = GetBackoffReleaseTime();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 if (original_url_throttler_entry_.get()) { 774 if (original_url_throttler_entry_.get()) {
771 base::TimeTicks original_url_backoff = 775 base::TimeTicks original_url_backoff =
772 original_url_throttler_entry_->GetExponentialBackoffReleaseTime(); 776 original_url_throttler_entry_->GetExponentialBackoffReleaseTime();
773 base::TimeTicks destination_url_backoff; 777 base::TimeTicks destination_url_backoff;
774 if (url_throttler_entry_.get() != NULL && 778 if (url_throttler_entry_.get() != NULL &&
775 original_url_throttler_entry_.get() != url_throttler_entry_.get()) { 779 original_url_throttler_entry_.get() != url_throttler_entry_.get()) {
776 destination_url_backoff = 780 destination_url_backoff =
777 url_throttler_entry_->GetExponentialBackoffReleaseTime(); 781 url_throttler_entry_->GetExponentialBackoffReleaseTime();
778 } 782 }
779 783
780 return original_url_backoff > destination_url_backoff ? 784 return original_url_backoff > destination_url_backoff
781 original_url_backoff : destination_url_backoff; 785 ? original_url_backoff
786 : destination_url_backoff;
782 } else { 787 } else {
783 return base::TimeTicks(); 788 return base::TimeTicks();
784 } 789 }
785 } 790 }
786 791
787 void URLFetcherCore::CompleteAddingUploadDataChunk( 792 void URLFetcherCore::CompleteAddingUploadDataChunk(const std::string& content,
788 const std::string& content, bool is_last_chunk) { 793 bool is_last_chunk) {
789 if (was_cancelled_) { 794 if (was_cancelled_) {
790 // Since CompleteAddingUploadDataChunk() is posted as a *delayed* task, it 795 // Since CompleteAddingUploadDataChunk() is posted as a *delayed* task, it
791 // may run after the URLFetcher was already stopped. 796 // may run after the URLFetcher was already stopped.
792 return; 797 return;
793 } 798 }
794 DCHECK(is_chunked_upload_); 799 DCHECK(is_chunked_upload_);
795 DCHECK(request_.get()); 800 DCHECK(request_.get());
796 DCHECK(!content.empty()); 801 DCHECK(!content.empty());
797 request_->AppendChunkToUpload(content.data(), 802 request_->AppendChunkToUpload(
798 static_cast<int>(content.length()), 803 content.data(), static_cast<int>(content.length()), is_last_chunk);
799 is_last_chunk);
800 } 804 }
801 805
802 int URLFetcherCore::WriteBuffer(scoped_refptr<DrainableIOBuffer> data) { 806 int URLFetcherCore::WriteBuffer(scoped_refptr<DrainableIOBuffer> data) {
803 while (data->BytesRemaining() > 0) { 807 while (data->BytesRemaining() > 0) {
804 const int result = response_writer_->Write( 808 const int result = response_writer_->Write(
805 data.get(), 809 data.get(),
806 data->BytesRemaining(), 810 data->BytesRemaining(),
807 base::Bind(&URLFetcherCore::DidWriteBuffer, this, data)); 811 base::Bind(&URLFetcherCore::DidWriteBuffer, this, data));
808 if (result < 0) { 812 if (result < 0) {
809 if (result != ERR_IO_PENDING) 813 if (result != ERR_IO_PENDING)
(...skipping 27 matching lines...) Expand all
837 if (request_.get()) 841 if (request_.get())
838 ReadResponse(); 842 ReadResponse();
839 } 843 }
840 844
841 void URLFetcherCore::ReadResponse() { 845 void URLFetcherCore::ReadResponse() {
842 // Some servers may treat HEAD requests as GET requests. To free up the 846 // Some servers may treat HEAD requests as GET requests. To free up the
843 // network connection as soon as possible, signal that the request has 847 // network connection as soon as possible, signal that the request has
844 // completed immediately, without trying to read any data back (all we care 848 // completed immediately, without trying to read any data back (all we care
845 // about is the response code and headers, which we already have). 849 // about is the response code and headers, which we already have).
846 int bytes_read = 0; 850 int bytes_read = 0;
847 if (request_->status().is_success() && 851 if (request_->status().is_success() && (request_type_ != URLFetcher::HEAD))
848 (request_type_ != URLFetcher::HEAD))
849 request_->Read(buffer_.get(), kBufferSize, &bytes_read); 852 request_->Read(buffer_.get(), kBufferSize, &bytes_read);
850 OnReadCompleted(request_.get(), bytes_read); 853 OnReadCompleted(request_.get(), bytes_read);
851 } 854 }
852 855
853 void URLFetcherCore::InformDelegateUploadProgress() { 856 void URLFetcherCore::InformDelegateUploadProgress() {
854 DCHECK(network_task_runner_->BelongsToCurrentThread()); 857 DCHECK(network_task_runner_->BelongsToCurrentThread());
855 if (request_.get()) { 858 if (request_.get()) {
856 int64 current = request_->GetUploadProgress().position(); 859 int64 current = request_->GetUploadProgress().position();
857 if (current_upload_bytes_ != current) { 860 if (current_upload_bytes_ != current) {
858 current_upload_bytes_ = current; 861 current_upload_bytes_ = current;
859 int64 total = -1; 862 int64 total = -1;
860 if (!is_chunked_upload_) { 863 if (!is_chunked_upload_) {
861 total = static_cast<int64>(request_->GetUploadProgress().size()); 864 total = static_cast<int64>(request_->GetUploadProgress().size());
862 // Total may be zero if the UploadDataStream::Init has not been called 865 // Total may be zero if the UploadDataStream::Init has not been called
863 // yet. Don't send the upload progress until the size is initialized. 866 // yet. Don't send the upload progress until the size is initialized.
864 if (!total) 867 if (!total)
865 return; 868 return;
866 } 869 }
867 delegate_task_runner_->PostTask( 870 delegate_task_runner_->PostTask(
868 FROM_HERE, 871 FROM_HERE,
869 base::Bind( 872 base::Bind(
870 &URLFetcherCore::InformDelegateUploadProgressInDelegateThread, 873 &URLFetcherCore::InformDelegateUploadProgressInDelegateThread,
871 this, current, total)); 874 this,
875 current,
876 total));
872 } 877 }
873 } 878 }
874 } 879 }
875 880
876 void URLFetcherCore::InformDelegateUploadProgressInDelegateThread( 881 void URLFetcherCore::InformDelegateUploadProgressInDelegateThread(int64 current,
877 int64 current, int64 total) { 882 int64 total) {
878 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 883 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
879 if (delegate_) 884 if (delegate_)
880 delegate_->OnURLFetchUploadProgress(fetcher_, current, total); 885 delegate_->OnURLFetchUploadProgress(fetcher_, current, total);
881 } 886 }
882 887
883 void URLFetcherCore::InformDelegateDownloadProgress() { 888 void URLFetcherCore::InformDelegateDownloadProgress() {
884 DCHECK(network_task_runner_->BelongsToCurrentThread()); 889 DCHECK(network_task_runner_->BelongsToCurrentThread());
885 delegate_task_runner_->PostTask( 890 delegate_task_runner_->PostTask(
886 FROM_HERE, 891 FROM_HERE,
887 base::Bind( 892 base::Bind(
888 &URLFetcherCore::InformDelegateDownloadProgressInDelegateThread, 893 &URLFetcherCore::InformDelegateDownloadProgressInDelegateThread,
889 this, current_response_bytes_, total_response_bytes_)); 894 this,
895 current_response_bytes_,
896 total_response_bytes_));
890 } 897 }
891 898
892 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( 899 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread(
893 int64 current, int64 total) { 900 int64 current,
901 int64 total) {
894 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 902 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
895 if (delegate_) 903 if (delegate_)
896 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); 904 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total);
897 } 905 }
898 906
899 } // namespace net 907 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698