OLD | NEW |
---|---|
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 #include "chrome/browser/prerender/prerender_histograms.h" | 5 #include "chrome/browser/prerender/prerender_histograms.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 return ComposeHistogramName("exp" + std::string(1, experiment_id + '0'), | 45 return ComposeHistogramName("exp" + std::string(1, experiment_id + '0'), |
46 name); | 46 name); |
47 } | 47 } |
48 | 48 |
49 if (experiment_id != kNoExperiment) | 49 if (experiment_id != kNoExperiment) |
50 return ComposeHistogramName("wash", name); | 50 return ComposeHistogramName("wash", name); |
51 | 51 |
52 switch (origin) { | 52 switch (origin) { |
53 case ORIGIN_OMNIBOX: | 53 case ORIGIN_OMNIBOX: |
54 return ComposeHistogramName("omnibox", name); | 54 return ComposeHistogramName("omnibox", name); |
55 case ORIGIN_LINK_REL_PRERENDER: | 55 case ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN: |
56 return ComposeHistogramName("web", name); | 56 return ComposeHistogramName("websame", name); |
57 case ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN: | |
58 return ComposeHistogramName("webcross", name); | |
mmenke
2012/10/17 15:12:16
nit: Move these after ORIGIN_NONE, to match decla
gavinp
2012/10/17 20:57:49
Done.
| |
57 case ORIGIN_NONE: | 59 case ORIGIN_NONE: |
58 return ComposeHistogramName("none", name); | 60 return ComposeHistogramName("none", name); |
59 case ORIGIN_GWS_PRERENDER: // Handled above. | 61 case ORIGIN_GWS_PRERENDER: // Handled above. |
60 default: | 62 default: |
61 NOTREACHED(); | 63 NOTREACHED(); |
62 break; | 64 break; |
63 }; | 65 }; |
64 | 66 |
65 // Dummy return value to make the compiler happy. | 67 // Dummy return value to make the compiler happy. |
66 NOTREACHED(); | 68 NOTREACHED(); |
(...skipping 22 matching lines...) Expand all Loading... | |
89 | 91 |
90 #define PREFIXED_HISTOGRAM_INTERNAL(origin, experiment, wash, HISTOGRAM, \ | 92 #define PREFIXED_HISTOGRAM_INTERNAL(origin, experiment, wash, HISTOGRAM, \ |
91 histogram_name) { \ | 93 histogram_name) { \ |
92 { \ | 94 { \ |
93 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ | 95 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ |
94 std::string name = ComposeHistogramName("", histogram_name); \ | 96 std::string name = ComposeHistogramName("", histogram_name); \ |
95 HISTOGRAM; \ | 97 HISTOGRAM; \ |
96 } \ | 98 } \ |
97 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ | 99 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ |
98 std::string name = GetHistogramName(origin, experiment, wash, \ | 100 std::string name = GetHistogramName(origin, experiment, wash, \ |
99 histogram_name); \ | 101 histogram_name); \ |
mmenke
2012/10/17 15:12:16
Would you mind just inlining GetHistogramName into
gavinp
2012/10/17 20:57:49
I have a lot of refactoring I could imagine happen
| |
100 static uint8 recording_experiment = kNoExperiment; \ | 102 static uint8 recording_experiment = kNoExperiment; \ |
101 if (recording_experiment == kNoExperiment && experiment != kNoExperiment) \ | 103 if (recording_experiment == kNoExperiment && experiment != kNoExperiment) \ |
102 recording_experiment = experiment; \ | 104 recording_experiment = experiment; \ |
103 if (wash) { \ | 105 if (wash) { \ |
104 HISTOGRAM; \ | 106 HISTOGRAM; \ |
105 } else if (experiment != kNoExperiment && \ | 107 } else if (experiment != kNoExperiment && \ |
106 (origin != ORIGIN_GWS_PRERENDER || \ | 108 (origin != ORIGIN_GWS_PRERENDER || \ |
107 experiment != recording_experiment)) { \ | 109 experiment != recording_experiment)) { \ |
108 } else if (origin == ORIGIN_LINK_REL_PRERENDER) { \ | |
109 HISTOGRAM; \ | |
110 } else if (origin == ORIGIN_OMNIBOX) { \ | 110 } else if (origin == ORIGIN_OMNIBOX) { \ |
111 HISTOGRAM; \ | 111 HISTOGRAM; \ |
112 } else if (origin == ORIGIN_NONE) { \ | 112 } else if (origin == ORIGIN_NONE) { \ |
113 HISTOGRAM; \ | 113 HISTOGRAM; \ |
114 } else if (origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN) { \ | |
115 HISTOGRAM; \ | |
116 } else if (origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN) { \ | |
117 HISTOGRAM; \ | |
114 } else if (experiment != kNoExperiment) { \ | 118 } else if (experiment != kNoExperiment) { \ |
115 HISTOGRAM; \ | 119 HISTOGRAM; \ |
116 } else { \ | 120 } else { \ |
117 HISTOGRAM; \ | 121 HISTOGRAM; \ |
118 } \ | 122 } \ |
119 } | 123 } |
120 | 124 |
121 PrerenderHistograms::PrerenderHistograms() | 125 PrerenderHistograms::PrerenderHistograms() |
122 : last_experiment_id_(kNoExperiment), | 126 : last_experiment_id_(kNoExperiment), |
123 last_origin_(ORIGIN_LINK_REL_PRERENDER), | 127 last_origin_(ORIGIN_MAX), |
124 origin_experiment_wash_(false), | 128 origin_experiment_wash_(false), |
125 seen_any_pageload_(true), | 129 seen_any_pageload_(true), |
126 seen_pageload_started_after_prerender_(true) { | 130 seen_pageload_started_after_prerender_(true) { |
127 } | 131 } |
128 | 132 |
129 void PrerenderHistograms::RecordPrerender(Origin origin, const GURL& url) { | 133 void PrerenderHistograms::RecordPrerender(Origin origin, const GURL& url) { |
130 // Check if we are doing an experiment. | 134 // Check if we are doing an experiment. |
131 uint8 experiment = GetQueryStringBasedExperiment(url); | 135 uint8 experiment = GetQueryStringBasedExperiment(url); |
132 | 136 |
133 // We need to update last_experiment_id_, last_origin_, and | 137 // We need to update last_experiment_id_, last_origin_, and |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 return last_experiment_id_; | 391 return last_experiment_id_; |
388 } | 392 } |
389 | 393 |
390 bool PrerenderHistograms::IsOriginExperimentWash() const { | 394 bool PrerenderHistograms::IsOriginExperimentWash() const { |
391 if (!WithinWindow()) | 395 if (!WithinWindow()) |
392 return false; | 396 return false; |
393 return origin_experiment_wash_; | 397 return origin_experiment_wash_; |
394 } | 398 } |
395 | 399 |
396 } // namespace prerender | 400 } // namespace prerender |
OLD | NEW |