X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fprerender%2Fprerender_manager.h;h=f0afe0813299480852dedd1aff93cc2ad5a5bd25;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=b90387e527063e0923664bb43601216221554378;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/prerender/prerender_manager.h b/src/chrome/browser/prerender/prerender_manager.h index b90387e..f0afe08 100644 --- a/src/chrome/browser/prerender/prerender_manager.h +++ b/src/chrome/browser/prerender/prerender_manager.h @@ -11,7 +11,6 @@ #include #include -#include "base/containers/hash_tables.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" @@ -26,6 +25,7 @@ #include "chrome/browser/prerender/prerender_contents.h" #include "chrome/browser/prerender/prerender_events.h" #include "chrome/browser/prerender/prerender_final_status.h" +#include "chrome/browser/prerender/prerender_histograms.h" #include "chrome/browser/prerender/prerender_origin.h" #include "chrome/browser/prerender/prerender_tracker.h" #include "components/browser_context_keyed_service/browser_context_keyed_service.h" @@ -61,25 +61,10 @@ namespace net { class URLRequestContextGetter; } -#if defined(COMPILER_GCC) - -namespace BASE_HASH_NAMESPACE { -template <> -struct hash { - std::size_t operator()(content::WebContents* value) const { - return reinterpret_cast(value); - } -}; - -} // namespace BASE_HASH_NAMESPACE - -#endif - namespace prerender { class PrerenderCondition; class PrerenderHandle; -class PrerenderHistograms; class PrerenderHistory; class PrerenderLocalPredictor; @@ -138,6 +123,7 @@ class PrerenderManager : public base::SupportsWeakPtr, int process_id, int route_id, const GURL& url, + uint32 rel_types, const content::Referrer& referrer, const gfx::Size& size); @@ -187,16 +173,22 @@ class PrerenderManager : public base::SupportsWeakPtr, virtual void MoveEntryToPendingDelete(PrerenderContents* entry, FinalStatus final_status); + // Records the page load time for a prerender that wasn't swapped in. + void RecordPageLoadTimeNotSwappedIn(Origin origin, + base::TimeDelta page_load_time, + const GURL& url); + // Records the perceived page load time for a page - effectively the time from // when the user navigates to a page to when it finishes loading. The actual // load may have started prior to navigation due to prerender hints. // This must be called on the UI thread. // |fraction_plt_elapsed_at_swap_in| must either be in [0.0, 1.0], or a value // outside that range indicating that it doesn't apply. - static void RecordPerceivedPageLoadTime( + void RecordPerceivedPageLoadTime( + Origin origin, + NavigationType navigation_type, base::TimeDelta perceived_page_load_time, double fraction_plt_elapsed_at_swap_in, - content::WebContents* web_contents, const GURL& url); // Set whether prerendering is currently enabled for this manager. @@ -230,26 +222,15 @@ class PrerenderManager : public base::SupportsWeakPtr, PrerenderContents* GetPrerenderContents( const content::WebContents* web_contents) const; + // Returns the PrerenderContents object for a given child_id, route_id pair, + // otherwise returns NULL. Note that the PrerenderContents may have been + // Destroy()ed, but not yet deleted. + virtual PrerenderContents* GetPrerenderContentsForRoute( + int child_id, int route_id) const; + // Returns a list of all WebContents being prerendered. const std::vector GetAllPrerenderingContents() const; - // Maintaining and querying the set of WebContents belonging to this - // PrerenderManager that are currently showing prerendered pages. - void MarkWebContentsAsPrerendered(content::WebContents* web_contents, - Origin origin); - void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents, - Origin origin); - void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); - - // Returns true if |web_contents| was originally a prerender that has since - // been swapped in. The optional parameter |origin| is an output parameter - // which, if a prerender is found, is set to the Origin of the prerender of - // |web_contents|. - bool IsWebContentsPrerendered(content::WebContents* web_contents, - Origin* origin) const; - bool WouldWebContentsBePrerendered(content::WebContents* web_contents, - Origin* origin) const; - // Checks whether |url| has been recently navigated to. bool HasRecentlyBeenNavigatedTo(Origin origin, const GURL& url); @@ -361,6 +342,18 @@ class PrerenderManager : public base::SupportsWeakPtr, PrerenderContents::CookieEvent event, const net::CookieList* cookie_list); + // Arranges for all session storage merges to hang indefinitely. This is used + // to reliably test various swap abort cases. + static void HangSessionStorageMergesForTesting(); + + // Notification that a prerender has completed and its bytes should be + // recorded. + void RecordNetworkBytes(bool used, int64 prerender_bytes); + + // Add to the running tally of bytes transferred over the network for this + // profile if prerendering is currently enabled. + void AddProfileNetworkBytesIfEnabled(int64 bytes); + protected: class PendingSwap; class PrerenderData : public base::SupportsWeakPtr { @@ -445,6 +438,7 @@ class PrerenderManager : public base::SupportsWeakPtr, bool should_replace_current_entry); virtual ~PendingSwap(); + content::WebContents* target_contents() const; void set_swap_successful(bool swap_successful) { swap_successful_ = swap_successful; } @@ -483,7 +477,6 @@ class PrerenderManager : public base::SupportsWeakPtr, // Prerender parameters. PrerenderManager* manager_; - content::WebContents* target_contents_; PrerenderData* prerender_data_; GURL url_; bool should_replace_current_entry_; @@ -500,13 +493,6 @@ class PrerenderManager : public base::SupportsWeakPtr, void SetPrerenderContentsFactory( PrerenderContents::Factory* prerender_contents_factory); - // Adds prerenders from the pending Prerenders, called by - // PrerenderContents::StartPendingPrerenders. - void StartPendingPrerenders( - int process_id, - ScopedVector* pending_prerenders, - content::SessionStorageNamespace* session_storage_namespace); - // Called by a PrerenderData to signal that the launcher has navigated away // from the context that launched the prerender. A user may have clicked // a link in a page containing a element, or the user @@ -524,37 +510,6 @@ class PrerenderManager : public base::SupportsWeakPtr, class OnCloseWebContentsDeleter; struct NavigationRecord; - // For each WebContents that is swapped in, we store a - // PrerenderedWebContentsData so that we can track the origin of the - // prerender. - struct PrerenderedWebContentsData { - explicit PrerenderedWebContentsData(Origin origin); - - Origin origin; - }; - - // In the control group experimental group for each WebContents "not swapped - // in" we create a WouldBePrerenderedWebContentsData to the origin of the - // "prerender" we did not launch. We also track a state machine to ensure - // the histogram reporting tracks what histograms would have done. - struct WouldBePrerenderedWebContentsData { - // When the WebContents gets a provisional load, we'd like to remove the - // WebContents from the map since the new navigation would not have swapped - // in a prerender. But the first provisional load after the control - // prerender is not "swapped in" is actually to the prerendered location! So - // we don't remove the item from the map on the first provisional load, but - // we do for subsequent loads. - enum State { - WAITING_FOR_PROVISIONAL_LOAD, - SEEN_PROVISIONAL_LOAD, - }; - - explicit WouldBePrerenderedWebContentsData(Origin origin); - - Origin origin; - State state; - }; - // Time interval before a new prerender is allowed. static const int kMinTimeBetweenPrerendersMs = 500; @@ -613,10 +568,10 @@ class PrerenderManager : public base::SupportsWeakPtr, const GURL& url, const content::SessionStorageNamespace* session_storage_namespace); - // If |child_id| and |route_id| correspond to a RenderView that is an active - // prerender, returns the PrerenderData object for that prerender. Otherwise, - // returns NULL. - PrerenderData* FindPrerenderDataForChildAndRoute(int child_id, int route_id); + // Finds the active PrerenderData object currently in a PendingSwap for + // |target_contents|. Otherwise, returns NULL. + PrerenderData* FindPrerenderDataForTargetContents( + content::WebContents* target_contents); // Given the |prerender_contents|, find the iterator in active_prerenders_ // correponding to the given prerender. @@ -706,25 +661,6 @@ class PrerenderManager : public base::SupportsWeakPtr, // navigate_time_. std::list navigations_; - // This map is from all WebContents which are currently displaying a - // prerendered page which has already been swapped in to a - // PrerenderedWebContentsData for tracking full lifetime information - // on prerenders. - base::hash_map - prerendered_web_contents_data_; - - // WebContents that would have been swapped out for a prerendered WebContents - // if the user was not part of the control group for measurement. When the - // WebContents gets a provisional load, the WebContents is removed from - // the map since the new navigation would not have swapped in a prerender. - // However, one complication exists because the first provisional load after - // the WebContents is marked as "Would Have Been Prerendered" is actually to - // the prerendered location. So, we need to keep a state around that does - // not clear the item from the map on the first provisional load, but does - // for subsequent loads. - base::hash_map - would_be_prerendered_map_; - scoped_ptr prerender_contents_factory_; static PrerenderManagerMode mode_; @@ -766,12 +702,16 @@ class PrerenderManager : public base::SupportsWeakPtr, CancelableRequestConsumer query_url_consumer_; + // The number of bytes transferred over the network for the profile this + // PrerenderManager is attached to. + int64 profile_network_bytes_; + + // The value of profile_network_bytes_ that was last recorded. + int64 last_recorded_profile_network_bytes_; + DISALLOW_COPY_AND_ASSIGN(PrerenderManager); }; -PrerenderManager* FindPrerenderManagerUsingRenderProcessId( - int render_process_id); - } // namespace prerender #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_