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

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

Issue 7038012: Safely cancel prerenders on threads other than the UI thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Response to Dominic's comments, part 2 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 30 matching lines...) Expand all
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 HandlePrefetchTag(
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 // Given a renderer process id and view id, this will destroy any preloads and
52 // pending preloads than are using or originated in the given render view.
53 // Must be called on the UI thread.
54 void DestroyPreloadForRenderView(
55 const base::WeakPtr<PrerenderManager>& prerender_manager_weak_ptr,
56 int render_process_id,
57 int render_view_id,
58 FinalStatus final_status);
59
60 // PrerenderManager is responsible for initiating and keeping prerendered 51 // PrerenderManager is responsible for initiating and keeping prerendered
61 // 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
62 // indicated otherwise. 53 // indicated otherwise.
63 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, 54 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
64 public base::NonThreadSafe { 55 public base::NonThreadSafe {
65 public: 56 public:
66 // PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not 57 // PrerenderManagerMode is used in a UMA_HISTOGRAM, so please do not
67 // add in the middle. 58 // add in the middle.
68 enum PrerenderManagerMode { 59 enum PrerenderManagerMode {
69 PRERENDER_MODE_DISABLED, 60 PRERENDER_MODE_DISABLED,
(...skipping 16 matching lines...) Expand all
86 const std::pair<int, int>& child_route_id_pair, 77 const std::pair<int, int>& child_route_id_pair,
87 const GURL& url, 78 const GURL& url,
88 const GURL& referrer); 79 const GURL& referrer);
89 80
90 void AddPendingPreload(const std::pair<int, int>& child_route_id_pair, 81 void AddPendingPreload(const std::pair<int, int>& child_route_id_pair,
91 const GURL& url, 82 const GURL& url,
92 const GURL& referrer); 83 const GURL& referrer);
93 84
94 // Destroy all preloads for the given child route id pair and assign a final 85 // Destroy all preloads for the given child route id pair and assign a final
95 // status to them. 86 // status to them.
96 void DestroyPreloadForChildRouteIdPair( 87 virtual void DestroyPreloadForChildRouteIdPair(
97 const std::pair<int, int>& child_route_id_pair, 88 const std::pair<int, int>& child_route_id_pair,
98 FinalStatus final_status); 89 FinalStatus final_status);
99 90
100 // For a given TabContents that wants to navigate to the URL supplied, 91 // For a given TabContents that wants to navigate to the URL supplied,
101 // determines whether a preloaded version of the URL can be used, 92 // determines whether a preloaded version of the URL can be used,
102 // and substitutes the prerendered RVH into the TabContents. Returns 93 // and substitutes the prerendered RVH into the TabContents. Returns
103 // whether or not a prerendered RVH could be used or not. 94 // whether or not a prerendered RVH could be used or not.
104 bool MaybeUsePreloadedPage(TabContents* tab_contents, const GURL& url); 95 bool MaybeUsePreloadedPage(TabContents* tab_contents, const GURL& url);
105 bool MaybeUsePreloadedPageOld(TabContents* tab_contents, const GURL& url); 96 bool MaybeUsePreloadedPageOld(TabContents* tab_contents, const GURL& url);
106 97
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 300
310 // Cancels pending tasks on deletion. 301 // Cancels pending tasks on deletion.
311 ScopedRunnableMethodFactory<PrerenderManager> runnable_method_factory_; 302 ScopedRunnableMethodFactory<PrerenderManager> runnable_method_factory_;
312 303
313 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); 304 DISALLOW_COPY_AND_ASSIGN(PrerenderManager);
314 }; 305 };
315 306
316 } // namespace prerender 307 } // namespace prerender
317 308
318 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ 309 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698