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

Side by Side Diff: chrome/browser/prerender/prerender_tab_helper.h

Issue 2738783002: Prerender: Remove PerceivedPLT histograms (Closed)
Patch Set: set the origin in prerender_tab_helper Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "chrome/browser/prerender/prerender_histograms.h" 13 #include "chrome/browser/prerender/prerender_histograms.h"
14 #include "chrome/browser/prerender/prerender_origin.h" 14 #include "chrome/browser/prerender/prerender_origin.h"
15 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/browser/web_contents_user_data.h" 16 #include "content/public/browser/web_contents_user_data.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace prerender { 19 namespace prerender {
20 20
21 class PrerenderManager; 21 class PrerenderManager;
22 22
23 // PrerenderTabHelper is responsible for recording perceived pageload times 23 // Notifies the PrerenderManager with the events happening in the prerendered
24 // to compare PLT's with prerendering enabled and disabled. 24 // WebContents.
25 class PrerenderTabHelper 25 class PrerenderTabHelper
26 : public content::WebContentsObserver, 26 : public content::WebContentsObserver,
27 public content::WebContentsUserData<PrerenderTabHelper> { 27 public content::WebContentsUserData<PrerenderTabHelper> {
28 public: 28 public:
29 ~PrerenderTabHelper() override; 29 ~PrerenderTabHelper() override;
30 30
31 // content::WebContentsObserver implementation. 31 // content::WebContentsObserver implementation.
32 void DidGetRedirectForResourceRequest( 32 void DidGetRedirectForResourceRequest(
33 const content::ResourceRedirectDetails& details) override; 33 const content::ResourceRedirectDetails& details) override;
34 void DidStopLoading() override;
35 void DidStartNavigation( 34 void DidStartNavigation(
36 content::NavigationHandle* navigation_handle) override; 35 content::NavigationHandle* navigation_handle) override;
37 void DidFinishNavigation( 36 void DidFinishNavigation(
38 content::NavigationHandle* navigation_handle) override; 37 content::NavigationHandle* navigation_handle) override;
39 38
40 // Called when the URL of the main frame changed, either when the load 39 // Called when the URL of the main frame changed, either when the load
41 // commits, or a redirect happens. 40 // commits, or a redirect happens.
42 void MainFrameUrlDidChange(const GURL& url); 41 void MainFrameUrlDidChange(const GURL& url);
43 42
44 // Called when this prerendered WebContents has just been swapped in. 43 // Called when this prerendered WebContents has just been swapped in.
45 void PrerenderSwappedIn(); 44 void PrerenderSwappedIn();
46 45
47 base::TimeTicks swap_ticks() const { return swap_ticks_; } 46 base::TimeTicks swap_ticks() const { return swap_ticks_; }
48 47
49 Origin origin() const { return origin_; } 48 Origin origin() const { return origin_; }
50 49
51 private: 50 private:
52 explicit PrerenderTabHelper(content::WebContents* web_contents); 51 explicit PrerenderTabHelper(content::WebContents* web_contents);
53 friend class content::WebContentsUserData<PrerenderTabHelper>; 52 friend class content::WebContentsUserData<PrerenderTabHelper>;
54 53
55 void RecordPerceivedPageLoadTime(
56 base::TimeDelta perceived_page_load_time,
57 double fraction_plt_elapsed_at_swap_in);
58
59 // Retrieves the PrerenderManager, or NULL, if none was found. 54 // Retrieves the PrerenderManager, or NULL, if none was found.
60 PrerenderManager* MaybeGetPrerenderManager() const; 55 PrerenderManager* MaybeGetPrerenderManager() const;
61 56
62 // Returns the current TimeTicks synchronized with PrerenderManager ticks. In 57 // Returns the current TimeTicks synchronized with PrerenderManager ticks. In
63 // tests the clock can be mocked out in PrerenderManager, but in production 58 // tests the clock can be mocked out in PrerenderManager, but in production
64 // this should be always TimeTicks::Now(). 59 // this should be always TimeTicks::Now().
65 base::TimeTicks GetTimeTicksFromPrerenderManager() const; 60 base::TimeTicks GetTimeTicksFromPrerenderManager() const;
66 61
67 // Returns whether the WebContents being observed is currently prerendering. 62 // Returns whether the WebContents being observed is currently prerendering.
68 bool IsPrerendering(); 63 bool IsPrerendering();
69 64
70 // The type the current pending navigation, if there is one. If the tab is a 65 // The origin of the relevant prerender or ORIGIN_NONE if there is no
71 // prerender before swap, the value is always NAVIGATION_TYPE_PRERENDERED, 66 // prerender associated with the WebContents.
72 // even if the prerender is not currently loading.
73 NavigationType navigation_type_;
74
75 // If |navigation_type_| is not NAVIGATION_TYPE_NORMAL, the origin of the
76 // relevant prerender. Otherwise, ORIGIN_NONE.
77 Origin origin_; 67 Origin origin_;
78 68
79 // System time at which the current load was started for the purpose of 69 // Record the most recent swap time.
80 // the perceived page load time (PPLT). If null, there is no current
81 // load.
82 base::TimeTicks pplt_load_start_;
83
84 // System time at which the actual pageload started (pre-swapin), if
85 // a applicable (in cases when a prerender that was still loading was
86 // swapped in).
87 base::TimeTicks actual_load_start_;
88
89 // Record the most recent swap time. This differs from |pplt_load_start_| in
90 // that it is not reset in various circumstances, like a load being stopped.
91 base::TimeTicks swap_ticks_; 70 base::TimeTicks swap_ticks_;
92 71
93 // Current URL being loaded. 72 // Current URL being loaded.
94 GURL url_; 73 GURL url_;
95 74
96 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_; 75 base::WeakPtrFactory<PrerenderTabHelper> weak_factory_;
97 76
98 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper); 77 DISALLOW_COPY_AND_ASSIGN(PrerenderTabHelper);
99 }; 78 };
100 79
101 } // namespace prerender 80 } // namespace prerender
102 81
103 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_ 82 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_manager.cc ('k') | chrome/browser/prerender/prerender_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698