Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(752)

Side by Side Diff: components/precache/core/precache_fetcher.cc

Issue 2762673002: predictors: Pass manifests from Bork to store in ResourcePrefetchPredictor. (Closed)
Patch Set: Add delegate tests for PrecacheFetcher. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « components/precache/core/precache_fetcher.h ('k') | components/precache/core/precache_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698