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 <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 PostTaskAndReplyWithResult( | 711 PostTaskAndReplyWithResult( |
| 712 db_task_runner_.get(), FROM_HERE, | 712 db_task_runner_.get(), FROM_HERE, |
| 713 base::Bind(&RetrieveQuotaInfo, precache_database_), | 713 base::Bind(&RetrieveQuotaInfo, precache_database_), |
| 714 base::Bind(&PrecacheFetcher::OnQuotaInfoRetrieved, AsWeakPtr())); | 714 base::Bind(&PrecacheFetcher::OnQuotaInfoRetrieved, AsWeakPtr())); |
| 715 } | 715 } |
| 716 | 716 |
| 717 void PrecacheFetcher::OnQuotaInfoRetrieved(const PrecacheQuota& quota) { | 717 void PrecacheFetcher::OnQuotaInfoRetrieved(const PrecacheQuota& quota) { |
| 718 quota_ = quota; | 718 quota_ = quota; |
| 719 base::Time time_now = base::Time::Now(); | 719 base::Time time_now = base::Time::Now(); |
| 720 if (IsQuotaTimeExpired(quota_, time_now)) { | 720 if (IsQuotaTimeExpired(quota_, time_now)) { |
| 721 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 722 "Precache.Fetch.ResponseBytes.Daily", | |
| 723 unfinished_work_->config_settings().daily_quota_total() - | |
| 724 quota_.remaining(), | |
|
jamartin
2017/03/07 21:10:12
(opt) It would be nice to have a bit more document
twifkak
2017/03/07 21:45:09
Done.
| |
| 725 1, kMaxResponseBytes, 100); | |
|
jamartin
2017/03/07 21:10:12
I assume you eyeballed the bucket values and they
twifkak
2017/03/07 21:45:09
Yes. The max is 500MB, which is more than enough f
| |
| 726 | |
| 721 // This is a new day. Update daily quota, that starts today and expires by | 727 // This is a new day. Update daily quota, that starts today and expires by |
| 722 // end of today. | 728 // end of today. |
|
jamartin
2017/03/07 21:10:12
Keep the comment at the beginning of the if block.
twifkak
2017/03/07 21:45:09
Done.
| |
| 723 quota_.set_start_time(time_now.LocalMidnight().ToInternalValue()); | 729 quota_.set_start_time(time_now.LocalMidnight().ToInternalValue()); |
| 724 quota_.set_remaining( | 730 quota_.set_remaining( |
| 725 unfinished_work_->config_settings().daily_quota_total()); | 731 unfinished_work_->config_settings().daily_quota_total()); |
| 726 db_task_runner_->PostTask( | 732 db_task_runner_->PostTask( |
| 727 FROM_HERE, | 733 FROM_HERE, |
| 728 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); | 734 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); |
| 729 } | 735 } |
| 730 StartNextFetch(); | 736 StartNextFetch(); |
| 731 } | 737 } |
| 732 | 738 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 remaining = 0; | 888 remaining = 0; |
| 883 quota_.set_remaining( | 889 quota_.set_remaining( |
| 884 used_bytes > quota_.remaining() ? 0U : quota_.remaining() - used_bytes); | 890 used_bytes > quota_.remaining() ? 0U : quota_.remaining() - used_bytes); |
| 885 db_task_runner_->PostTask( | 891 db_task_runner_->PostTask( |
| 886 FROM_HERE, | 892 FROM_HERE, |
| 887 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); | 893 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); |
| 888 } | 894 } |
| 889 } | 895 } |
| 890 | 896 |
| 891 } // namespace precache | 897 } // namespace precache |
| OLD | NEW |