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

Side by Side Diff: chrome/browser/prerender/prerender_manager.h

Issue 6966016: Handle <link rel=prerender> in chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tone down the over-aggressive search and replace... Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_PRERENDER_PRERENDER_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 }; 34 };
35 } 35 }
36 36
37 #endif 37 #endif
38 38
39 namespace prerender { 39 namespace prerender {
40 40
41 // Adds either a preload or a pending preload to the PrerenderManager. 41 // Adds either a preload or a pending preload to the PrerenderManager.
42 // Must be called on the UI thread. 42 // Must be called on the UI thread.
43 void HandlePrefetchTag( 43 void HandleTag(
44 const base::WeakPtr<PrerenderManager>& prerender_manager, 44 const base::WeakPtr<PrerenderManager>& prerender_manager,
45 int render_process_id, 45 int render_process_id,
46 int render_view_id, 46 int render_view_id,
47 const GURL& url, 47 const GURL& url,
48 const GURL& referrer, 48 const GURL& referrer,
49 bool make_pending); 49 bool make_pending);
50 50
51 // PrerenderManager is responsible for initiating and keeping prerendered 51 // PrerenderManager is responsible for initiating and keeping prerendered
52 // views of webpages. All methods must be called on the UI thread unless 52 // views of webpages. All methods must be called on the UI thread unless
53 // indicated otherwise. 53 // indicated otherwise.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // Must be called on the UI thread. 146 // Must be called on the UI thread.
147 // If |enabled| is false, existing prerendered pages will still persist until 147 // If |enabled| is false, existing prerendered pages will still persist until
148 // they time out, but new ones will not be generated. 148 // they time out, but new ones will not be generated.
149 void set_enabled(bool enabled); 149 void set_enabled(bool enabled);
150 150
151 static PrerenderManagerMode GetMode(); 151 static PrerenderManagerMode GetMode();
152 static void SetMode(PrerenderManagerMode mode); 152 static void SetMode(PrerenderManagerMode mode);
153 static bool IsPrerenderingPossible(); 153 static bool IsPrerenderingPossible();
154 static bool IsControlGroup(); 154 static bool IsControlGroup();
155 155
156 // Records that a prefetch tag has been observed. 156 // Records that a prerender tag has been observed.
157 void RecordPrefetchTagObserved(); 157 void RecordTagObserved();
158 158
159 // Query the list of current prerender pages to see if the given tab contents 159 // Query the list of current prerender pages to see if the given tab contents
160 // is prerendering a page. 160 // is prerendering a page.
161 bool IsTabContentsPrerendering(TabContents* tab_contents) const; 161 bool IsTabContentsPrerendering(TabContents* tab_contents) const;
162 162
163 // Maintaining and querying the set of TabContents belonging to this 163 // Maintaining and querying the set of TabContents belonging to this
164 // PrerenderManager that are currently showing prerendered pages. 164 // PrerenderManager that are currently showing prerendered pages.
165 void MarkTabContentsAsPrerendered(TabContents* tab_contents); 165 void MarkTabContentsAsPrerendered(TabContents* tab_contents);
166 void MarkTabContentsAsWouldBePrerendered(TabContents* tab_contents); 166 void MarkTabContentsAsWouldBePrerendered(TabContents* tab_contents);
167 void MarkTabContentsAsNotPrerendered(TabContents* tab_contents); 167 void MarkTabContentsAsNotPrerendered(TabContents* tab_contents);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // ownership of the PrerenderContents. 236 // ownership of the PrerenderContents.
237 PrerenderContents* FindEntry(const GURL& url); 237 PrerenderContents* FindEntry(const GURL& url);
238 238
239 // Returns the iterator to the PrerenderContentsData entry that is being 239 // Returns the iterator to the PrerenderContentsData entry that is being
240 // prerendered from the given child route id pair. 240 // prerendered from the given child route id pair.
241 std::list<PrerenderContentsData>::iterator 241 std::list<PrerenderContentsData>::iterator
242 FindPrerenderContentsForChildRouteIdPair( 242 FindPrerenderContentsForChildRouteIdPair(
243 const std::pair<int, int>& child_route_id_pair); 243 const std::pair<int, int>& child_route_id_pair);
244 244
245 // Returns whether the PrerenderManager is currently within the prerender 245 // Returns whether the PrerenderManager is currently within the prerender
246 // window - effectively, up to 30 seconds after a prefetch tag has been 246 // window - effectively, up to 30 seconds after a prerender tag has been
247 // observed. 247 // observed.
248 bool WithinWindow() const; 248 bool WithinWindow() const;
249 249
250 // Called when removing a preload to ensure we clean up any pending preloads 250 // Called when removing a preload to ensure we clean up any pending preloads
251 // that might remain in the map. 251 // that might remain in the map.
252 void RemovePendingPreload(PrerenderContents* entry); 252 void RemovePendingPreload(PrerenderContents* entry);
253 253
254 bool DoesRateLimitAllowPrerender() const; 254 bool DoesRateLimitAllowPrerender() const;
255 255
256 // Deletes old TabContents that have been replaced by prerendered ones. This 256 // Deletes old TabContents that have been replaced by prerendered ones. This
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 293
294 // Map of child/route id pairs to pending prerender data. 294 // Map of child/route id pairs to pending prerender data.
295 typedef std::map<std::pair<int, int>, std::vector<PendingContentsData> > 295 typedef std::map<std::pair<int, int>, std::vector<PendingContentsData> >
296 PendingPrerenderList; 296 PendingPrerenderList;
297 PendingPrerenderList pending_prerender_list_; 297 PendingPrerenderList pending_prerender_list_;
298 298
299 scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_; 299 scoped_ptr<PrerenderContents::Factory> prerender_contents_factory_;
300 300
301 static PrerenderManagerMode mode_; 301 static PrerenderManagerMode mode_;
302 302
303 // The time when we last saw a prefetch request coming from a renderer. 303 // The time when we last saw a prerender request coming from a renderer.
304 // This is used to record perceived PLT's for a certain amount of time 304 // This is used to record perceived PLT's for a certain amount of time
305 // from the point that we last saw a <link rel=prefetch> tag. 305 // from the point that we last saw a <link rel=prerender> tag.
306 base::TimeTicks last_prefetch_seen_time_; 306 base::TimeTicks last_prerender_seen_time_;
307 307
308 // A count of how many prerenders we do per session. Initialized to 0 then 308 // A count of how many prerenders we do per session. Initialized to 0 then
309 // incremented and emitted to a histogram on each successful prerender. 309 // incremented and emitted to a histogram on each successful prerender.
310 static int prerenders_per_session_count_; 310 static int prerenders_per_session_count_;
311 311
312 // RepeatingTimer to perform periodic cleanups of pending prerendered 312 // RepeatingTimer to perform periodic cleanups of pending prerendered
313 // pages. 313 // pages.
314 base::RepeatingTimer<PrerenderManager> repeating_timer_; 314 base::RepeatingTimer<PrerenderManager> repeating_timer_;
315 315
316 // Track time of last prerender to limit prerender spam. 316 // Track time of last prerender to limit prerender spam.
317 base::TimeTicks last_prerender_start_time_; 317 base::TimeTicks last_prerender_start_time_;
318 318
319 std::list<TabContentsWrapper*> old_tab_contents_list_; 319 std::list<TabContentsWrapper*> old_tab_contents_list_;
320 320
321 // Cancels pending tasks on deletion. 321 // Cancels pending tasks on deletion.
322 ScopedRunnableMethodFactory<PrerenderManager> runnable_method_factory_; 322 ScopedRunnableMethodFactory<PrerenderManager> runnable_method_factory_;
323 323
324 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); 324 DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
325 }; 325 };
326 326
327 } // namespace prerender 327 } // namespace prerender
328 328
329 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 329 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_field_trial.cc ('k') | chrome/browser/prerender/prerender_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698