| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 case ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN: | 89 case ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN: |
| 90 return ComposeHistogramName("webcross", name); | 90 return ComposeHistogramName("webcross", name); |
| 91 case ORIGIN_EXTERNAL_REQUEST: | 91 case ORIGIN_EXTERNAL_REQUEST: |
| 92 return ComposeHistogramName("externalrequest", name); | 92 return ComposeHistogramName("externalrequest", name); |
| 93 case ORIGIN_INSTANT: | 93 case ORIGIN_INSTANT: |
| 94 return ComposeHistogramName("Instant", name); | 94 return ComposeHistogramName("Instant", name); |
| 95 case ORIGIN_LINK_REL_NEXT: | 95 case ORIGIN_LINK_REL_NEXT: |
| 96 return ComposeHistogramName("webnext", name); | 96 return ComposeHistogramName("webnext", name); |
| 97 case ORIGIN_GWS_PRERENDER: | 97 case ORIGIN_GWS_PRERENDER: |
| 98 return ComposeHistogramName("gws", name); | 98 return ComposeHistogramName("gws", name); |
| 99 case ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR: | 99 case ORIGIN_EXTERNAL_REQUEST_FORCED_PRERENDER: |
| 100 return ComposeHistogramName("externalrequestforced", name); | 100 return ComposeHistogramName("externalrequestforced", name); |
| 101 case ORIGIN_OFFLINE: | 101 case ORIGIN_OFFLINE: |
| 102 return ComposeHistogramName("offline", name); | 102 return ComposeHistogramName("offline", name); |
| 103 default: | 103 default: |
| 104 NOTREACHED(); | 104 NOTREACHED(); |
| 105 break; | 105 break; |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Dummy return value to make the compiler happy. | 108 // Dummy return value to make the compiler happy. |
| 109 NOTREACHED(); | 109 NOTREACHED(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 123 // Helper macros for origin-based histogram reporting. All HISTOGRAM arguments | 123 // Helper macros for origin-based histogram reporting. All HISTOGRAM arguments |
| 124 // must be UMA_HISTOGRAM... macros that contain an argument "name" which these | 124 // must be UMA_HISTOGRAM... macros that contain an argument "name" which these |
| 125 // macros will eventually substitute for the actual name used. | 125 // macros will eventually substitute for the actual name used. |
| 126 #define PREFIXED_HISTOGRAM(histogram_name, origin, HISTOGRAM) \ | 126 #define PREFIXED_HISTOGRAM(histogram_name, origin, HISTOGRAM) \ |
| 127 PREFIXED_HISTOGRAM_INTERNAL(origin, IsOriginWash(), HISTOGRAM, histogram_name) | 127 PREFIXED_HISTOGRAM_INTERNAL(origin, IsOriginWash(), HISTOGRAM, histogram_name) |
| 128 | 128 |
| 129 #define PREFIXED_HISTOGRAM_ORIGIN_EXPERIMENT(histogram_name, origin, \ | 129 #define PREFIXED_HISTOGRAM_ORIGIN_EXPERIMENT(histogram_name, origin, \ |
| 130 HISTOGRAM) \ | 130 HISTOGRAM) \ |
| 131 PREFIXED_HISTOGRAM_INTERNAL(origin, false, HISTOGRAM, histogram_name) | 131 PREFIXED_HISTOGRAM_INTERNAL(origin, false, HISTOGRAM, histogram_name) |
| 132 | 132 |
| 133 #define PREFIXED_HISTOGRAM_INTERNAL(origin, wash, HISTOGRAM, histogram_name) \ | 133 #define PREFIXED_HISTOGRAM_INTERNAL(origin, wash, HISTOGRAM, histogram_name) \ |
| 134 do { \ | 134 do { \ |
| 135 { \ | 135 { \ |
| 136 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ | 136 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ |
| 137 std::string name = ComposeHistogramName(std::string(), histogram_name); \ | 137 std::string name = ComposeHistogramName(std::string(), histogram_name); \ |
| 138 HISTOGRAM; \ | 138 HISTOGRAM; \ |
| 139 } \ | 139 } \ |
| 140 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ | 140 /* Do not rename. HISTOGRAM expects a local variable "name". */ \ |
| 141 std::string name = GetHistogramName(origin, wash, histogram_name); \ | 141 std::string name = GetHistogramName(origin, wash, histogram_name); \ |
| 142 /* Branching because HISTOGRAM is caching the histogram into a static. */ \ | 142 /* Branching because HISTOGRAM is caching the histogram into a static. */ \ |
| 143 if (wash) { \ | 143 if (wash) { \ |
| 144 HISTOGRAM; \ | 144 HISTOGRAM; \ |
| 145 } else if (origin == ORIGIN_OMNIBOX) { \ | 145 } else if (origin == ORIGIN_OMNIBOX) { \ |
| 146 HISTOGRAM; \ | 146 HISTOGRAM; \ |
| 147 } else if (origin == ORIGIN_NONE) { \ | 147 } else if (origin == ORIGIN_NONE) { \ |
| 148 HISTOGRAM; \ | 148 HISTOGRAM; \ |
| 149 } else if (origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN) { \ | 149 } else if (origin == ORIGIN_LINK_REL_PRERENDER_SAMEDOMAIN) { \ |
| 150 HISTOGRAM; \ | 150 HISTOGRAM; \ |
| 151 } else if (origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN) { \ | 151 } else if (origin == ORIGIN_LINK_REL_PRERENDER_CROSSDOMAIN) { \ |
| 152 HISTOGRAM; \ | 152 HISTOGRAM; \ |
| 153 } else if (origin == ORIGIN_EXTERNAL_REQUEST) { \ | 153 } else if (origin == ORIGIN_EXTERNAL_REQUEST) { \ |
| 154 HISTOGRAM; \ | 154 HISTOGRAM; \ |
| 155 } else if (origin == ORIGIN_INSTANT) { \ | 155 } else if (origin == ORIGIN_INSTANT) { \ |
| 156 HISTOGRAM; \ | 156 HISTOGRAM; \ |
| 157 } else if (origin == ORIGIN_LINK_REL_NEXT) { \ | 157 } else if (origin == ORIGIN_LINK_REL_NEXT) { \ |
| 158 HISTOGRAM; \ | 158 HISTOGRAM; \ |
| 159 } else if (origin == ORIGIN_EXTERNAL_REQUEST_FORCED_CELLULAR) { \ | 159 } else if (origin == ORIGIN_EXTERNAL_REQUEST_FORCED_PRERENDER) { \ |
| 160 HISTOGRAM; \ | 160 HISTOGRAM; \ |
| 161 } else if (origin == ORIGIN_OFFLINE) { \ | 161 } else if (origin == ORIGIN_OFFLINE) { \ |
| 162 HISTOGRAM; \ | 162 HISTOGRAM; \ |
| 163 } else { \ | 163 } else { \ |
| 164 HISTOGRAM; \ | 164 HISTOGRAM; \ |
| 165 } \ | 165 } \ |
| 166 } while (0) | 166 } while (0) |
| 167 | 167 |
| 168 PrerenderHistograms::PrerenderHistograms() | 168 PrerenderHistograms::PrerenderHistograms() |
| 169 : last_origin_(ORIGIN_MAX), | 169 : last_origin_(ORIGIN_MAX), |
| 170 origin_wash_(false), | 170 origin_wash_(false), |
| 171 seen_any_pageload_(true), | 171 seen_any_pageload_(true), |
| 172 seen_pageload_started_after_prerender_(true) { | 172 seen_pageload_started_after_prerender_(true) { |
| 173 } | 173 } |
| 174 | 174 |
| 175 void PrerenderHistograms::RecordPrerender(Origin origin, const GURL& url) { | 175 void PrerenderHistograms::RecordPrerender(Origin origin, const GURL& url) { |
| 176 // We need to update last_origin_ and origin_wash_. | 176 // We need to update last_origin_ and origin_wash_. |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 base::TimeDelta::FromMinutes(2), time, 50); | 492 base::TimeDelta::FromMinutes(2), time, 50); |
| 493 } | 493 } |
| 494 | 494 |
| 495 bool PrerenderHistograms::IsOriginWash() const { | 495 bool PrerenderHistograms::IsOriginWash() const { |
| 496 if (!WithinWindow()) | 496 if (!WithinWindow()) |
| 497 return false; | 497 return false; |
| 498 return origin_wash_; | 498 return origin_wash_; |
| 499 } | 499 } |
| 500 | 500 |
| 501 } // namespace prerender | 501 } // namespace prerender |
| OLD | NEW |