| Index: net/url_request/url_fetcher_core.cc
|
| diff --git a/net/url_request/url_fetcher_core.cc b/net/url_request/url_fetcher_core.cc
|
| index eb45ecf52e3755789f2d1fd2a2de27646d8cdc71..b3c3e9571e2f73e20bf17c0161d9bafb4568fc80 100644
|
| --- a/net/url_request/url_fetcher_core.cc
|
| +++ b/net/url_request/url_fetcher_core.cc
|
| @@ -33,7 +33,8 @@ const int kUploadProgressTimerInterval = 100;
|
| bool g_interception_enabled = false;
|
| bool g_ignore_certificate_requests = false;
|
|
|
| -void EmptyCompletionCallback(int result) {}
|
| +void EmptyCompletionCallback(int result) {
|
| +}
|
|
|
| } // namespace
|
|
|
| @@ -41,8 +42,10 @@ namespace net {
|
|
|
| // URLFetcherCore::Registry ---------------------------------------------------
|
|
|
| -URLFetcherCore::Registry::Registry() {}
|
| -URLFetcherCore::Registry::~Registry() {}
|
| +URLFetcherCore::Registry::Registry() {
|
| +}
|
| +URLFetcherCore::Registry::~Registry() {
|
| +}
|
|
|
| void URLFetcherCore::Registry::AddURLFetcherCore(URLFetcherCore* core) {
|
| DCHECK(!ContainsKey(fetchers_, core));
|
| @@ -62,8 +65,8 @@ void URLFetcherCore::Registry::CancelAll() {
|
| // URLFetcherCore -------------------------------------------------------------
|
|
|
| // static
|
| -base::LazyInstance<URLFetcherCore::Registry>
|
| - URLFetcherCore::g_registry = LAZY_INSTANCE_INITIALIZER;
|
| +base::LazyInstance<URLFetcherCore::Registry> URLFetcherCore::g_registry =
|
| + LAZY_INSTANCE_INITIALIZER;
|
|
|
| URLFetcherCore::URLFetcherCore(URLFetcher* fetcher,
|
| const GURL& original_url,
|
| @@ -172,8 +175,7 @@ void URLFetcherCore::SetUploadFilePath(
|
|
|
| void URLFetcherCore::SetChunkedUpload(const std::string& content_type) {
|
| DCHECK(is_chunked_upload_ ||
|
| - (upload_content_type_.empty() &&
|
| - upload_content_.empty()));
|
| + (upload_content_type_.empty() && upload_content_.empty()));
|
|
|
| // Empty |content_type| is not allowed here, because it is impossible
|
| // to ensure non-empty upload content as it is not yet supplied.
|
| @@ -190,7 +192,9 @@ void URLFetcherCore::AppendChunkToUpload(const std::string& content,
|
| DCHECK(network_task_runner_.get());
|
| network_task_runner_->PostTask(
|
| FROM_HERE,
|
| - base::Bind(&URLFetcherCore::CompleteAddingUploadDataChunk, this, content,
|
| + base::Bind(&URLFetcherCore::CompleteAddingUploadDataChunk,
|
| + this,
|
| + content,
|
| is_last_chunk));
|
| }
|
|
|
| @@ -412,8 +416,7 @@ void URLFetcherCore::OnCertificateRequested(
|
| }
|
| }
|
|
|
| -void URLFetcherCore::OnReadCompleted(URLRequest* request,
|
| - int bytes_read) {
|
| +void URLFetcherCore::OnReadCompleted(URLRequest* request, int bytes_read) {
|
| DCHECK(request == request_);
|
| DCHECK(network_task_runner_->BelongsToCurrentThread());
|
|
|
| @@ -518,8 +521,9 @@ void URLFetcherCore::StartURLRequest() {
|
| request_->SetLoadFlags(flags);
|
| request_->SetReferrer(referrer_);
|
| request_->set_referrer_policy(referrer_policy_);
|
| - request_->set_first_party_for_cookies(first_party_for_cookies_.is_empty() ?
|
| - original_url_ : first_party_for_cookies_);
|
| + request_->set_first_party_for_cookies(first_party_for_cookies_.is_empty()
|
| + ? original_url_
|
| + : first_party_for_cookies_);
|
| if (url_request_data_key_ && !url_request_create_data_callback_.is_null()) {
|
| request_->SetUserData(url_request_data_key_,
|
| url_request_create_data_callback_.Run());
|
| @@ -535,9 +539,10 @@ void URLFetcherCore::StartURLRequest() {
|
| // Upload content must be set.
|
| DCHECK(is_chunked_upload_ || upload_content_set_);
|
|
|
| - request_->set_method(
|
| - request_type_ == URLFetcher::POST ? "POST" :
|
| - request_type_ == URLFetcher::PUT ? "PUT" : "PATCH");
|
| + request_->set_method(request_type_ == URLFetcher::POST
|
| + ? "POST"
|
| + : request_type_ == URLFetcher::PUT ? "PUT"
|
| + : "PATCH");
|
| if (!upload_content_type_.empty()) {
|
| extra_request_headers_.SetHeader(HttpRequestHeaders::kContentType,
|
| upload_content_type_);
|
| @@ -625,7 +630,8 @@ void URLFetcherCore::StartURLRequestWhenAppropriate() {
|
| StartURLRequest();
|
| } else {
|
| base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
| - FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequest, this),
|
| + FROM_HERE,
|
| + base::Bind(&URLFetcherCore::StartURLRequest, this),
|
| base::TimeDelta::FromMilliseconds(delay));
|
| }
|
| }
|
| @@ -658,8 +664,7 @@ void URLFetcherCore::CancelURLRequest(int error) {
|
| was_cancelled_ = true;
|
| }
|
|
|
| -void URLFetcherCore::OnCompletedURLRequest(
|
| - base::TimeDelta backoff_delay) {
|
| +void URLFetcherCore::OnCompletedURLRequest(base::TimeDelta backoff_delay) {
|
| DCHECK(delegate_task_runner_->BelongsToCurrentThread());
|
|
|
| // Save the status and backoff_delay so that delegates can read it.
|
| @@ -708,8 +713,7 @@ void URLFetcherCore::RetryOrCompleteUrlFetch() {
|
| base::TimeDelta backoff_delay;
|
|
|
| // Checks the response from server.
|
| - if (response_code_ >= 500 ||
|
| - status_.error() == ERR_TEMPORARILY_THROTTLED) {
|
| + if (response_code_ >= 500 || status_.error() == ERR_TEMPORARILY_THROTTLED) {
|
| // When encountering a server error, we will send the request again
|
| // after backoff time.
|
| ++num_retries_on_5xx_;
|
| @@ -777,15 +781,16 @@ base::TimeTicks URLFetcherCore::GetBackoffReleaseTime() {
|
| url_throttler_entry_->GetExponentialBackoffReleaseTime();
|
| }
|
|
|
| - return original_url_backoff > destination_url_backoff ?
|
| - original_url_backoff : destination_url_backoff;
|
| + return original_url_backoff > destination_url_backoff
|
| + ? original_url_backoff
|
| + : destination_url_backoff;
|
| } else {
|
| return base::TimeTicks();
|
| }
|
| }
|
|
|
| -void URLFetcherCore::CompleteAddingUploadDataChunk(
|
| - const std::string& content, bool is_last_chunk) {
|
| +void URLFetcherCore::CompleteAddingUploadDataChunk(const std::string& content,
|
| + bool is_last_chunk) {
|
| if (was_cancelled_) {
|
| // Since CompleteAddingUploadDataChunk() is posted as a *delayed* task, it
|
| // may run after the URLFetcher was already stopped.
|
| @@ -794,9 +799,8 @@ void URLFetcherCore::CompleteAddingUploadDataChunk(
|
| DCHECK(is_chunked_upload_);
|
| DCHECK(request_.get());
|
| DCHECK(!content.empty());
|
| - request_->AppendChunkToUpload(content.data(),
|
| - static_cast<int>(content.length()),
|
| - is_last_chunk);
|
| + request_->AppendChunkToUpload(
|
| + content.data(), static_cast<int>(content.length()), is_last_chunk);
|
| }
|
|
|
| int URLFetcherCore::WriteBuffer(scoped_refptr<DrainableIOBuffer> data) {
|
| @@ -844,8 +848,7 @@ void URLFetcherCore::ReadResponse() {
|
| // completed immediately, without trying to read any data back (all we care
|
| // about is the response code and headers, which we already have).
|
| int bytes_read = 0;
|
| - if (request_->status().is_success() &&
|
| - (request_type_ != URLFetcher::HEAD))
|
| + if (request_->status().is_success() && (request_type_ != URLFetcher::HEAD))
|
| request_->Read(buffer_.get(), kBufferSize, &bytes_read);
|
| OnReadCompleted(request_.get(), bytes_read);
|
| }
|
| @@ -868,13 +871,15 @@ void URLFetcherCore::InformDelegateUploadProgress() {
|
| FROM_HERE,
|
| base::Bind(
|
| &URLFetcherCore::InformDelegateUploadProgressInDelegateThread,
|
| - this, current, total));
|
| + this,
|
| + current,
|
| + total));
|
| }
|
| }
|
| }
|
|
|
| -void URLFetcherCore::InformDelegateUploadProgressInDelegateThread(
|
| - int64 current, int64 total) {
|
| +void URLFetcherCore::InformDelegateUploadProgressInDelegateThread(int64 current,
|
| + int64 total) {
|
| DCHECK(delegate_task_runner_->BelongsToCurrentThread());
|
| if (delegate_)
|
| delegate_->OnURLFetchUploadProgress(fetcher_, current, total);
|
| @@ -886,11 +891,14 @@ void URLFetcherCore::InformDelegateDownloadProgress() {
|
| FROM_HERE,
|
| base::Bind(
|
| &URLFetcherCore::InformDelegateDownloadProgressInDelegateThread,
|
| - this, current_response_bytes_, total_response_bytes_));
|
| + this,
|
| + current_response_bytes_,
|
| + total_response_bytes_));
|
| }
|
|
|
| void URLFetcherCore::InformDelegateDownloadProgressInDelegateThread(
|
| - int64 current, int64 total) {
|
| + int64 current,
|
| + int64 total) {
|
| DCHECK(delegate_task_runner_->BelongsToCurrentThread());
|
| if (delegate_)
|
| delegate_->OnURLFetchDownloadProgress(fetcher_, current, total);
|
|
|