OLD | NEW |
---|---|
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_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 <string> | 10 #include <string> |
11 | 11 |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
18 #include "base/time.h" | 18 #include "base/time.h" |
19 #include "base/timer.h" | 19 #include "base/timer.h" |
20 #include "chrome/browser/prerender/prerender_config.h" | 20 #include "chrome/browser/prerender/prerender_config.h" |
21 #include "chrome/browser/prerender/prerender_contents.h" | 21 #include "chrome/browser/prerender/prerender_contents.h" |
22 #include "chrome/browser/prerender/prerender_final_status.h" | 22 #include "chrome/browser/prerender/prerender_final_status.h" |
23 #include "chrome/browser/prerender/prerender_origin.h" | 23 #include "chrome/browser/prerender/prerender_origin.h" |
24 #include "chrome/browser/profiles/profile_keyed_service.h" | 24 #include "chrome/browser/profiles/profile_keyed_service.h" |
25 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
26 #include "ui/gfx/rect.h" | |
26 | 27 |
27 class Profile; | 28 class Profile; |
28 class TabContents; | 29 class TabContents; |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 class DictionaryValue; | 32 class DictionaryValue; |
32 } | 33 } |
33 | 34 |
34 namespace content { | 35 namespace content { |
35 class WebContents; | 36 class WebContents; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 static void SetMode(PrerenderManagerMode mode); | 163 static void SetMode(PrerenderManagerMode mode); |
163 static bool IsPrerenderingPossible(); | 164 static bool IsPrerenderingPossible(); |
164 static bool ActuallyPrerendering(); | 165 static bool ActuallyPrerendering(); |
165 static bool IsControlGroup(); | 166 static bool IsControlGroup(); |
166 static bool IsNoUseGroup(); | 167 static bool IsNoUseGroup(); |
167 | 168 |
168 // Query the list of current prerender pages to see if the given web contents | 169 // Query the list of current prerender pages to see if the given web contents |
169 // is prerendering a page. | 170 // is prerendering a page. |
170 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; | 171 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; |
171 | 172 |
173 // Returns true if there is a prerendered page for the given URL and it has | |
174 // finished loading. Needs to be called before MaybeUsePrerenderedPage. | |
175 bool DidPrerenderFinishLoading(const GURL& url); | |
cbentzel
2012/02/14 01:20:31
const?
The comment about "Needs to be called" is
Jay Civelli
2012/02/14 03:13:51
Done.
cbentzel
2012/02/14 10:33:36
Ah, misinterpretation on my part. I thought you me
dominich
2012/02/14 16:38:59
It will still be swapped, but this lets the Androi
| |
176 | |
172 // Maintaining and querying the set of WebContents belonging to this | 177 // Maintaining and querying the set of WebContents belonging to this |
173 // PrerenderManager that are currently showing prerendered pages. | 178 // PrerenderManager that are currently showing prerendered pages. |
174 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); | 179 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); |
175 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); | 180 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); |
176 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); | 181 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); |
177 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; | 182 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; |
178 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; | 183 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; |
179 bool IsOldRenderViewHost(const RenderViewHost* render_view_host) const; | 184 bool IsOldRenderViewHost(const RenderViewHost* render_view_host) const; |
180 | 185 |
181 // Checks whether navigation to the provided URL has occurred in a visible | 186 // Checks whether navigation to the provided URL has occurred in a visible |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 // Adds a condition. This is owned by the PrerenderManager. | 225 // Adds a condition. This is owned by the PrerenderManager. |
221 void AddCondition(const PrerenderCondition* condition); | 226 void AddCondition(const PrerenderCondition* condition); |
222 | 227 |
223 bool IsTopSite(const GURL& url); | 228 bool IsTopSite(const GURL& url); |
224 | 229 |
225 bool IsPendingEntry(const GURL& url) const; | 230 bool IsPendingEntry(const GURL& url) const; |
226 | 231 |
227 // Returns true if |url| matches any URLs being prerendered. | 232 // Returns true if |url| matches any URLs being prerendered. |
228 bool IsPrerendering(const GURL& url) const; | 233 bool IsPrerendering(const GURL& url) const; |
229 | 234 |
235 // The default tab bounds are used as the prerenderer tab size when the active | |
236 // tab could not be accessed (Android case). | |
237 void set_default_tab_bounds(const gfx::Rect& bounds) { | |
dominich
2012/02/14 01:11:20
Maybe this would be better as part of the Config s
Jay Civelli
2012/02/14 03:13:51
Good idea! Moved to prerender_config.
| |
238 default_tab_bounds_ = bounds; | |
239 } | |
240 gfx::Rect default_tab_bounds() const { return default_tab_bounds_; } | |
241 | |
230 protected: | 242 protected: |
231 void SetPrerenderContentsFactory( | 243 void SetPrerenderContentsFactory( |
232 PrerenderContents::Factory* prerender_contents_factory); | 244 PrerenderContents::Factory* prerender_contents_factory); |
233 | 245 |
234 // Utility method that is called from the virtual Shutdown method on this | 246 // Utility method that is called from the virtual Shutdown method on this |
235 // class but is called directly from the TestPrerenderManager in the unit | 247 // class but is called directly from the TestPrerenderManager in the unit |
236 // tests. | 248 // tests. |
237 void DoShutdown(); | 249 void DoShutdown(); |
238 | 250 |
239 private: | 251 private: |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 ScopedVector<OnCloseTabContentsDeleter> on_close_tab_contents_deleters_; | 450 ScopedVector<OnCloseTabContentsDeleter> on_close_tab_contents_deleters_; |
439 | 451 |
440 scoped_ptr<PrerenderHistory> prerender_history_; | 452 scoped_ptr<PrerenderHistory> prerender_history_; |
441 | 453 |
442 std::list<const PrerenderCondition*> prerender_conditions_; | 454 std::list<const PrerenderCondition*> prerender_conditions_; |
443 | 455 |
444 scoped_ptr<PrerenderHistograms> histograms_; | 456 scoped_ptr<PrerenderHistograms> histograms_; |
445 | 457 |
446 scoped_ptr<MostVisitedSites> most_visited_; | 458 scoped_ptr<MostVisitedSites> most_visited_; |
447 | 459 |
460 gfx::Rect default_tab_bounds_; | |
461 | |
448 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 462 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
449 }; | 463 }; |
450 | 464 |
451 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 465 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
452 int render_process_id); | 466 int render_process_id); |
453 | 467 |
454 } // namespace prerender | 468 } // namespace prerender |
455 | 469 |
456 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 470 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |