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

Unified Diff: chrome/browser/prerender/prerender_manager.h

Issue 9226037: Cancel prerenders from Omnibox if we navigate to a different URL than predicted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix leak Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prerender/prerender_manager.h
diff --git a/chrome/browser/prerender/prerender_manager.h b/chrome/browser/prerender/prerender_manager.h
index 03f73f46f09e1d30f2c216ffb80477b49e57109a..516cffe56c1741f92307b9736ac0b782ab762229 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_.
« no previous file with comments | « chrome/browser/autocomplete/network_action_predictor.cc ('k') | chrome/browser/prerender/prerender_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698