Chromium Code Reviews| 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/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 } else { \ | 136 } else { \ |
| 137 HISTOGRAM; \ | 137 HISTOGRAM; \ |
| 138 } \ | 138 } \ |
| 139 } while (0) | 139 } while (0) |
| 140 | 140 |
| 141 PrerenderHistograms::PrerenderHistograms() | 141 PrerenderHistograms::PrerenderHistograms() |
| 142 : last_experiment_id_(kNoExperiment), | 142 : last_experiment_id_(kNoExperiment), |
| 143 last_origin_(ORIGIN_MAX), | 143 last_origin_(ORIGIN_MAX), |
| 144 origin_experiment_wash_(false), | 144 origin_experiment_wash_(false), |
| 145 seen_any_pageload_(true), | 145 seen_any_pageload_(true), |
| 146 seen_pageload_started_after_prerender_(true) { | 146 seen_pageload_started_after_prerender_(true), |
| 147 last_profile_network_bytes_(0) { | |
| 147 } | 148 } |
| 148 | 149 |
| 149 void PrerenderHistograms::RecordPrerender(Origin origin, const GURL& url) { | 150 void PrerenderHistograms::RecordPrerender(Origin origin, const GURL& url) { |
| 150 // Check if we are doing an experiment. | 151 // Check if we are doing an experiment. |
| 151 uint8 experiment = GetQueryStringBasedExperiment(url); | 152 uint8 experiment = GetQueryStringBasedExperiment(url); |
| 152 | 153 |
| 153 // We need to update last_experiment_id_, last_origin_, and | 154 // We need to update last_experiment_id_, last_origin_, and |
| 154 // origin_experiment_wash_. | 155 // origin_experiment_wash_. |
| 155 if (!WithinWindow()) { | 156 if (!WithinWindow()) { |
| 156 // If we are outside a window, this is a fresh start and we are fine, | 157 // If we are outside a window, this is a fresh start and we are fine, |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 | 403 |
| 403 void PrerenderHistograms::RecordPrerenderPageVisitedStatus( | 404 void PrerenderHistograms::RecordPrerenderPageVisitedStatus( |
| 404 Origin origin, | 405 Origin origin, |
| 405 uint8 experiment_id, | 406 uint8 experiment_id, |
| 406 bool visited_before) const { | 407 bool visited_before) const { |
| 407 PREFIXED_HISTOGRAM_ORIGIN_EXPERIMENT( | 408 PREFIXED_HISTOGRAM_ORIGIN_EXPERIMENT( |
| 408 "PageVisitedStatus", origin, experiment_id, | 409 "PageVisitedStatus", origin, experiment_id, |
| 409 UMA_HISTOGRAM_BOOLEAN(name, visited_before)); | 410 UMA_HISTOGRAM_BOOLEAN(name, visited_before)); |
| 410 } | 411 } |
| 411 | 412 |
| 413 void PrerenderHistograms::RecordBytes(bool used, | |
| 414 int64 prerender_bytes, | |
| 415 int64 profile_bytes) { | |
| 416 if (used) | |
| 417 UMA_HISTOGRAM_COUNTS("Prerender.NetworkBytes.Used.KB", | |
|
tburkard
2014/02/12 19:54:56
nit: shouldnt { } be used if it's more than one li
jkarlin
2014/02/13 13:24:49
Done.
| |
| 418 prerender_bytes >> 10); | |
| 419 else | |
| 420 UMA_HISTOGRAM_COUNTS("Prerender.NetworkBytes.Wasted.KB", | |
| 421 prerender_bytes >> 10); | |
| 422 | |
| 423 int64 recent_profile_bytes = profile_bytes - last_profile_network_bytes_; | |
|
tburkard
2014/02/12 19:54:56
I would keep PrerenderHistograms dead simple, and
jkarlin
2014/02/13 13:24:49
Done.
| |
| 424 last_profile_network_bytes_ = profile_bytes; | |
| 425 UMA_HISTOGRAM_COUNTS("Prerender.NetworkBytes.TotalForProfile.KB", | |
| 426 recent_profile_bytes >> 10); | |
| 427 } | |
| 428 | |
| 412 uint8 PrerenderHistograms::GetCurrentExperimentId() const { | 429 uint8 PrerenderHistograms::GetCurrentExperimentId() const { |
| 413 if (!WithinWindow()) | 430 if (!WithinWindow()) |
| 414 return kNoExperiment; | 431 return kNoExperiment; |
| 415 return last_experiment_id_; | 432 return last_experiment_id_; |
| 416 } | 433 } |
| 417 | 434 |
| 418 bool PrerenderHistograms::IsOriginExperimentWash() const { | 435 bool PrerenderHistograms::IsOriginExperimentWash() const { |
| 419 if (!WithinWindow()) | 436 if (!WithinWindow()) |
| 420 return false; | 437 return false; |
| 421 return origin_experiment_wash_; | 438 return origin_experiment_wash_; |
| 422 } | 439 } |
| 423 | 440 |
| 424 } // namespace prerender | 441 } // namespace prerender |
| OLD | NEW |