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

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

Issue 7077009: Handle AddPreload/AddPendingPreload on UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 29 matching lines...) Expand all
40 40
41 class PrerenderTracker; 41 class PrerenderTracker;
42 42
43 // Adds either a preload or a pending preload to the PrerenderManager. 43 // Adds either a preload or a pending preload to the PrerenderManager.
44 // Must be called on the UI thread. 44 // Must be called on the UI thread.
45 void HandleTag( 45 void HandleTag(
46 const base::WeakPtr<PrerenderManager>& prerender_manager, 46 const base::WeakPtr<PrerenderManager>& prerender_manager,
47 int render_process_id, 47 int render_process_id,
48 int render_view_id, 48 int render_view_id,
49 const GURL& url, 49 const GURL& url,
50 const GURL& referrer, 50 const GURL& referrer);
51 bool make_pending);
52 51
53 void DestroyPreloadForRenderView( 52 void DestroyPreloadForRenderView(
54 const base::WeakPtr<PrerenderManager>& prerender_manager_weak_ptr, 53 const base::WeakPtr<PrerenderManager>& prerender_manager_weak_ptr,
55 int child_id, 54 int child_id,
56 int route_id, 55 int route_id,
57 FinalStatus final_status); 56 FinalStatus final_status);
58 57
59 // PrerenderManager is responsible for initiating and keeping prerendered 58 // PrerenderManager is responsible for initiating and keeping prerendered
60 // views of webpages. All methods must be called on the UI thread unless 59 // views of webpages. All methods must be called on the UI thread unless
61 // indicated otherwise. 60 // indicated otherwise.
(...skipping 12 matching lines...) Expand all
74 73
75 // Owned by a Profile object for the lifetime of the profile. 74 // Owned by a Profile object for the lifetime of the profile.
76 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); 75 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker);
77 76
78 virtual ~PrerenderManager(); 77 virtual ~PrerenderManager();
79 78
80 // Preloads |url| if valid. |child_route_id_pair| identifies the 79 // Preloads |url| if valid. |child_route_id_pair| identifies the
81 // RenderViewHost that the prerender request came from and is used to 80 // RenderViewHost that the prerender request came from and is used to
82 // set the initial window size of the RenderViewHost used for prerendering. 81 // set the initial window size of the RenderViewHost used for prerendering.
83 // Returns true if the URL was added, false if it was not. 82 // Returns true if the URL was added, false if it was not.
83 // If |child_route_id_pair| itself is prerendering, adds the preloads as
84 // a pending preload.
84 bool AddPreload( 85 bool AddPreload(
85 const std::pair<int, int>& child_route_id_pair, 86 const std::pair<int, int>& child_route_id_pair,
86 const GURL& url, 87 const GURL& url,
87 const GURL& referrer); 88 const GURL& referrer);
88 89
89 void AddPendingPreload(const std::pair<int, int>& child_route_id_pair,
90 const GURL& url,
91 const GURL& referrer);
92
93 // Destroy all preloads for the given child route id pair and assign a final 90 // Destroy all preloads for the given child route id pair and assign a final
94 // status to them. 91 // status to them.
95 virtual void DestroyPreloadForChildRouteIdPair( 92 virtual void DestroyPreloadForChildRouteIdPair(
96 const std::pair<int, int>& child_route_id_pair, 93 const std::pair<int, int>& child_route_id_pair,
97 FinalStatus final_status); 94 FinalStatus final_status);
98 95
99 // For a given TabContents that wants to navigate to the URL supplied, 96 // For a given TabContents that wants to navigate to the URL supplied,
100 // determines whether a preloaded version of the URL can be used, 97 // determines whether a preloaded version of the URL can be used,
101 // and substitutes the prerendered RVH into the TabContents. Returns 98 // and substitutes the prerendered RVH into the TabContents. Returns
102 // whether or not a prerendered RVH could be used or not. 99 // whether or not a prerendered RVH could be used or not.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 201
205 private: 202 private:
206 // Test that needs needs access to internal functions. 203 // Test that needs needs access to internal functions.
207 friend class PrerenderBrowserTest; 204 friend class PrerenderBrowserTest;
208 205
209 friend class base::RefCountedThreadSafe<PrerenderManager>; 206 friend class base::RefCountedThreadSafe<PrerenderManager>;
210 207
211 struct PrerenderContentsData; 208 struct PrerenderContentsData;
212 struct NavigationRecord; 209 struct NavigationRecord;
213 210
211 // Adds a pending preload issued by the prerendering RenderView identified by
212 // |child_route_id_pair|. If and when that prerendering RenderView is used,
213 // the specified prerender will start.
214 void AddPendingPreload(const std::pair<int, int>& child_route_id_pair,
215 const GURL& url,
216 const GURL& referrer);
217
214 // Starts scheduling periodic cleanups. 218 // Starts scheduling periodic cleanups.
215 void StartSchedulingPeriodicCleanups(); 219 void StartSchedulingPeriodicCleanups();
216 // Stops scheduling periodic cleanups if they're no longer needed. 220 // Stops scheduling periodic cleanups if they're no longer needed.
217 void MaybeStopSchedulingPeriodicCleanups(); 221 void MaybeStopSchedulingPeriodicCleanups();
218 222
219 // Deletes stale and cancelled prerendered PrerenderContents, as well as 223 // Deletes stale and cancelled prerendered PrerenderContents, as well as
220 // TabContents that have been replaced by prerendered TabContents. 224 // TabContents that have been replaced by prerendered TabContents.
221 // Also identifies and kills PrerenderContents that use too much 225 // Also identifies and kills PrerenderContents that use too much
222 // resources. 226 // resources.
223 void PeriodicCleanup(); 227 void PeriodicCleanup();
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 334
331 // Cancels pending tasks on deletion. 335 // Cancels pending tasks on deletion.
332 ScopedRunnableMethodFactory<PrerenderManager> runnable_method_factory_; 336 ScopedRunnableMethodFactory<PrerenderManager> runnable_method_factory_;
333 337
334 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); 338 DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
335 }; 339 };
336 340
337 } // namespace prerender 341 } // namespace prerender
338 342
339 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 343 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_final_status.h ('k') | chrome/browser/prerender/prerender_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698