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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.h

Issue 10900037: Adding more histograms to ResourcePrefetchPredictor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: ResourcePrefetchPredictor can only be enabled at startup. Created 8 years, 3 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 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // Size of LRU caches for the Url data. 75 // Size of LRU caches for the Url data.
76 size_t max_urls_to_track; // Default 500 76 size_t max_urls_to_track; // Default 500
77 // The number of times, we should have seen a visit to this Url in history 77 // The number of times, we should have seen a visit to this Url in history
78 // to start tracking it. This is to ensure we dont bother with oneoff 78 // to start tracking it. This is to ensure we dont bother with oneoff
79 // entries. 79 // entries.
80 int min_url_visit_count; // Default 3 80 int min_url_visit_count; // Default 3
81 // The maximum number of resources to store per entry. 81 // The maximum number of resources to store per entry.
82 int max_resources_per_entry; // Default 50 82 int max_resources_per_entry; // Default 50
83 // The number of consecutive misses after we stop tracking a resource Url. 83 // The number of consecutive misses after we stop tracking a resource Url.
84 int max_consecutive_misses; // Default 3 84 int max_consecutive_misses; // Default 3
85 // The number of resources we should report accuracy stats on.
86 int num_resources_assumed_prefetched; // Default 25
87 }; 85 };
88 86
89 // Stores the data that we need to get from the URLRequest. 87 // Stores the data that we need to get from the URLRequest.
90 struct URLRequestSummary { 88 struct URLRequestSummary {
91 URLRequestSummary(); 89 URLRequestSummary();
92 URLRequestSummary(const URLRequestSummary& other); 90 URLRequestSummary(const URLRequestSummary& other);
93 ~URLRequestSummary(); 91 ~URLRequestSummary();
94 92
95 NavigationID navigation_id; 93 NavigationID navigation_id;
96 GURL resource_url; 94 GURL resource_url;
97 ResourceType::Type resource_type; 95 ResourceType::Type resource_type;
98 96
99 // Only for responses. 97 // Only for responses.
100 std::string mime_type; 98 std::string mime_type;
101 bool was_cached; 99 bool was_cached;
102 GURL redirect_url; // Empty unless request was redirected to a valid url. 100 GURL redirect_url; // Empty unless request was redirected to a valid url.
103 }; 101 };
104 102
105 ResourcePrefetchPredictor(const Config& config, Profile* profile); 103 ResourcePrefetchPredictor(const Config& config, Profile* profile);
106 virtual ~ResourcePrefetchPredictor(); 104 virtual ~ResourcePrefetchPredictor();
107 105
108 // Thread safe. 106 // Thread safe.
109 static bool IsEnabled(Profile* profile); 107 static bool IsEnabled();
110 static bool ShouldRecordRequest(net::URLRequest* request, 108 static bool ShouldRecordRequest(net::URLRequest* request,
111 ResourceType::Type resource_type); 109 ResourceType::Type resource_type);
112 static bool ShouldRecordResponse(net::URLRequest* response); 110 static bool ShouldRecordResponse(net::URLRequest* response);
113 static bool ShouldRecordRedirect(net::URLRequest* response); 111 static bool ShouldRecordRedirect(net::URLRequest* response);
114 112
115 static ResourceType::Type GetResourceTypeFromMimeType( 113 static ResourceType::Type GetResourceTypeFromMimeType(
116 const std::string& mime_type, 114 const std::string& mime_type,
117 ResourceType::Type fallback); 115 ResourceType::Type fallback);
118 116
119 void RecordURLRequest(const URLRequestSummary& request); 117 void RecordURLRequest(const URLRequestSummary& request);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 void RemoveAnEntryFromUrlDB(); 187 void RemoveAnEntryFromUrlDB();
190 void DeleteAllUrls(); 188 void DeleteAllUrls();
191 void DeleteUrls(const history::URLRows& urls); 189 void DeleteUrls(const history::URLRows& urls);
192 190
193 bool ShouldTrackUrl(const GURL& url); 191 bool ShouldTrackUrl(const GURL& url);
194 void CleanupAbandonedNavigations(const NavigationID& navigation_id); 192 void CleanupAbandonedNavigations(const NavigationID& navigation_id);
195 void OnNavigationComplete(const NavigationID& navigation_id); 193 void OnNavigationComplete(const NavigationID& navigation_id);
196 void LearnUrlNavigation(const GURL& main_frame_url, 194 void LearnUrlNavigation(const GURL& main_frame_url,
197 const std::vector<URLRequestSummary>& new_value); 195 const std::vector<URLRequestSummary>& new_value);
198 void MaybeReportAccuracyStats(const NavigationID& navigation_id) const; 196 void MaybeReportAccuracyStats(const NavigationID& navigation_id) const;
197 void ReportAccuracyHistograms(const UrlTableRowVector& predicted,
198 const std::map<GURL, bool>& actual_resources,
199 int total_resources_fetched_from_network,
200 int max_assumed_prefetched) const;
199 201
200 void SetTablesForTesting( 202 void SetTablesForTesting(
201 scoped_refptr<ResourcePrefetchPredictorTables> tables); 203 scoped_refptr<ResourcePrefetchPredictorTables> tables);
202 204
203 Profile* const profile_; 205 Profile* const profile_;
204 Config config_; 206 Config config_;
205 InitializationState initialization_state_; 207 InitializationState initialization_state_;
206 scoped_refptr<ResourcePrefetchPredictorTables> tables_; 208 scoped_refptr<ResourcePrefetchPredictorTables> tables_;
207 content::NotificationRegistrar notification_registrar_; 209 content::NotificationRegistrar notification_registrar_;
208 210
209 NavigationMap inflight_navigations_; 211 NavigationMap inflight_navigations_;
210 UrlTableCacheMap url_table_cache_; 212 UrlTableCacheMap url_table_cache_;
211 213
212 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); 214 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor);
213 }; 215 };
214 216
215 } // namespace predictors 217 } // namespace predictors
216 218
217 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 219 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698