Revert 194484 "Add the LoggedIn Predictor, to detect which websi..."
[chromium-blink-merge.git] / chrome / browser / prerender / prerender_tab_helper.h
blob4c47e3b70dfb9b51fcee6e6bc3ebaa99f1e74cd6
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/time.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/browser/web_contents_user_data.h"
12 #include "googleurl/src/gurl.h"
14 namespace prerender {
16 class PrerenderManager;
18 // PrerenderTabHelper is responsible for recording perceived pageload times
19 // to compare PLT's with prerendering enabled and disabled.
20 class PrerenderTabHelper
21 : public content::WebContentsObserver,
22 public content::WebContentsUserData<PrerenderTabHelper> {
23 public:
24 virtual ~PrerenderTabHelper();
26 // content::WebContentsObserver implementation.
27 virtual void ProvisionalChangeToMainFrameUrl(
28 const GURL& url,
29 content::RenderViewHost* render_view_host) OVERRIDE;
30 virtual void DidStopLoading(
31 content::RenderViewHost* render_view_host) OVERRIDE;
32 virtual void DidStartProvisionalLoadForFrame(
33 int64 frame_id,
34 int64 parent_frame_id,
35 bool is_main_frame,
36 const GURL& validated_url,
37 bool is_error_page,
38 bool is_iframe_srcdoc,
39 content::RenderViewHost* render_view_host) OVERRIDE;
40 virtual void DidCommitProvisionalLoadForFrame(
41 int64 frame_id,
42 bool is_main_frame,
43 const GURL& validated_url,
44 content::PageTransition transition_type,
45 content::RenderViewHost* render_view_host) OVERRIDE;
46 // Called when this prerendered WebContents has just been swapped in.
47 void PrerenderSwappedIn();
49 private:
50 explicit PrerenderTabHelper(content::WebContents* web_contents);
51 friend class content::WebContentsUserData<PrerenderTabHelper>;
53 // Helper class to compute pixel-based stats on the paint progress
54 // between when a prerendered page is swapped in and when the onload event
55 // fires.
56 class PixelStats;
57 scoped_ptr<PixelStats> pixel_stats_;
59 // Retrieves the PrerenderManager, or NULL, if none was found.
60 PrerenderManager* MaybeGetPrerenderManager() const;
62 // Returns whether the WebContents being observed is currently prerendering.
63 bool IsPrerendering();
65 // Returns whether the WebContents being observed was prerendered.
66 bool IsPrerendered();
68 // System time at which the current load was started for the purpose of
69 // the perceived page load time (PPLT).
70 base::TimeTicks pplt_load_start_;
72 // System time at which the actual pageload started (pre-swapin), if
73 // a applicable (in cases when a prerender that was still loading was
74 // swapped in).
75 base::TimeTicks actual_load_start_;
77 // Current URL being loaded.
78 GURL url_;
80 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper);
83 } // namespace prerender
85 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_