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

Side by Side Diff: chrome/browser/prerender/prerender_tab_helper.cc

Issue 15021007: Do conservative prerendering based on the LocalPredictor in Dev/Canary. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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/prerender/prerender_tab_helper.h" 5 #include "chrome/browser/prerender/prerender_tab_helper.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "chrome/browser/predictors/logged_in_predictor_table.h" 10 #include "chrome/browser/predictors/logged_in_predictor_table.h"
11 #include "chrome/browser/prerender/prerender_field_trial.h"
11 #include "chrome/browser/prerender/prerender_histograms.h" 12 #include "chrome/browser/prerender/prerender_histograms.h"
12 #include "chrome/browser/prerender/prerender_manager.h" 13 #include "chrome/browser/prerender/prerender_manager.h"
13 #include "chrome/browser/prerender/prerender_manager_factory.h" 14 #include "chrome/browser/prerender/prerender_manager_factory.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/navigation_details.h" 17 #include "content/public/browser/navigation_details.h"
17 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
18 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_view.h" 21 #include "content/public/browser/web_contents_view.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 content::RenderViewHost* render_view_host) { 146 content::RenderViewHost* render_view_host) {
146 url_ = url; 147 url_ = url;
147 RecordEvent(EVENT_MAINFRAME_CHANGE); 148 RecordEvent(EVENT_MAINFRAME_CHANGE);
148 RecordEventIfLoggedInURL(EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN, url); 149 RecordEventIfLoggedInURL(EVENT_MAINFRAME_CHANGE_DOMAIN_LOGGED_IN, url);
149 PrerenderManager* prerender_manager = MaybeGetPrerenderManager(); 150 PrerenderManager* prerender_manager = MaybeGetPrerenderManager();
150 if (!prerender_manager) 151 if (!prerender_manager)
151 return; 152 return;
152 if (prerender_manager->IsWebContentsPrerendering(web_contents(), NULL)) 153 if (prerender_manager->IsWebContentsPrerendering(web_contents(), NULL))
153 return; 154 return;
154 prerender_manager->MarkWebContentsAsNotPrerendered(web_contents()); 155 prerender_manager->MarkWebContentsAsNotPrerendered(web_contents());
156 if (IsLocalPredictorEnabled())
Shishir 2013/05/07 22:57:30 In the previous line you are marking the web_conte
tburkard 2013/05/07 23:21:59 No, this only means that the data currently in the
157 prerender_manager->MaybeUsePrerenderedPage(web_contents(), url);
155 } 158 }
156 159
157 void PrerenderTabHelper::DidCommitProvisionalLoadForFrame( 160 void PrerenderTabHelper::DidCommitProvisionalLoadForFrame(
158 int64 frame_id, 161 int64 frame_id,
159 bool is_main_frame, 162 bool is_main_frame,
160 const GURL& validated_url, 163 const GURL& validated_url,
161 content::PageTransition transition_type, 164 content::PageTransition transition_type,
162 content::RenderViewHost* render_view_host) { 165 content::RenderViewHost* render_view_host) {
163 if (!is_main_frame) 166 if (!is_main_frame)
164 return; 167 return;
165 RecordEvent(EVENT_MAINFRAME_COMMIT); 168 RecordEvent(EVENT_MAINFRAME_COMMIT);
166 RecordEventIfLoggedInURL(EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN, 169 RecordEventIfLoggedInURL(EVENT_MAINFRAME_COMMIT_DOMAIN_LOGGED_IN,
167 validated_url); 170 validated_url);
168 url_ = validated_url; 171 url_ = validated_url;
169 PrerenderManager* prerender_manager = MaybeGetPrerenderManager(); 172 PrerenderManager* prerender_manager = MaybeGetPrerenderManager();
170 if (!prerender_manager) 173 if (!prerender_manager)
171 return; 174 return;
172 if (prerender_manager->IsWebContentsPrerendering(web_contents(), NULL)) 175 if (prerender_manager->IsWebContentsPrerendering(web_contents(), NULL))
173 return; 176 return;
174 prerender_manager->RecordNavigation(validated_url); 177 prerender_manager->RecordNavigation(validated_url);
178 if (IsLocalPredictorEnabled())
Shishir 2013/05/07 22:57:30 Why are we trying to swap at both start and commit
tburkard 2013/05/07 23:21:59 Some URL changes only show up in one or the other,
Shishir 2013/05/08 20:19:20 Can you mention which ones show up on in only one
tburkard 2013/05/08 20:35:47 Removing these changes in this file altogether, si
179 prerender_manager->MaybeUsePrerenderedPage(web_contents(), validated_url);
175 } 180 }
176 181
177 void PrerenderTabHelper::DidStopLoading( 182 void PrerenderTabHelper::DidStopLoading(
178 content::RenderViewHost* render_view_host) { 183 content::RenderViewHost* render_view_host) {
179 // Compute the PPLT metric and report it in a histogram, if needed. 184 // Compute the PPLT metric and report it in a histogram, if needed.
180 // We include pages that are still prerendering and have just finished 185 // We include pages that are still prerendering and have just finished
181 // loading -- PrerenderManager will sort this out and handle it correctly 186 // loading -- PrerenderManager will sort this out and handle it correctly
182 // (putting those times into a separate histogram). 187 // (putting those times into a separate histogram).
183 if (!pplt_load_start_.is_null()) { 188 if (!pplt_load_start_.is_null()) {
184 double fraction_elapsed_at_swapin = -1.0; 189 double fraction_elapsed_at_swapin = -1.0;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 302
298 void PrerenderTabHelper::RecordEventIfLoggedInURLResult( 303 void PrerenderTabHelper::RecordEventIfLoggedInURLResult(
299 PrerenderTabHelper::Event event, 304 PrerenderTabHelper::Event event,
300 scoped_ptr<bool> is_present, 305 scoped_ptr<bool> is_present,
301 scoped_ptr<bool> lookup_succeeded) { 306 scoped_ptr<bool> lookup_succeeded) {
302 if (*lookup_succeeded && *is_present) 307 if (*lookup_succeeded && *is_present)
303 RecordEvent(event); 308 RecordEvent(event);
304 } 309 }
305 310
306 } // namespace prerender 311 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698