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

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: fix windows build 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
50 // any local browsing prerendering.
51 void RecordSimulatedLocalBrowsingBaselinePLT(base::TimeDelta page_load_time,
52 const GURL& url) const;
53
54 // For simulated local browsing prerendering, records the PLT with
55 // local browsing prerendering.
56 void RecordSimulatedLocalBrowsingPLT(base::TimeDelta page_load_time,
57 const GURL& url) const;
58
59 // Records the time from when a page starts prerendering to when the user 51 // 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. 52 // navigates to it. This must be called on the UI thread.
61 void RecordTimeUntilUsed(base::TimeDelta time_until_used, 53 void RecordTimeUntilUsed(Origin origin,
54 base::TimeDelta time_until_used,
62 base::TimeDelta time_to_live) const; 55 base::TimeDelta time_to_live) const;
63 56
64 // Record a PerSessionCount data point. 57 // Record a PerSessionCount data point.
65 void RecordPerSessionCount(int count) const; 58 void RecordPerSessionCount(Origin origin, int count) const;
66 59
67 // Record time between two prerender requests. 60 // Record time between two prerender requests.
68 void RecordTimeBetweenPrerenderRequests(base::TimeDelta time) const; 61 void RecordTimeBetweenPrerenderRequests(Origin origin,
62 base::TimeDelta time) const;
69 63
70 // Record a final status of a prerendered page in a histogram. 64 // Record a final status of a prerendered page in a histogram.
71 void RecordFinalStatus(Origin origin, 65 void RecordFinalStatus(Origin origin,
72 uint8 experiment_id, 66 uint8 experiment_id,
73 PrerenderContents::MatchCompleteStatus mc_status, 67 PrerenderContents::MatchCompleteStatus mc_status,
74 FinalStatus final_status) const; 68 FinalStatus final_status) const;
75 69
76 // To be called when a new prerender is added. 70 // To be called when a new prerender is added.
77 void RecordPrerender(Origin origin, const GURL& url); 71 void RecordPrerender(Origin origin, const GURL& url);
78 72
79 // To be called when a new prerender is started. 73 // To be called when a new prerender is started.
80 void RecordPrerenderStarted(Origin origin) const; 74 void RecordPrerenderStarted(Origin origin) const;
81 75
82 // To be called when we know how many prerenders are running after starting 76 // To be called when we know how many prerenders are running after starting
83 // a prerender. 77 // a prerender.
84 void RecordConcurrency(size_t prerender_count, size_t max_concurrency) const; 78 void RecordConcurrency(size_t prerender_count, size_t max_concurrency) const;
85 79
86 // Called when we swap in a prerender. 80 // Called when we swap in a prerender.
87 void RecordUsedPrerender(Origin origin) const; 81 void RecordUsedPrerender(Origin origin) const;
88 82
89 // Record the time since a page was recently visited. 83 // Record the time since a page was recently visited.
90 void RecordTimeSinceLastRecentVisit(base::TimeDelta time) const; 84 void RecordTimeSinceLastRecentVisit(Origin origin,
85 base::TimeDelta time) const;
91 86
92 // Record a percentage of pixels of the final page already in place at 87 // Record a percentage of pixels of the final page already in place at
93 // swap-in. 88 // swap-in.
94 void RecordFractionPixelsFinalAtSwapin(double fraction) const; 89 void RecordFractionPixelsFinalAtSwapin(Origin origin, double fraction) const;
95
96 // Record the occurrence of an event from the local predictor.
97 void RecordLocalPredictorEvent(PrerenderLocalPredictor::Event event) const;
98
99 // 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
101 // UI thread.
102 void RecordLocalPredictorTimeUntilUsed(base::TimeDelta time_until_used,
103 base::TimeDelta max_age) const;
104 90
105 private: 91 private:
106 base::TimeTicks GetCurrentTimeTicks() const; 92 base::TimeTicks GetCurrentTimeTicks() const;
107 93
108 // Returns the time elapsed since the last prerender happened. 94 // Returns the time elapsed since the last prerender happened.
109 base::TimeDelta GetTimeSinceLastPrerender() const; 95 base::TimeDelta GetTimeSinceLastPrerender() const;
110 96
111 // Returns whether the PrerenderManager is currently within the prerender 97 // Returns whether the PrerenderManager is currently within the prerender
112 // window - effectively, up to 30 seconds after a prerender tag has been 98 // window - effectively, up to 30 seconds after a prerender tag has been
113 // observed. 99 // observed.
114 bool WithinWindow() const; 100 bool WithinWindow() const;
115 101
116 // Returns the current experiment. 102 // Returns the current experiment.
117 uint8 GetCurrentExperimentId() const; 103 uint8 GetCurrentExperimentId() const;
118 // Returns the current origin. 104
119 Origin GetCurrentOrigin() const;
120 // Returns whether or not there is currently an origin/experiment wash. 105 // Returns whether or not there is currently an origin/experiment wash.
121 bool IsOriginExperimentWash() const; 106 bool IsOriginExperimentWash() const;
122 107
123 // An integer indicating a Prerendering Experiment being currently conducted. 108 // An integer indicating a Prerendering Experiment being currently conducted.
124 // (The last experiment ID seen). 109 // (The last experiment ID seen).
125 uint8 last_experiment_id_; 110 uint8 last_experiment_id_;
126 111
127 // Origin of the last prerender seen. 112 // Origin of the last prerender seen.
128 Origin last_origin_; 113 Origin last_origin_;
129 114
130 // A boolean indicating that we have recently encountered a combination of 115 // A boolean indicating that we have recently encountered a combination of
131 // different experiments and origins, making an attribution of PPLT's to 116 // different experiments and origins, making an attribution of PPLT's to
132 // experiments / origins impossible. 117 // experiments / origins impossible.
133 bool origin_experiment_wash_; 118 bool origin_experiment_wash_;
134 119
120 // The prerender time to live determines the window size for determining
121 // washes.
122 const base::TimeDelta prerender_ttl_;
123
135 // The time when we last saw a prerender request coming from a renderer. 124 // 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 125 // 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. 126 // from the point that we last saw a <link rel=prerender> tag.
138 base::TimeTicks last_prerender_seen_time_; 127 base::TimeTicks last_prerender_seen_time_;
139 128
140 // Indicates whether we have recorded page load events after the most 129 // 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 130 // recent prerender. These must be initialized to true, so that we don't
142 // start recording events before the first prerender occurs. 131 // start recording events before the first prerender occurs.
143 bool seen_any_pageload_; 132 bool seen_any_pageload_;
144 bool seen_pageload_started_after_prerender_; 133 bool seen_pageload_started_after_prerender_;
145 134
146 DISALLOW_COPY_AND_ASSIGN(PrerenderHistograms); 135 DISALLOW_COPY_AND_ASSIGN(PrerenderHistograms);
147 }; 136 };
148 137
149 } // namespace prerender 138 } // namespace prerender
150 139
151 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HISTOGRAMS_H_ 140 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_HISTOGRAMS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698