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

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

Issue 10553029: Handle interface to prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediation to reviews, and unit test improvements. Created 8 years, 6 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_contents.h
diff --git a/chrome/browser/prerender/prerender_contents.h b/chrome/browser/prerender/prerender_contents.h
index 6156d486d3a56ddbfb413bd965ae7132b4aa9e69..a0d4fa725291d71223d1077618a691bc9dd7828d 100644
--- a/chrome/browser/prerender/prerender_contents.h
+++ b/chrome/browser/prerender/prerender_contents.h
@@ -15,6 +15,7 @@
#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/prerender/prerender_final_status.h"
+#include "chrome/browser/prerender/prerender_handle.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_observer.h"
@@ -66,10 +67,6 @@ class PrerenderContents : public content::NotificationObserver,
DISALLOW_COPY_AND_ASSIGN(Factory);
};
- // Information on pages that the prerendered page has tried to prerender.
- struct PendingPrerenderInfo;
- typedef std::list<PendingPrerenderInfo> PendingPrerenderList;
-
// Indicates how this PrerenderContents relates to MatchComplete. This is to
// figure out which histograms to use to record the FinalStatus, Match (record
// all prerenders and control group prerenders) or MatchComplete (record
@@ -80,7 +77,7 @@ class PrerenderContents : public content::NotificationObserver,
// MatchComplete.
MATCH_COMPLETE_DEFAULT,
// A prerender that used to be a regular prerender, but has since been
- // replaced by a MatchComplete dummy. Therefore, we will record this only
+ // replaced by a MatchComplete dummy. Therefore, we will record this only
// for Match, but not for MatchComplete.
MATCH_COMPLETE_REPLACED,
// A prerender that is a MatchComplete dummy replacing a regular prerender.
@@ -95,6 +92,12 @@ class PrerenderContents : public content::NotificationObserver,
virtual ~PrerenderContents();
+ // For MatchComplete correctness, create a dummy replacement prerender
+ // contents to stand in for this prerender contents that (which we are about
+ // to destroy).
+ void MakeIntoDummyReplacementOf(
+ const PrerenderContents* original_prerender_contents);
+
bool Init();
static Factory* CreateFactory();
@@ -156,11 +159,10 @@ class PrerenderContents : public content::NotificationObserver,
base::TimeTicks load_start_time() const { return load_start_time_; }
// Indicates whether this prerendered page can be used for the provided
- // URL, i.e. whether there is a match. |matching_url| is optional and will be
- // set to the URL that is found as a match if it is provided.
- // TODO(gavinp,mmenke): Rework matching to be based on both the URL
- // and the session WebStorage.
- bool MatchesURL(const GURL& url, GURL* matching_url) const;
+ // |url| and |session_storage_namespace|.
+ bool Matches(
+ const GURL& url,
+ const content::SessionStorageNamespace* session_storage_namespace);
// content::WebContentsObserver implementation.
virtual void DidStopLoading() OVERRIDE;
@@ -212,19 +214,39 @@ class PrerenderContents : public content::NotificationObserver,
// MouseEvent being dispatched by a link to a website installed as an app.
bool IsCrossSiteNavigationPending() const;
- // Adds a pending prerender to the list.
- virtual void AddPendingPrerender(const GURL& url,
- const content::Referrer& referrer,
- const gfx::Size& size);
+ // Adds a pending prerender to the list. If |weak_prerender_handle| still
+ // exists when this page is made visible, it will be launched.
+ virtual void AddPendingPrerender(
+ base::WeakPtr<PrerenderHandle> weak_prerender_handle,
+ const GURL& url,
+ const content::Referrer& referrer,
+ const gfx::Size& size);
// Returns true if |url| corresponds to a pending prerender.
- bool IsPendingEntry(const GURL& url) const;
+ bool IsPendingEntry(PrerenderHandle* prerender_handle) const;
dominich 2012/07/02 20:43:03 const PrerenderHandle& prerender_handle?
gavinp 2012/07/03 16:41:02 const PrerenderHandle* prerender_handle.
dominich 2012/07/03 17:08:39 Why? Can it be NULL?
gavinp 2012/07/03 18:45:40 Done. I just didn't have a PrerenderHandle& anywhe
// Reissues any pending prerender requests from the prerendered page. Also
// clears the list of pending requests.
void StartPendingPrerenders();
protected:
+ // Information on pages that the prerendered page has tried to prerender.
+ struct PendingPrerenderInfo {
+ PendingPrerenderInfo(
+ base::WeakPtr<PrerenderHandle> weak_prerender_handle,
+ const GURL& url,
+ const content::Referrer& referrer,
+ const gfx::Size& size);
+ ~PendingPrerenderInfo();
+
+ const base::WeakPtr<PrerenderHandle> weak_prerender_handle;
+ const GURL url;
+ const content::Referrer referrer;
+ const gfx::Size size;
+ };
+
+ typedef std::list<PendingPrerenderInfo> PendingPrerenderList;
dominich 2012/07/02 20:43:03 I think this should be a vector - better memory us
gavinp 2012/07/03 16:41:02 Done.
+
PrerenderContents(PrerenderManager* prerender_manager,
PrerenderTracker* prerender_tracker,
Profile* profile,
@@ -255,6 +277,11 @@ class PrerenderContents : public content::NotificationObserver,
bool prerendering_has_started_;
+ // Time at which we started to load the URL. This is used to compute
+ // the time elapsed from initiating a prerender until the time the
+ // (potentially only partially) prerendered page is shown to the user.
+ base::TimeTicks load_start_time_;
+
private:
class TabContentsDelegateImpl;
@@ -303,6 +330,11 @@ class PrerenderContents : public content::NotificationObserver,
// such as HTTP redirects or javascript redirects.
std::vector<GURL> alias_urls_;
+ // The session storage namespace for use in Matching. We must save it
+ // rather than get it from the RenderViewHost since in the control group
+ // we won't have a RenderViewHost.
+ content::SessionStorageNamespace* session_storage_namespace_;
+
bool has_stopped_loading_;
// True when the main frame has finished loading.
@@ -321,11 +353,6 @@ class PrerenderContents : public content::NotificationObserver,
// Used solely to prevent double deletion.
bool prerendering_has_been_cancelled_;
- // Time at which we started to load the URL. This is used to compute
- // the time elapsed from initiating a prerender until the time the
- // (potentially only partially) prerendered page is shown to the user.
- base::TimeTicks load_start_time_;
-
// Process Metrics of the render process associated with the
// RenderViewHost for this object.
scoped_ptr<base::ProcessMetrics> process_metrics_;

Powered by Google App Engine
This is Rietveld 408576698