| 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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 void PrecacheFetcher::OnManifestFetchComplete(int64_t host_visits, | 875 void PrecacheFetcher::OnManifestFetchComplete(int64_t host_visits, |
| 876 const Fetcher& source) { | 876 const Fetcher& source) { |
| 877 DCHECK(unfinished_work_->has_config_settings()); | 877 DCHECK(unfinished_work_->has_config_settings()); |
| 878 UpdateStats(source.response_bytes(), source.network_response_bytes()); | 878 UpdateStats(source.response_bytes(), source.network_response_bytes()); |
| 879 if (source.network_url_fetcher() == nullptr) { | 879 if (source.network_url_fetcher() == nullptr) { |
| 880 pool_.DeleteAll(); // Cancel any other ongoing request. | 880 pool_.DeleteAll(); // Cancel any other ongoing request. |
| 881 } else { | 881 } else { |
| 882 PrecacheManifest manifest; | 882 PrecacheManifest manifest; |
| 883 | 883 |
| 884 if (ParseProtoFromFetchResponse(*source.network_url_fetcher(), &manifest)) { | 884 if (ParseProtoFromFetchResponse(*source.network_url_fetcher(), &manifest)) { |
| 885 precache_delegate_->OnManifestFetched(source.referrer(), manifest); |
| 885 const base::Optional<std::vector<bool>> resource_bitset = | 886 const base::Optional<std::vector<bool>> resource_bitset = |
| 886 GetResourceBitset(manifest, experiment_id_); | 887 GetResourceBitset(manifest, experiment_id_); |
| 887 const int32_t included_resources_max = | 888 const int32_t included_resources_max = |
| 888 unfinished_work_->config_settings().top_resources_count(); | 889 unfinished_work_->config_settings().top_resources_count(); |
| 889 int32_t included_resources = 0; | 890 int32_t included_resources = 0; |
| 890 for (int i = 0; i < manifest.resource_size() && | 891 for (int i = 0; i < manifest.resource_size() && |
| 891 included_resources < included_resources_max; | 892 included_resources < included_resources_max; |
| 892 ++i) { | 893 ++i) { |
| 893 if ((!resource_bitset.has_value() || resource_bitset.value()[i]) && | 894 if ((!resource_bitset.has_value() || resource_bitset.value()[i]) && |
| 894 manifest.resource(i).has_url()) { | 895 manifest.resource(i).has_url()) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 remaining = 0; | 997 remaining = 0; |
| 997 quota_.set_remaining( | 998 quota_.set_remaining( |
| 998 used_bytes > quota_.remaining() ? 0U : quota_.remaining() - used_bytes); | 999 used_bytes > quota_.remaining() ? 0U : quota_.remaining() - used_bytes); |
| 999 db_task_runner_->PostTask( | 1000 db_task_runner_->PostTask( |
| 1000 FROM_HERE, | 1001 FROM_HERE, |
| 1001 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); | 1002 base::Bind(&PrecacheDatabase::SaveQuota, precache_database_, quota_)); |
| 1002 } | 1003 } |
| 1003 } | 1004 } |
| 1004 | 1005 |
| 1005 } // namespace precache | 1006 } // namespace precache |
| OLD | NEW |