Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / prerender / prerender_contents.h
index fc23008..ef3f7fb 100644 (file)
@@ -30,7 +30,6 @@ class ProcessMetrics;
 }
 
 namespace content {
-struct FaviconURL;
 class RenderViewHost;
 class SessionStorageNamespace;
 class WebContents;
@@ -78,7 +77,12 @@ class PrerenderContents : public content::NotificationObserver,
     // Signals that the prerender has had its load event.
     virtual void OnPrerenderStopLoading(PrerenderContents* contents);
 
-    // Signals that the prerender has stopped running.
+    // Signals that the prerender has had its 'DOMContentLoaded' event.
+    virtual void OnPrerenderDomContentLoaded(PrerenderContents* contents);
+
+    // Signals that the prerender has stopped running. A PrerenderContents with
+    // an unset final status will always call OnPrerenderStop before being
+    // destroyed.
     virtual void OnPrerenderStop(PrerenderContents* contents) = 0;
 
     // Signals that this prerender has just become a MatchComplete replacement.
@@ -90,25 +94,6 @@ class PrerenderContents : public content::NotificationObserver,
     virtual ~Observer() = 0;
   };
 
-  // A container for extra data on pending prerenders.
-  struct PendingPrerenderInfo {
-   public:
-    PendingPrerenderInfo(
-        base::WeakPtr<PrerenderHandle> weak_prerender_handle,
-        Origin origin,
-        const GURL& url,
-        const content::Referrer& referrer,
-        const gfx::Size& size);
-
-    ~PendingPrerenderInfo();
-
-    base::WeakPtr<PrerenderHandle> weak_prerender_handle;
-    Origin origin;
-    GURL url;
-    content::Referrer referrer;
-    gfx::Size size;
-  };
-
   // 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
@@ -179,7 +164,6 @@ class PrerenderContents : public content::NotificationObserver,
 
   base::string16 title() const { return title_; }
   int32 page_id() const { return page_id_; }
-  GURL icon_url() const { return icon_url_; }
   const GURL& prerender_url() const { return prerender_url_; }
   const content::Referrer& referrer() const { return referrer_; }
   bool has_stopped_loading() const { return has_stopped_loading_; }
@@ -200,10 +184,6 @@ class PrerenderContents : public content::NotificationObserver,
   // and returns a boolean indicating the validity of that id.
   virtual bool GetRouteId(int* route_id) const;
 
-  // Set the final status for how the PrerenderContents was used. This
-  // should only be called once, and should be called before the prerender
-  // contents are destroyed.
-  void SetFinalStatus(FinalStatus final_status);
   FinalStatus final_status() const { return final_status_; }
 
   Origin origin() const { return origin_; }
@@ -223,6 +203,8 @@ class PrerenderContents : public content::NotificationObserver,
       content::RenderFrameHost* render_frame_host) OVERRIDE;
   virtual void DidStopLoading(
       content::RenderViewHost* render_view_host) OVERRIDE;
+  virtual void DocumentLoadedInFrame(
+      int64 frame_id, content::RenderViewHost* render_view_host) OVERRIDE;
   virtual void DidStartProvisionalLoadForFrame(
       int64 frame_id,
       int64 parent_frame_id,
@@ -231,6 +213,13 @@ class PrerenderContents : public content::NotificationObserver,
       bool is_error_page,
       bool is_iframe_srcdoc,
       content::RenderViewHost* render_view_host) OVERRIDE;
+  virtual void DidCommitProvisionalLoadForFrame(
+      int64 frame_id,
+      const base::string16& frame_unique_name,
+      bool is_main_frame,
+      const GURL& url,
+      content::PageTransition transition_type,
+      content::RenderViewHost* render_view_host) OVERRIDE;
   virtual void DidFinishLoad(
       int64 frame_id,
       const GURL& validated_url,
@@ -242,8 +231,6 @@ class PrerenderContents : public content::NotificationObserver,
   virtual void DidGetRedirectForResourceRequest(
       content::RenderViewHost* render_view_host,
       const content::ResourceRedirectDetails& details) OVERRIDE;
-  virtual void DidUpdateFaviconURL(int32 page_id,
-      const std::vector<content::FaviconURL>& urls) OVERRIDE;
   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
 
   virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
@@ -289,13 +276,7 @@ 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. If |weak_prerender_handle| still
-  // exists when this page is made visible, it will be launched.
-  virtual void AddPendingPrerender(
-      scoped_ptr<PendingPrerenderInfo> pending_prerender_info);
-
-  // Reissues any pending prerender requests from the prerendered page.  Also
-  // clears the list of pending requests. Sends notifications.
+  // Marks prerender as used and releases any throttled resource requests.
   void PrepareForUse();
 
   content::SessionStorageNamespace* GetSessionStorageNamespace() const;
@@ -322,6 +303,9 @@ class PrerenderContents : public content::NotificationObserver,
   void AddResourceThrottle(
       const base::WeakPtr<PrerenderResourceThrottle>& throttle);
 
+  // Increments the number of bytes fetched over the network for this prerender.
+  void AddNetworkBytes(int64 bytes);
+
  protected:
   PrerenderContents(PrerenderManager* prerender_manager,
                     Profile* profile,
@@ -330,10 +314,16 @@ class PrerenderContents : public content::NotificationObserver,
                     Origin origin,
                     uint8 experiment_id);
 
+  // Set the final status for how the PrerenderContents was used. This
+  // should only be called once, and should be called before the prerender
+  // contents are destroyed.
+  void SetFinalStatus(FinalStatus final_status);
+
   // These call out to methods on our Observers, using our observer_list_. Note
   // that NotifyPrerenderStop() also clears the observer list.
   void NotifyPrerenderStart();
   void NotifyPrerenderStopLoading();
+  void NotifyPrerenderDomContentLoaded();
   void NotifyPrerenderStop();
   void NotifyPrerenderCreatedMatchCompleteReplacement(
       PrerenderContents* replacement);
@@ -347,8 +337,6 @@ class PrerenderContents : public content::NotificationObserver,
     return notification_registrar_;
   }
 
-  size_t pending_prerender_count() const;
-
   bool prerendering_has_been_cancelled() const {
     return prerendering_has_been_cancelled_;
   }
@@ -409,7 +397,6 @@ class PrerenderContents : public content::NotificationObserver,
   base::string16 title_;
   int32 page_id_;
   GURL url_;
-  GURL icon_url_;
   content::NotificationRegistrar notification_registrar_;
 
   // A vector of URLs that this prerendered page matches against.
@@ -451,13 +438,12 @@ class PrerenderContents : public content::NotificationObserver,
   // Experiment during which this prerender is performed.
   uint8 experiment_id_;
 
-  // Prerenders that the prerendered page has tried to prerender. They remain
-  // pending until this page is displayed.
-  ScopedVector<PendingPrerenderInfo> pending_prerenders_;
-
   // The process that created the child id.
   int creator_child_id_;
 
+  // Main frame ID of last committed page.
+  int64 main_frame_id_;
+
   // The size of the WebView from the launching page.
   gfx::Size size_;
 
@@ -478,6 +464,10 @@ class PrerenderContents : public content::NotificationObserver,
   // throttle on the IO thread.
   std::vector<base::WeakPtr<PrerenderResourceThrottle> > resource_throttles_;
 
+  // A running tally of the number of bytes this prerender has caused to be
+  // transferred over the network for resources.  Updated with AddNetworkBytes.
+  int64 network_bytes_;
+
   DISALLOW_COPY_AND_ASSIGN(PrerenderContents);
 };