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

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

Issue 11028037: Fix prerender histograms for multiple prerender case. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... whitespace Created 8 years, 2 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 | Annotate | Revision Log
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_HISTOGRAMS_H_ 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_HISTOGRAMS_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_HISTOGRAMS_H_ 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_HISTOGRAMS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "chrome/browser/prerender/prerender_contents.h" 11 #include "chrome/browser/prerender/prerender_contents.h"
12 #include "chrome/browser/prerender/prerender_final_status.h" 12 #include "chrome/browser/prerender/prerender_final_status.h"
13 #include "chrome/browser/prerender/prerender_local_predictor.h" 13 #include "chrome/browser/prerender/prerender_local_predictor.h"
14 #include "chrome/browser/prerender/prerender_origin.h" 14 #include "chrome/browser/prerender/prerender_origin.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 16
17 namespace prerender { 17 namespace prerender {
18 18
19 // PrerenderHistograms is responsible for recording all prerender specific 19 // PrerenderHistograms is responsible for recording all prerender specific
20 // histograms for PrerenderManager. It keeps track of the type of prerender 20 // histograms for PrerenderManager. It keeps track of the type of prerender
21 // currently underway (based on the PrerenderOrigin of the most recent 21 // currently underway (based on the PrerenderOrigin of the most recent
22 // prerenders, and any experiments detected). 22 // prerenders, and any experiments detected).
23 // PrerenderHistograms does not necessarily record all histograms related to 23 // PrerenderHistograms does not necessarily record all histograms related to
24 // prerendering, only the ones in the context of PrerenderManager. 24 // prerendering, only the ones in the context of PrerenderManager.
25 class PrerenderHistograms { 25 class PrerenderHistograms {
26 public: 26 public:
27 // Owned by a PrerenderManager object for the lifetime of the 27 // Owned by a PrerenderManager object for the lifetime of the
28 // PrerenderManager. 28 // PrerenderManager.
29 PrerenderHistograms(); 29 explicit PrerenderHistograms(const base::TimeDelta prerender_ttl);
30 30
31 // Records the perceived page load time for a page - effectively the time from 31 // Records the perceived page load time for a page - effectively the time from
32 // when the user navigates to a page to when it finishes loading. The actual 32 // when the user navigates to a page to when it finishes loading. The actual
33 // load may have started prior to navigation due to prerender hints. 33 // load may have started prior to navigation due to prerender hints.
34 void RecordPerceivedPageLoadTime(base::TimeDelta perceived_page_load_time, 34 void RecordPerceivedPageLoadTime(Origin origin,
35 base::TimeDelta perceived_page_load_time,
35 bool was_prerender, 36 bool was_prerender,
36 bool was_complete_prerender, 37 bool was_complete_prerender,
37 const GURL& url); 38 const GURL& url);
38 39
39 // Records, in a histogram, the percentage of the page load time that had 40 // Records, in a histogram, the percentage of the page load time that had
40 // elapsed by the time it is swapped in. Values outside of [0, 1.0] are 41 // elapsed by the time it is swapped in. Values outside of [0, 1.0] are
41 // invalid and ignored. 42 // invalid and ignored.
42 void RecordPercentLoadDoneAtSwapin(double fraction) const; 43 void RecordPercentLoadDoneAtSwapin(Origin origin, double fraction) const;
43 44
44 // Records the actual pageload time of a prerender that has not been swapped 45 // Records the actual pageload time of a prerender that has not been swapped
45 // in yet, but finished loading. 46 // in yet, but finished loading.
46 void RecordPageLoadTimeNotSwappedIn(base::TimeDelta page_load_time, 47 void RecordPageLoadTimeNotSwappedIn(Origin origin,
48 base::TimeDelta page_load_time,
47 const GURL& url) const; 49 const GURL& url) const;
48 50
49 // For simulated local browsing prerendering, records the PLT without 51 // For simulated local browsing prerendering, records the PLT without
50 // any local browsing prerendering. 52 // any local browsing prerendering.
51 void RecordSimulatedLocalBrowsingBaselinePLT(base::TimeDelta page_load_time, 53 void RecordSimulatedLocalBrowsingBaselinePLT(Origin origin,
54 base::TimeDelta page_load_time,
52 const GURL& url) const; 55 const GURL& url) const;
53 56
54 // For simulated local browsing prerendering, records the PLT with 57 // For simulated local browsing prerendering, records the PLT with
55 // local browsing prerendering. 58 // local browsing prerendering.
56 void RecordSimulatedLocalBrowsingPLT(base::TimeDelta page_load_time, 59 void RecordSimulatedLocalBrowsingPLT(Origin origin,
60 base::TimeDelta page_load_time,
57 const GURL& url) const; 61 const GURL& url) const;
58 62
59 // Records the time from when a page starts prerendering to when the user 63 // Records the time from when a page starts prerendering to when the user
60 // navigates to it. This must be called on the UI thread. 64 // navigates to it. This must be called on the UI thread.
61 void RecordTimeUntilUsed(base::TimeDelta time_until_used, 65 void RecordTimeUntilUsed(Origin origin,
66 base::TimeDelta time_until_used,
62 base::TimeDelta time_to_live) const; 67 base::TimeDelta time_to_live) const;
63 68
64 // Record a PerSessionCount data point. 69 // Record a PerSessionCount data point.
65 void RecordPerSessionCount(int count) const; 70 void RecordPerSessionCount(Origin origin, int count) const;
66 71
67 // Record time between two prerender requests. 72 // Record time between two prerender requests.
68 void RecordTimeBetweenPrerenderRequests(base::TimeDelta time) const; 73 void RecordTimeBetweenPrerenderRequests(Origin origin,
74 base::TimeDelta time) const;
69 75
70 // Record a final status of a prerendered page in a histogram. 76 // Record a final status of a prerendered page in a histogram.
71 void RecordFinalStatus(Origin origin, 77 void RecordFinalStatus(Origin origin,
72 uint8 experiment_id, 78 uint8 experiment_id,
73 PrerenderContents::MatchCompleteStatus mc_status, 79 PrerenderContents::MatchCompleteStatus mc_status,
74 FinalStatus final_status) const; 80 FinalStatus final_status) const;
75 81
76 // To be called when a new prerender is added. 82 // To be called when a new prerender is added.
77 void RecordPrerender(Origin origin, const GURL& url); 83 void RecordPrerender(Origin origin, const GURL& url);
78 84
79 // To be called when a new prerender is started. 85 // To be called when a new prerender is started.
80 void RecordPrerenderStarted(Origin origin) const; 86 void RecordPrerenderStarted(Origin origin) const;
81 87
82 // To be called when we know how many prerenders are running after starting 88 // To be called when we know how many prerenders are running after starting
83 // a prerender. 89 // a prerender.
84 void RecordConcurrency(size_t prerender_count, size_t max_concurrency) const; 90 void RecordConcurrency(size_t prerender_count, size_t max_concurrency) const;
85 91
86 // Called when we swap in a prerender. 92 // Called when we swap in a prerender.
87 void RecordUsedPrerender(Origin origin) const; 93 void RecordUsedPrerender(Origin origin) const;
88 94
89 // Record the time since a page was recently visited. 95 // Record the time since a page was recently visited.
90 void RecordTimeSinceLastRecentVisit(base::TimeDelta time) const; 96 void RecordTimeSinceLastRecentVisit(Origin origin,
97 base::TimeDelta time) const;
91 98
92 // Record a percentage of pixels of the final page already in place at 99 // Record a percentage of pixels of the final page already in place at
93 // swap-in. 100 // swap-in.
94 void RecordFractionPixelsFinalAtSwapin(double fraction) const; 101 void RecordFractionPixelsFinalAtSwapin(Origin origin, double fraction) const;
95 102
96 // Record the occurrence of an event from the local predictor. 103 // Record the occurrence of an event from the local predictor.
97 void RecordLocalPredictorEvent(PrerenderLocalPredictor::Event event) const; 104 void RecordLocalPredictorEvent(PrerenderLocalPredictor::Event event) const;
98 105
99 // For the local predictor, records the time from when a page starts 106 // For the local predictor, records the time from when a page starts
100 // prerendering to when the user navigates to it. This must be called on the 107 // prerendering to when the user navigates to it. This must be called on the
101 // UI thread. 108 // UI thread.
102 void RecordLocalPredictorTimeUntilUsed(base::TimeDelta time_until_used, 109 void RecordLocalPredictorTimeUntilUsed(Origin origin,
110 base::TimeDelta time_until_used,
103 base::TimeDelta max_age) const; 111 base::TimeDelta max_age) const;
104 112
105 private: 113 private:
106 base::TimeTicks GetCurrentTimeTicks() const; 114 base::TimeTicks GetCurrentTimeTicks() const;
107 115
108 // Returns the time elapsed since the last prerender happened. 116 // Returns the time elapsed since the last prerender happened.
109 base::TimeDelta GetTimeSinceLastPrerender() const; 117 base::TimeDelta GetTimeSinceLastPrerender() const;
110 118
111 // Returns whether the PrerenderManager is currently within the prerender 119 // Returns whether the PrerenderManager is currently within the prerender
112 // window - effectively, up to 30 seconds after a prerender tag has been 120 // window - effectively, up to 30 seconds after a prerender tag has been
113 // observed. 121 // observed.
114 bool WithinWindow() const; 122 bool WithinWindow() const;
115 123
116 // Returns the current experiment. 124 // Returns the current experiment.
117 uint8 GetCurrentExperimentId() const; 125 uint8 GetCurrentExperimentId() const;
118 // Returns the current origin. 126
119 Origin GetCurrentOrigin() const;
120 // Returns whether or not there is currently an origin/experiment wash. 127 // Returns whether or not there is currently an origin/experiment wash.
121 bool IsOriginExperimentWash() const; 128 bool IsOriginExperimentWash() const;
122 129
123 // An integer indicating a Prerendering Experiment being currently conducted. 130 // An integer indicating a Prerendering Experiment being currently conducted.
124 // (The last experiment ID seen). 131 // (The last experiment ID seen).
125 uint8 last_experiment_id_; 132 uint8 last_experiment_id_;
126 133
127 // Origin of the last prerender seen. 134 // Origin of the last prerender seen.
128 Origin last_origin_; 135 Origin last_origin_;
129 136
130 // A boolean indicating that we have recently encountered a combination of 137 // A boolean indicating that we have recently encountered a combination of
131 // different experiments and origins, making an attribution of PPLT's to 138 // different experiments and origins, making an attribution of PPLT's to
132 // experiments / origins impossible. 139 // experiments / origins impossible.
133 bool origin_experiment_wash_; 140 bool origin_experiment_wash_;
134 141
142 // The prerender time to live determines the window size for determining
143 // washes.
144 const base::TimeDelta prerender_ttl_;
145
135 // The time when we last saw a prerender request coming from a renderer. 146 // The time when we last saw a prerender request coming from a renderer.
136 // This is used to record perceived PLT's for a certain amount of time 147 // This is used to record perceived PLT's for a certain amount of time
137 // from the point that we last saw a <link rel=prerender> tag. 148 // from the point that we last saw a <link rel=prerender> tag.
138 base::TimeTicks last_prerender_seen_time_; 149 base::TimeTicks last_prerender_seen_time_;
139 150
140 // Indicates whether we have recorded page load events after the most 151 // Indicates whether we have recorded page load events after the most
141 // recent prerender. These must be initialized to true, so that we don't 152 // recent prerender. These must be initialized to true, so that we don't
142 // start recording events before the first prerender occurs. 153 // start recording events before the first prerender occurs.
143 bool seen_any_pageload_; 154 bool seen_any_pageload_;
144 bool seen_pageload_started_after_prerender_; 155 bool seen_pageload_started_after_prerender_;
145 156
146 DISALLOW_COPY_AND_ASSIGN(PrerenderHistograms); 157 DISALLOW_COPY_AND_ASSIGN(PrerenderHistograms);
147 }; 158 };
148 159
149 } // namespace prerender 160 } // namespace prerender
150 161
151 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HISTOGRAMS_H_ 162 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HISTOGRAMS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698