Chromium Code Reviews| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 UMA_HISTOGRAM_CUSTOM_TIMES("Precache.Fetch.TimeToComplete", time_to_fetch, | 293 UMA_HISTOGRAM_CUSTOM_TIMES("Precache.Fetch.TimeToComplete", time_to_fetch, |
| 294 base::TimeDelta::FromSeconds(1), | 294 base::TimeDelta::FromSeconds(1), |
| 295 base::TimeDelta::FromHours(4), 50); | 295 base::TimeDelta::FromHours(4), 50); |
| 296 | 296 |
| 297 // Number of manifests for which we have downloaded all resources. | 297 // Number of manifests for which we have downloaded all resources. |
| 298 int manifests_completed = | 298 int manifests_completed = |
| 299 unfinished_work.num_manifest_urls() - remaining_manifest_urls_to_fetch; | 299 unfinished_work.num_manifest_urls() - remaining_manifest_urls_to_fetch; |
| 300 | 300 |
| 301 // If there are resource URLs left to fetch, the last manifest is not yet | 301 // If there are resource URLs left to fetch, the last manifest is not yet |
| 302 // completed. | 302 // completed. |
| 303 if (remaining_resource_urls_to_fetch > 0) | 303 if (remaining_resource_urls_to_fetch > 0 && manifests_completed > 0) |
|
bengr
2016/07/06 17:04:27
This seems like it should be a DCHECK. Could you e
Raj
2016/07/06 18:28:23
hmm. I got this failure in a few of my tests.
Now
| |
| 304 --manifests_completed; | 304 --manifests_completed; |
| 305 | 305 |
| 306 DCHECK_GE(manifests_completed, 0); | 306 DCHECK_GE(manifests_completed, 0); |
| 307 int percent_completed = unfinished_work.num_manifest_urls() == 0 | 307 int percent_completed = unfinished_work.num_manifest_urls() == 0 |
| 308 ? 0 | 308 ? 0 |
| 309 : (static_cast<double>(manifests_completed) / | 309 : (static_cast<double>(manifests_completed) / |
| 310 unfinished_work.num_manifest_urls() * 100); | 310 unfinished_work.num_manifest_urls() * 100); |
| 311 | 311 |
| 312 UMA_HISTOGRAM_PERCENTAGE("Precache.Fetch.PercentCompleted", | 312 UMA_HISTOGRAM_PERCENTAGE("Precache.Fetch.PercentCompleted", |
| 313 percent_completed); | 313 percent_completed); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 567 | 567 |
| 568 void PrecacheFetcher::UpdateStats(int64_t response_bytes, | 568 void PrecacheFetcher::UpdateStats(int64_t response_bytes, |
| 569 int64_t network_response_bytes) { | 569 int64_t network_response_bytes) { |
| 570 unfinished_work_->set_total_bytes( | 570 unfinished_work_->set_total_bytes( |
| 571 unfinished_work_->total_bytes() + response_bytes); | 571 unfinished_work_->total_bytes() + response_bytes); |
| 572 unfinished_work_->set_network_bytes( | 572 unfinished_work_->set_network_bytes( |
| 573 unfinished_work_->network_bytes() + network_response_bytes); | 573 unfinished_work_->network_bytes() + network_response_bytes); |
| 574 } | 574 } |
| 575 | 575 |
| 576 } // namespace precache | 576 } // namespace precache |
| OLD | NEW |