Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <vector> | |
|
cbentzel
2011/01/12 23:49:53
Should a set be used instead of a vector? It seems
tburkard
2011/01/13 19:14:16
I don't think it makes a difference..
formally set
cbentzel
2011/01/14 02:01:13
Seems reasonable.
| |
| 10 | 11 |
| 11 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 13 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 14 #include "base/time.h" | 15 #include "base/time.h" |
| 15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 16 | 17 |
| 17 class PrerenderContents; | 18 class PrerenderContents; |
| 18 class Profile; | 19 class Profile; |
| 19 class TabContents; | 20 class TabContents; |
| 20 | 21 |
| 21 // PrerenderManager is responsible for initiating and keeping prerendered | 22 // PrerenderManager is responsible for initiating and keeping prerendered |
| 22 // views of webpages. | 23 // views of webpages. |
| 23 class PrerenderManager : public base::RefCounted<PrerenderManager>, | 24 class PrerenderManager : public base::RefCounted<PrerenderManager>, |
| 24 private base::NonThreadSafe { | 25 private base::NonThreadSafe { |
| 25 public: | 26 public: |
| 26 // Owned by a Profile object for the lifetime of the profile. | 27 // Owned by a Profile object for the lifetime of the profile. |
| 27 explicit PrerenderManager(Profile* profile); | 28 explicit PrerenderManager(Profile* profile); |
| 28 | 29 |
| 29 // Preloads the URL supplied. | 30 // Preloads the URL supplied. alias_urls indicates URLs that redirect |
| 30 void AddPreload(const GURL& url); | 31 // to the same URL to be preloaded. |
| 32 void AddPreload(const GURL& url, const std::vector<GURL>& alias_urls); | |
| 31 | 33 |
| 32 // For a given TabContents that wants to navigate to the URL supplied, | 34 // For a given TabContents that wants to navigate to the URL supplied, |
| 33 // determines whether a preloaded version of the URL can be used, | 35 // determines whether a preloaded version of the URL can be used, |
| 34 // and substitutes the prerendered RVH into the TabContents. Returns | 36 // and substitutes the prerendered RVH into the TabContents. Returns |
| 35 // whether or not a prerendered RVH could be used or not. | 37 // whether or not a prerendered RVH could be used or not. |
| 36 bool MaybeUsePreloadedPage(TabContents* tc, const GURL& url); | 38 bool MaybeUsePreloadedPage(TabContents* tc, const GURL& url); |
| 37 | 39 |
| 38 // Allows PrerenderContents to remove itself when prerendering should | 40 // Allows PrerenderContents to remove itself when prerendering should |
| 39 // be cancelled. Also deletes the entry. | 41 // be cancelled. Also deletes the entry. |
| 40 void RemoveEntry(PrerenderContents* entry); | 42 void RemoveEntry(PrerenderContents* entry); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 // Default maximum permitted elements to prerender. | 75 // Default maximum permitted elements to prerender. |
| 74 static const unsigned int kDefaultMaxPrerenderElements = 1; | 76 static const unsigned int kDefaultMaxPrerenderElements = 1; |
| 75 | 77 |
| 76 // Default maximum age a prerendered element may have, in seconds. | 78 // Default maximum age a prerendered element may have, in seconds. |
| 77 static const int kDefaultMaxPrerenderAgeSeconds = 20; | 79 static const int kDefaultMaxPrerenderAgeSeconds = 20; |
| 78 | 80 |
| 79 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 81 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 84 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| OLD | NEW |