| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/precache/core/precache_fetcher.h" | 5 #include "components/precache/core/precache_fetcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // If going over the per-resource download cap. | 236 // If going over the per-resource download cap. |
| 237 if (fetch_stage_ == FetchStage::NETWORK && | 237 if (fetch_stage_ == FetchStage::NETWORK && |
| 238 // |current| is guaranteed to be non-negative, so this cast is safe. | 238 // |current| is guaranteed to be non-negative, so this cast is safe. |
| 239 static_cast<size_t>(std::max(current, total)) > max_bytes_) { | 239 static_cast<size_t>(std::max(current, total)) > max_bytes_) { |
| 240 VLOG(1) << "Cancelling " << url_ << ": (" << current << "/" << total | 240 VLOG(1) << "Cancelling " << url_ << ": (" << current << "/" << total |
| 241 << ") is over " << max_bytes_; | 241 << ") is over " << max_bytes_; |
| 242 | 242 |
| 243 // Cancel the download. | 243 // Cancel the download. |
| 244 network_url_fetcher_.reset(); | 244 network_url_fetcher_.reset(); |
| 245 | 245 |
| 246 response_bytes_ = network_response_bytes_ = current; |
| 247 |
| 248 UMA_HISTOGRAM_CUSTOM_COUNTS("Precache.Fetch.ResponseBytes.NetworkWasted", |
| 249 network_response_bytes_, 1, kMaxResponseBytes, |
| 250 100); |
| 251 |
| 246 // Call the completion callback, to attempt the next download, or to trigger | 252 // Call the completion callback, to attempt the next download, or to trigger |
| 247 // cleanup in precache_delegate_->OnDone(). | 253 // cleanup in precache_delegate_->OnDone(). |
| 248 response_bytes_ = network_response_bytes_ = current; | |
| 249 | |
| 250 callback_.Run(*this); | 254 callback_.Run(*this); |
| 251 } | 255 } |
| 252 } | 256 } |
| 253 | 257 |
| 254 void PrecacheFetcher::Fetcher::OnURLFetchComplete( | 258 void PrecacheFetcher::Fetcher::OnURLFetchComplete( |
| 255 const net::URLFetcher* source) { | 259 const net::URLFetcher* source) { |
| 256 CHECK(source); | 260 CHECK(source); |
| 257 if (fetch_stage_ == FetchStage::CACHE && | 261 if (fetch_stage_ == FetchStage::CACHE && |
| 258 (source->GetStatus().error() == net::ERR_CACHE_MISS || | 262 (source->GetStatus().error() == net::ERR_CACHE_MISS || |
| 259 (source->GetResponseHeaders() && | 263 (source->GetResponseHeaders() && |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 575 |
| 572 void PrecacheFetcher::UpdateStats(int64_t response_bytes, | 576 void PrecacheFetcher::UpdateStats(int64_t response_bytes, |
| 573 int64_t network_response_bytes) { | 577 int64_t network_response_bytes) { |
| 574 unfinished_work_->set_total_bytes( | 578 unfinished_work_->set_total_bytes( |
| 575 unfinished_work_->total_bytes() + response_bytes); | 579 unfinished_work_->total_bytes() + response_bytes); |
| 576 unfinished_work_->set_network_bytes( | 580 unfinished_work_->set_network_bytes( |
| 577 unfinished_work_->network_bytes() + network_response_bytes); | 581 unfinished_work_->network_bytes() + network_response_bytes); |
| 578 } | 582 } |
| 579 | 583 |
| 580 } // namespace precache | 584 } // namespace precache |
| OLD | NEW |