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 <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 // |current| is guaranteed to be non-negative, so this cast is safe. | 273 // |current| is guaranteed to be non-negative, so this cast is safe. |
274 static_cast<size_t>(std::max(current, total)) > max_bytes_) { | 274 static_cast<size_t>(std::max(current, total)) > max_bytes_) { |
275 VLOG(1) << "Cancelling " << url_ << ": (" << current << "/" << total | 275 VLOG(1) << "Cancelling " << url_ << ": (" << current << "/" << total |
276 << ") is over " << max_bytes_; | 276 << ") is over " << max_bytes_; |
277 | 277 |
278 // Call the completion callback, to attempt the next download, or to trigger | 278 // Call the completion callback, to attempt the next download, or to trigger |
279 // cleanup in precache_delegate_->OnDone(). | 279 // cleanup in precache_delegate_->OnDone(). |
280 response_bytes_ = network_response_bytes_ = current; | 280 response_bytes_ = network_response_bytes_ = current; |
281 was_cached_ = source->WasCached(); | 281 was_cached_ = source->WasCached(); |
282 | 282 |
| 283 UMA_HISTOGRAM_CUSTOM_COUNTS("Precache.Fetch.ResponseBytes.NetworkWasted", |
| 284 network_response_bytes_, 1, |
| 285 1024 * 1024 /* 1 MB */, 100); |
| 286 |
283 // Cancel the download. | 287 // Cancel the download. |
284 network_url_fetcher_.reset(); | 288 network_url_fetcher_.reset(); |
285 callback_.Run(*this); | 289 callback_.Run(*this); |
286 } | 290 } |
287 } | 291 } |
288 | 292 |
289 void PrecacheFetcher::Fetcher::OnURLFetchComplete( | 293 void PrecacheFetcher::Fetcher::OnURLFetchComplete( |
290 const net::URLFetcher* source) { | 294 const net::URLFetcher* source) { |
291 CHECK(source); | 295 CHECK(source); |
292 if (fetch_stage_ == FetchStage::CACHE && | 296 if (fetch_stage_ == FetchStage::CACHE && |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 | 696 |
693 void PrecacheFetcher::UpdateStats(int64_t response_bytes, | 697 void PrecacheFetcher::UpdateStats(int64_t response_bytes, |
694 int64_t network_response_bytes) { | 698 int64_t network_response_bytes) { |
695 unfinished_work_->set_total_bytes( | 699 unfinished_work_->set_total_bytes( |
696 unfinished_work_->total_bytes() + response_bytes); | 700 unfinished_work_->total_bytes() + response_bytes); |
697 unfinished_work_->set_network_bytes( | 701 unfinished_work_->set_network_bytes( |
698 unfinished_work_->network_bytes() + network_response_bytes); | 702 unfinished_work_->network_bytes() + network_response_bytes); |
699 } | 703 } |
700 | 704 |
701 } // namespace precache | 705 } // namespace precache |
OLD | NEW |