summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prerender/prerender_manager.h
diff options
context:
space:
mode:
authordominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 18:55:39 +0000
committerdominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 18:55:39 +0000
commit861b0ceabe0f6bad41ef6438e9411da23d32035a (patch)
treea166ef20446d294e3c9fde156841b18d4d6df1d0 /chrome/browser/prerender/prerender_manager.h
parentdf1480cfdd3413bddb628726ebd4e65374baaec5 (diff)
downloadchromium_src-861b0ceabe0f6bad41ef6438e9411da23d32035a.zip
chromium_src-861b0ceabe0f6bad41ef6438e9411da23d32035a.tar.gz
chromium_src-861b0ceabe0f6bad41ef6438e9411da23d32035a.tar.bz2
Cancel prerenders from Omnibox if we navigate to a different URL than predicted.
I also took the opportunity to align the order of methods in prerender_manager.cc to that of the header (as it should be) and make a couple of methods const. BUG=110799,111350 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=119699 Review URL: http://codereview.chromium.org/9226037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prerender/prerender_manager.h')
-rw-r--r--chrome/browser/prerender/prerender_manager.h32
1 files changed, 16 insertions, 16 deletions
diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h
index 03f73f4..516cffe 100644
--- a/chrome/browser/prerender/prerender_manager.h
+++ b/chrome/browser/prerender/prerender_manager.h
@@ -121,6 +121,9 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// Cancels all active prerenders.
void CancelAllPrerenders();
+ // Cancels all active prerenders with the ORIGIN_OMNIBOX origin.
+ void CancelOmniboxPrerenders();
+
// For a given WebContents that wants to navigate to the URL supplied,
// determines whether a prerendered version of the URL can be used,
// and substitutes the prerendered RVH into the WebContents. |opener_url| is
@@ -221,6 +224,9 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
bool IsPendingEntry(const GURL& url) const;
+ // Returns true if |url| matches any URLs being prerendered.
+ bool IsPrerendering(const GURL& url) const;
+
protected:
void SetPrerenderContentsFactory(
PrerenderContents::Factory* prerender_contents_factory);
@@ -237,6 +243,11 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// Test that needs needs access to internal functions.
friend class PrerenderBrowserTest;
FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, AliasURLTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, CancelAllTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest,
+ CancelOmniboxRemovesOmniboxTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest,
+ CancelOmniboxDoesNotRemoveLinkTest);
FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, ClearTest);
FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, ControlGroup);
FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, DropOldestRequestTest);
@@ -259,6 +270,8 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
class MostVisitedSites;
+ typedef std::list<PrerenderContentsData> PrerenderContentsDataList;
+
// Adds a prerender for |url| from referrer |referrer| initiated from the
// RenderViewHost specified by |child_route_id_pair|. The |origin| specifies
// how the prerender was added. If the |session_storage_namespace| is NULL,
@@ -271,14 +284,6 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
const content::Referrer& referrer,
SessionStorageNamespace* session_storage_namespace);
- // Adds a pending preload issued by the prerendering RenderView identified by
- // |child_route_id_pair|. If and when that prerendering RenderView is used,
- // the specified prerender will start.
- void AddPendingPrerender(Origin origin,
- const std::pair<int, int>& child_route_id_pair,
- const GURL& url,
- const content::Referrer& referrer);
-
// Retrieves the PrerenderContents object for the specified URL, if it
// has been prerendered. The caller will then have ownership of the
// PrerenderContents object and is responsible for freeing it.
@@ -328,19 +333,14 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// Finds the specified PrerenderContents and returns it, if it exists.
// Returns NULL otherwise. Unlike GetEntry, the PrerenderManager maintains
// ownership of the PrerenderContents.
- PrerenderContents* FindEntry(const GURL& url);
+ PrerenderContents* FindEntry(const GURL& url) const;
// Returns the iterator to the PrerenderContentsData entry that is being
// prerendered from the given child route id pair.
- std::list<PrerenderContentsData>::iterator
+ PrerenderContentsDataList::iterator
FindPrerenderContentsForChildRouteIdPair(
const std::pair<int, int>& child_route_id_pair);
- // Returns whether the PrerenderManager is currently within the prerender
- // window - effectively, up to 30 seconds after a prerender tag has been
- // observed.
- bool WithinWindow() const;
-
bool DoesRateLimitAllowPrerender() const;
// Deletes old TabContents that have been replaced by prerendered ones. This
@@ -399,7 +399,7 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
PrerenderTracker* prerender_tracker_;
// List of prerendered elements.
- std::list<PrerenderContentsData> prerender_list_;
+ PrerenderContentsDataList prerender_list_;
// List of recent navigations in this profile, sorted by ascending
// navigate_time_.