Chromium Code Reviews| 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..ce921014db310c5b7e6c71714f713b58a1fcb637 100644 |
| --- a/chrome/browser/prerender/prerender_contents.h |
| +++ b/chrome/browser/prerender/prerender_contents.h |
| @@ -6,7 +6,6 @@ |
| #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| #pragma once |
| -#include <list> |
| #include <string> |
| #include <utility> |
| #include <vector> |
| @@ -15,6 +14,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 +66,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 +76,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 +91,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 +158,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 +213,37 @@ 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(const PrerenderHandle* prerender_handle) const; |
| // 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(); |
| + |
| + base::WeakPtr<PrerenderHandle> weak_prerender_handle; |
|
dominich
2012/07/03 17:08:39
why did you remove the const? once we have a pendi
gavinp
2012/07/03 18:45:41
std::vector<T> requires that T be default construc
|
| + GURL url; |
| + content::Referrer referrer; |
| + gfx::Size size; |
| + }; |
| + |
| PrerenderContents(PrerenderManager* prerender_manager, |
| PrerenderTracker* prerender_tracker, |
| Profile* profile, |
| @@ -242,7 +261,7 @@ class PrerenderContents : public content::NotificationObserver, |
| return notification_registrar_; |
| } |
| - const PendingPrerenderList* pending_prerender_list() const { |
| + const std::vector<PendingPrerenderInfo>* pending_prerender_vector() const { |
| return &pending_prerender_list_; |
| } |
| @@ -255,6 +274,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 +327,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 +350,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_; |
| @@ -348,7 +372,7 @@ class PrerenderContents : public content::NotificationObserver, |
| uint8 experiment_id_; |
| // List of all pages the prerendered page has tried to prerender. |
| - PendingPrerenderList pending_prerender_list_; |
| + std::vector<PendingPrerenderInfo> pending_prerender_list_; |
|
dominich
2012/07/03 17:08:39
so you changed the accessor to reflect the new typ
gavinp
2012/07/03 18:45:41
Done.
|
| // The process that created the child id. |
| int creator_child_id_; |