| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 const std::string& name) { | 22 const std::string& name) { |
| 23 if (prefix_type.empty()) | 23 if (prefix_type.empty()) |
| 24 return std::string("Prerender.") + name; | 24 return std::string("Prerender.") + name; |
| 25 return std::string("Prerender.") + prefix_type + std::string("_") + name; | 25 return std::string("Prerender.") + prefix_type + std::string("_") + name; |
| 26 } | 26 } |
| 27 | 27 |
| 28 std::string GetHistogramName(Origin origin, uint8 experiment_id, | 28 std::string GetHistogramName(Origin origin, uint8 experiment_id, |
| 29 bool is_wash, const std::string& name) { | 29 bool is_wash, const std::string& name) { |
| 30 if (is_wash) | 30 if (is_wash) |
| 31 return ComposeHistogramName("wash", name); | 31 return ComposeHistogramName("wash", name); |
| 32 |
| 33 if (origin == ORIGIN_GWS_PRERENDER) { |
| 34 if (experiment_id == kNoExperiment) |
| 35 return ComposeHistogramName("gws", name); |
| 36 return ComposeHistogramName("exp" + std::string(1, experiment_id + '0'), |
| 37 name); |
| 38 } |
| 39 |
| 40 if (experiment_id != kNoExperiment) |
| 41 return ComposeHistogramName("wash", name); |
| 42 |
| 32 switch (origin) { | 43 switch (origin) { |
| 33 case ORIGIN_OMNIBOX_ORIGINAL: | 44 case ORIGIN_OMNIBOX_ORIGINAL: |
| 34 if (experiment_id != kNoExperiment) | |
| 35 return ComposeHistogramName("wash", name); | |
| 36 return ComposeHistogramName("omnibox_original", name); | 45 return ComposeHistogramName("omnibox_original", name); |
| 37 case ORIGIN_OMNIBOX_CONSERVATIVE: | 46 case ORIGIN_OMNIBOX_CONSERVATIVE: |
| 38 if (experiment_id != kNoExperiment) | |
| 39 return ComposeHistogramName("wash", name); | |
| 40 return ComposeHistogramName("omnibox_conservative", name); | 47 return ComposeHistogramName("omnibox_conservative", name); |
| 41 case ORIGIN_OMNIBOX_EXACT: | 48 case ORIGIN_OMNIBOX_EXACT: |
| 42 if (experiment_id != kNoExperiment) | |
| 43 return ComposeHistogramName("wash", name); | |
| 44 return ComposeHistogramName("omnibox_exact", name); | 49 return ComposeHistogramName("omnibox_exact", name); |
| 50 case ORIGIN_OMNIBOX_EXACT_FULL: |
| 51 return ComposeHistogramName("omnibox_exact_full", name); |
| 45 case ORIGIN_LINK_REL_PRERENDER: | 52 case ORIGIN_LINK_REL_PRERENDER: |
| 46 if (experiment_id != kNoExperiment) | |
| 47 return ComposeHistogramName("wash", name); | |
| 48 return ComposeHistogramName("web", name); | 53 return ComposeHistogramName("web", name); |
| 49 case ORIGIN_GWS_PRERENDER: | 54 case ORIGIN_GWS_PRERENDER: // Handled above. |
| 50 if (experiment_id == kNoExperiment) | |
| 51 return ComposeHistogramName("gws", name); | |
| 52 return ComposeHistogramName("exp" + std::string(1, experiment_id + '0'), | |
| 53 name); | |
| 54 default: | 55 default: |
| 55 NOTREACHED(); | 56 NOTREACHED(); |
| 56 break; | 57 break; |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 // Dummy return value to make the compiler happy. | 60 // Dummy return value to make the compiler happy. |
| 60 NOTREACHED(); | 61 NOTREACHED(); |
| 61 return ComposeHistogramName("wash", name); | 62 return ComposeHistogramName("wash", name); |
| 62 } | 63 } |
| 63 | 64 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 90 static uint8 recording_experiment = kNoExperiment; \ | 91 static uint8 recording_experiment = kNoExperiment; \ |
| 91 if (recording_experiment == kNoExperiment && experiment != kNoExperiment) \ | 92 if (recording_experiment == kNoExperiment && experiment != kNoExperiment) \ |
| 92 recording_experiment = experiment; \ | 93 recording_experiment = experiment; \ |
| 93 if (wash) { \ | 94 if (wash) { \ |
| 94 HISTOGRAM; \ | 95 HISTOGRAM; \ |
| 95 } else if (experiment != kNoExperiment && \ | 96 } else if (experiment != kNoExperiment && \ |
| 96 (origin != ORIGIN_GWS_PRERENDER || \ | 97 (origin != ORIGIN_GWS_PRERENDER || \ |
| 97 experiment != recording_experiment)) { \ | 98 experiment != recording_experiment)) { \ |
| 98 } else if (origin == ORIGIN_LINK_REL_PRERENDER) { \ | 99 } else if (origin == ORIGIN_LINK_REL_PRERENDER) { \ |
| 99 HISTOGRAM; \ | 100 HISTOGRAM; \ |
| 100 } else if (origin == ORIGIN_OMNIBOX_ORIGINAL) { \ | 101 } else if (origin == ORIGIN_OMNIBOX_ORIGINAL || \ |
| 101 HISTOGRAM; \ | 102 origin == ORIGIN_OMNIBOX_CONSERVATIVE || \ |
| 102 } else if (origin == ORIGIN_OMNIBOX_CONSERVATIVE) { \ | 103 origin == ORIGIN_OMNIBOX_EXACT || \ |
| 103 HISTOGRAM; \ | 104 origin == ORIGIN_OMNIBOX_EXACT_FULL) { \ |
| 104 } else if (origin == ORIGIN_OMNIBOX_EXACT) { \ | |
| 105 HISTOGRAM; \ | 105 HISTOGRAM; \ |
| 106 } else if (experiment != kNoExperiment) { \ | 106 } else if (experiment != kNoExperiment) { \ |
| 107 HISTOGRAM; \ | 107 HISTOGRAM; \ |
| 108 } else { \ | 108 } else { \ |
| 109 HISTOGRAM; \ | 109 HISTOGRAM; \ |
| 110 } \ | 110 } \ |
| 111 } | 111 } |
| 112 | 112 |
| 113 PrerenderHistograms::PrerenderHistograms() | 113 PrerenderHistograms::PrerenderHistograms() |
| 114 : last_experiment_id_(kNoExperiment), | 114 : last_experiment_id_(kNoExperiment), |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 return last_origin_; | 271 return last_origin_; |
| 272 } | 272 } |
| 273 | 273 |
| 274 bool PrerenderHistograms::IsOriginExperimentWash() const { | 274 bool PrerenderHistograms::IsOriginExperimentWash() const { |
| 275 if (!WithinWindow()) | 275 if (!WithinWindow()) |
| 276 return false; | 276 return false; |
| 277 return origin_experiment_wash_; | 277 return origin_experiment_wash_; |
| 278 } | 278 } |
| 279 | 279 |
| 280 } // namespace prerender | 280 } // namespace prerender |
| OLD | NEW |