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

Side by Side Diff: chrome/browser/ui/webui/predictors/predictors_handler.cc

Issue 2388783002: predictors: Refactor resource_prefetch_predictor_tables. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/predictors/predictors_handler.h" 5 #include "chrome/browser/ui/webui/predictors/predictors_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 dict); 111 dict);
112 } 112 }
113 113
114 void PredictorsHandler::AddPrefetchDataMapToListValue( 114 void PredictorsHandler::AddPrefetchDataMapToListValue(
115 const ResourcePrefetchPredictor::PrefetchDataMap& data_map, 115 const ResourcePrefetchPredictor::PrefetchDataMap& data_map,
116 base::ListValue* db) const { 116 base::ListValue* db) const {
117 for (const auto& p : data_map) { 117 for (const auto& p : data_map) {
118 std::unique_ptr<base::DictionaryValue> main(new base::DictionaryValue()); 118 std::unique_ptr<base::DictionaryValue> main(new base::DictionaryValue());
119 main->SetString("main_frame_url", p.first); 119 main->SetString("main_frame_url", p.first);
120 base::ListValue* resources = new base::ListValue(); 120 base::ListValue* resources = new base::ListValue();
121 for (const predictors::ResourceData& r : p.second.resources) { 121 for (const predictors::ResourceData& r : p.second.resources()) {
122 std::unique_ptr<base::DictionaryValue> resource( 122 std::unique_ptr<base::DictionaryValue> resource(
123 new base::DictionaryValue()); 123 new base::DictionaryValue());
124 resource->SetString("resource_url", r.resource_url()); 124 resource->SetString("resource_url", r.resource_url());
125 resource->SetString("resource_type", 125 resource->SetString("resource_type",
126 ConvertResourceType(r.resource_type())); 126 ConvertResourceType(r.resource_type()));
127 resource->SetInteger("number_of_hits", r.number_of_hits()); 127 resource->SetInteger("number_of_hits", r.number_of_hits());
128 resource->SetInteger("number_of_misses", r.number_of_misses()); 128 resource->SetInteger("number_of_misses", r.number_of_misses());
129 resource->SetInteger("consecutive_misses", r.consecutive_misses()); 129 resource->SetInteger("consecutive_misses", r.consecutive_misses());
130 resource->SetDouble("position", r.average_position()); 130 resource->SetDouble("position", r.average_position());
131 resources->Append(std::move(resource)); 131 resources->Append(std::move(resource));
132 } 132 }
133 main->Set("resources", resources); 133 main->Set("resources", resources);
134 db->Append(std::move(main)); 134 db->Append(std::move(main));
135 } 135 }
136 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/predictors/resource_prefetch_predictor_unittest.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698