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

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

Issue 10198040: New link rel=prerender api, using WebKit::WebPrerenderingPlatform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove the urls_to_id_map_, and follow consequences through. Created 8 years, 8 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 20dcb0cabd177046fa8c2caefecf52de597bed6c..f5ca319e3986c387ee66cd246d48ac013a4a6818 100644
--- a/chrome/browser/prerender/prerender_manager.h
+++ b/chrome/browser/prerender/prerender_manager.h
@@ -8,6 +8,7 @@
#include <list>
#include <string>
+#include <utility>
#include "base/gtest_prod_util.h"
#include "base/hash_tables.h"
@@ -34,6 +35,10 @@ namespace content {
class WebContents;
}
+namespace gfx {
+class Size;
+}
+
#if defined(COMPILER_GCC)
namespace BASE_HASH_NAMESPACE {
@@ -101,9 +106,13 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// Returns true if the URL was added, false if it was not.
// If the RenderViewHost source is itself prerendering, the prerender is added
// as a pending prerender.
- bool AddPrerenderFromLinkRelPrerender(int process_id, int route_id,
- const GURL& url,
- const content::Referrer& referrer);
+ bool AddPrerenderFromLinkRelPrerender(
+ int process_id,
+ int route_id,
+ const GURL& url,
+ const content::Referrer& referrer,
+ const gfx::Size& size,
+ content::SessionStorageNamespace* session_storage_namespace);
// Adds a prerender for |url| if valid. As the prerender request is coming
// from a source without a RenderViewHost (i.e., the omnibox) we don't have a
@@ -114,9 +123,15 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
const GURL& url,
content::SessionStorageNamespace* session_storage_namespace);
+ // Request cancelation of a previously added prerender. If the add_count_ of
+ // the prerender is one, it will be canceled. Otherwise, add_count_ will be
+ // decremented by one.
+ void MaybeCancelPrerender(const GURL& url);
+
// Destroy all prerenders for the given child route id pair and assign a final
// status to them.
- virtual void DestroyPrerenderForRenderView(int process_id, int view_id,
+ virtual void DestroyPrerenderForRenderView(int process_id,
+ int view_id,
FinalStatus final_status);
// Cancels all active prerenders.
@@ -247,31 +262,34 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
void DoShutdown();
private:
- // Needs access to AddPrerender.
- friend class PrerenderContents;
-
// 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,
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, AliasURLTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, CancelAllTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest,
CancelOmniboxRemovesOmniboxTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest,
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest,
CancelOmniboxDoesNotRemoveLinkTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, ClearTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, ControlGroup);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, DropOldestRequestTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, DropSecondRequestTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, ExpireTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, FoundTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, FragmentMatchesFragmentTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, FragmentMatchesPageTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, PageMatchesFragmentTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, PendingPrerenderTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, RateLimitInWindowTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, RateLimitOutsideWindowTest);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, SourceRenderViewClosed);
- FRIEND_TEST_ALL_PREFIXES(PrerenderManagerTest, TwoElementPrerenderTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ClearTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ControlGroup);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, DropOldestRequestTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, DropSecondRequestTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ExpireTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, FoundTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, FragmentMatchesFragmentTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, FragmentMatchesPageTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerAddTwiceCancelTwice);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerCancel);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerCancelThenAddAgain);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerCancelTwice);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerExpireThenAddAgain);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerExpireThenCancel);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PageMatchesFragmentTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PendingPrerenderTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitInWindowTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitOutsideWindowTest);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, SourceRenderViewClosed);
+ FRIEND_TEST_ALL_PREFIXES(PrerenderTest, TwoElementPrerenderTest);
struct PrerenderContentsData;
struct NavigationRecord;
@@ -289,9 +307,10 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// |child_route_id_pair|.
bool AddPrerender(
Origin origin,
- const std::pair<int, int>& child_route_id_pair,
+ int child_id,
const GURL& url,
const content::Referrer& referrer,
+ const gfx::Size& size,
content::SessionStorageNamespace* session_storage_namespace);
// Retrieves the PrerenderContents object for the specified URL, if it
@@ -341,9 +360,10 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
// list.
void DeletePendingDeleteEntries();
- // Finds the specified PrerenderContents and returns it, if it exists.
- // Returns NULL otherwise. Unlike GetEntry, the PrerenderManager maintains
- // ownership of the PrerenderContents.
+ // Finds the specified PrerenderContentsData/PrerenderContents and returns it,
+ // if it exists. Returns NULL otherwise. Unlike GetEntry, the
+ // PrerenderManager maintains ownership of the PrerenderContents.
+ PrerenderContentsData* FindEntryData(const GURL& url);
PrerenderContents* FindEntry(const GURL& url) const;
// Returns the iterator to the PrerenderContentsData entry that is being
@@ -352,6 +372,9 @@ class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>,
FindPrerenderContentsForChildRouteIdPair(
const std::pair<int, int>& child_route_id_pair);
+ PrerenderContentsDataList::iterator
+ FindPrerenderContentsForURL(const GURL& url);
dominich 2012/04/29 18:52:55 should this also take a session storage namespace
gavinp 2012/04/30 11:43:16 Yup, if we ever key prerenders on the session stor
dominich 2012/04/30 15:52:05 Or the proposed CL to add a PrerenderHandle.
+
bool DoesRateLimitAllowPrerender() const;
// Deletes old WebContents that have been replaced by prerendered ones. This

Powered by Google App Engine
This is Rietveld 408576698