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

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

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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 | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_fetcher_delegate.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_fetcher_core.h" 5 #include "net/url_request/url_fetcher_core.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 DCHECK(upload_content.empty() || !upload_content_type.empty()); 148 DCHECK(upload_content.empty() || !upload_content_type.empty());
149 149
150 upload_content_type_ = upload_content_type; 150 upload_content_type_ = upload_content_type;
151 upload_content_ = upload_content; 151 upload_content_ = upload_content;
152 upload_content_set_ = true; 152 upload_content_set_ = true;
153 } 153 }
154 154
155 void URLFetcherCore::SetUploadFilePath( 155 void URLFetcherCore::SetUploadFilePath(
156 const std::string& upload_content_type, 156 const std::string& upload_content_type,
157 const base::FilePath& file_path, 157 const base::FilePath& file_path,
158 uint64 range_offset, 158 uint64_t range_offset,
159 uint64 range_length, 159 uint64_t range_length,
160 scoped_refptr<base::TaskRunner> file_task_runner) { 160 scoped_refptr<base::TaskRunner> file_task_runner) {
161 AssertHasNoUploadData(); 161 AssertHasNoUploadData();
162 DCHECK(!is_chunked_upload_); 162 DCHECK(!is_chunked_upload_);
163 DCHECK_EQ(upload_range_offset_, 0ULL); 163 DCHECK_EQ(upload_range_offset_, 0ULL);
164 DCHECK_EQ(upload_range_length_, 0ULL); 164 DCHECK_EQ(upload_range_length_, 0ULL);
165 DCHECK(upload_content_type_.empty()); 165 DCHECK(upload_content_type_.empty());
166 DCHECK(!upload_content_type.empty()); 166 DCHECK(!upload_content_type.empty());
167 167
168 upload_content_type_ = upload_content_type; 168 upload_content_type_ = upload_content_type;
169 upload_file_path_ = file_path; 169 upload_file_path_ = file_path;
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 // If the context has been shut down, or there's no ThrottlerManager, just 652 // If the context has been shut down, or there's no ThrottlerManager, just
653 // start the request. In the former case, StartURLRequest() will just inform 653 // start the request. In the former case, StartURLRequest() will just inform
654 // the URLFetcher::Delegate the request has been canceled. 654 // the URLFetcher::Delegate the request has been canceled.
655 if (context && context->throttler_manager()) { 655 if (context && context->throttler_manager()) {
656 if (!original_url_throttler_entry_.get()) { 656 if (!original_url_throttler_entry_.get()) {
657 original_url_throttler_entry_ = 657 original_url_throttler_entry_ =
658 context->throttler_manager()->RegisterRequestUrl(original_url_); 658 context->throttler_manager()->RegisterRequestUrl(original_url_);
659 } 659 }
660 660
661 if (original_url_throttler_entry_.get()) { 661 if (original_url_throttler_entry_.get()) {
662 int64 delay = 662 int64_t delay =
663 original_url_throttler_entry_->ReserveSendingTimeForNextRequest( 663 original_url_throttler_entry_->ReserveSendingTimeForNextRequest(
664 GetBackoffReleaseTime()); 664 GetBackoffReleaseTime());
665 if (delay != 0) { 665 if (delay != 0) {
666 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 666 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
667 FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequest, this), 667 FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequest, this),
668 base::TimeDelta::FromMilliseconds(delay)); 668 base::TimeDelta::FromMilliseconds(delay));
669 return; 669 return;
670 } 670 }
671 } 671 }
672 } 672 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 (request_type_ != URLFetcher::HEAD)) { 892 (request_type_ != URLFetcher::HEAD)) {
893 if (!request_->Read(buffer_.get(), kBufferSize, &bytes_read)) 893 if (!request_->Read(buffer_.get(), kBufferSize, &bytes_read))
894 bytes_read = -1; // Match OnReadCompleted() interface contract. 894 bytes_read = -1; // Match OnReadCompleted() interface contract.
895 } 895 }
896 OnReadCompleted(request_.get(), bytes_read); 896 OnReadCompleted(request_.get(), bytes_read);
897 } 897 }
898 898
899 void URLFetcherCore::InformDelegateUploadProgress() { 899 void URLFetcherCore::InformDelegateUploadProgress() {
900 DCHECK(network_task_runner_->BelongsToCurrentThread()); 900 DCHECK(network_task_runner_->BelongsToCurrentThread());
901 if (request_.get()) { 901 if (request_.get()) {
902 int64 current = request_->GetUploadProgress().position(); 902 int64_t current = request_->GetUploadProgress().position();
903 if (current_upload_bytes_ != current) { 903 if (current_upload_bytes_ != current) {
904 current_upload_bytes_ = current; 904 current_upload_bytes_ = current;
905 int64 total = -1; 905 int64_t total = -1;
906 if (!is_chunked_upload_) { 906 if (!is_chunked_upload_) {
907 total = static_cast<int64>(request_->GetUploadProgress().size()); 907 total = static_cast<int64_t>(request_->GetUploadProgress().size());
908 // Total may be zero if the UploadDataStream::Init has not been called 908 // Total may be zero if the UploadDataStream::Init has not been called
909 // yet. Don't send the upload progress until the size is initialized. 909 // yet. Don't send the upload progress until the size is initialized.
910 if (!total) 910 if (!total)
911 return; 911 return;
912 } 912 }
913 delegate_task_runner_->PostTask( 913 delegate_task_runner_->PostTask(
914 FROM_HERE, 914 FROM_HERE,
915 base::Bind( 915 base::Bind(
916 &URLFetcherCore::InformDelegateUploadProgressInDelegateThread, 916 &URLFetcherCore::InformDelegateUploadProgressInDelegateThread,
917 this, current, total)); 917 this, current, total));
918 } 918 }
919 } 919 }
920 } 920 }
921 921
922 void URLFetcherCore::InformDelegateUploadProgressInDelegateThread( 922 void URLFetcherCore::InformDelegateUploadProgressInDelegateThread(
923 int64 current, int64 total) { 923 int64_t current,
924 int64_t total) {
924 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 925 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
925 if (delegate_) 926 if (delegate_)
926 delegate_->OnURLFetchUploadProgress(fetcher_, current, total); 927 delegate_->OnURLFetchUploadProgress(fetcher_, current, total);
927 } 928 }
928 929
929 void URLFetcherCore::InformDelegateDownloadProgress() { 930 void URLFetcherCore::InformDelegateDownloadProgress() {
930 DCHECK(network_task_runner_->BelongsToCurrentThread()); 931 DCHECK(network_task_runner_->BelongsToCurrentThread());
931 932
932 // TODO(pkasting): Remove ScopedTracker below once crbug.com/455952 is fixed. 933 // TODO(pkasting): Remove ScopedTracker below once crbug.com/455952 is fixed.
933 tracked_objects::ScopedTracker tracking_profile2( 934 tracked_objects::ScopedTracker tracking_profile2(
934 FROM_HERE_WITH_EXPLICIT_FUNCTION( 935 FROM_HERE_WITH_EXPLICIT_FUNCTION(
935 "455952 delegate_task_runner_->PostTask()")); 936 "455952 delegate_task_runner_->PostTask()"));
936 937
937 delegate_task_runner_->PostTask( 938 delegate_task_runner_->PostTask(
938 FROM_HERE, 939 FROM_HERE,
939 base::Bind( 940 base::Bind(
940 &URLFetcherCore::InformDelegateDownloadProgressInDelegateThread, 941 &URLFetcherCore::InformDelegateDownloadProgressInDelegateThread,
941 this, current_response_bytes_, total_response_bytes_)); 942 this, current_response_bytes_, total_response_bytes_));
942 } 943 }
943 944
944 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread( 945 void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread(
945 int64 current, int64 total) { 946 int64_t current,
947 int64_t total) {
946 DCHECK(delegate_task_runner_->BelongsToCurrentThread()); 948 DCHECK(delegate_task_runner_->BelongsToCurrentThread());
947 if (delegate_) 949 if (delegate_)
948 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total); 950 delegate_->OnURLFetchDownloadProgress(fetcher_, current, total);
949 } 951 }
950 952
951 void URLFetcherCore::AssertHasNoUploadData() const { 953 void URLFetcherCore::AssertHasNoUploadData() const {
952 DCHECK(!upload_content_set_); 954 DCHECK(!upload_content_set_);
953 DCHECK(upload_content_.empty()); 955 DCHECK(upload_content_.empty());
954 DCHECK(upload_file_path_.empty()); 956 DCHECK(upload_file_path_.empty());
955 DCHECK(upload_stream_factory_.is_null()); 957 DCHECK(upload_stream_factory_.is_null());
956 } 958 }
957 959
958 } // namespace net 960 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_fetcher_core.h ('k') | net/url_request/url_fetcher_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698