Chromium Code Reviews| Index: chrome/browser/prerender/prerender_histograms.cc |
| diff --git a/chrome/browser/prerender/prerender_histograms.cc b/chrome/browser/prerender/prerender_histograms.cc |
| index 3e4b4bfa1915016af5bb4cf47d24037264b2f2f0..7afe01dccfb5830c4e3465ceee1aad9e842c6b36 100644 |
| --- a/chrome/browser/prerender/prerender_histograms.cc |
| +++ b/chrome/browser/prerender/prerender_histograms.cc |
| @@ -7,18 +7,29 @@ |
| #include <string> |
| #include "base/format_macros.h" |
| +#include "base/logging.h" |
| #include "base/metrics/histogram.h" |
| #include "base/strings/stringprintf.h" |
| -#include "chrome/browser/predictors/autocomplete_action_predictor.h" |
| #include "chrome/browser/prerender/prerender_manager.h" |
| #include "chrome/browser/prerender/prerender_util.h" |
| -using predictors::AutocompleteActionPredictor; |
| - |
| namespace prerender { |
| namespace { |
| +// This enum is used to define the buckets for the |
| +// "Prerender.NoStatePrefetchResourceCount" histogram family. |
| +// Hence, existing enumerated constants should never be deleted or reordered, |
| +// and new constants should only be appended at the end of the enumeration. |
| +enum NoStatePrefetchResourceType { |
| + MAIN_RESOURCE_CACHEABLE = 0, |
| + MAIN_RESOURCE_NO_STORE = 1, |
| + SUB_RESOURCE_CACHEABLE = 2, |
| + SUB_RESOURCE_NO_STORE = 3, |
| + |
| + NO_STATE_PREFETCH_RESOURCE_TYPE_COUNT // Must be the last. |
| +}; |
| + |
| // Time window for which we will record windowed PLTs from the last observed |
| // link rel=prefetch tag. This is not intended to be the same as the prerender |
| // ttl, it's just intended to be a window during which a prerender has likely |
| @@ -383,6 +394,28 @@ void PrerenderHistograms::RecordNetworkBytes(Origin origin, |
| } |
| } |
| +void PrerenderHistograms::RecordResourcePrefetch(Origin origin, |
| + bool is_main_resource, |
| + bool is_no_store) { |
| + DCHECK(thread_checker_.CalledOnValidThread()); |
| + NoStatePrefetchResourceType type = |
| + is_main_resource |
| + ? (is_no_store ? MAIN_RESOURCE_NO_STORE : MAIN_RESOURCE_CACHEABLE) |
| + : (is_no_store ? SUB_RESOURCE_NO_STORE : SUB_RESOURCE_CACHEABLE); |
| + DCHECK_LT(type, NO_STATE_PREFETCH_RESOURCE_TYPE_COUNT); |
| + |
| + std::string histogram_name = |
| + GetHistogramName(origin, IsOriginWash(), "NoStatePrefetchResourceCount"); |
|
pasko
2016/08/30 15:11:19
nit: I think "Count" is implied in histograms, Bla
|
| + |
| + // Unrolls UMA_HISTOGRAM_ENUMERATION, required to support dynamic histogram |
| + // name. |
| + base::HistogramBase* histogram_pointer = base::LinearHistogram::FactoryGet( |
| + histogram_name, 1, NO_STATE_PREFETCH_RESOURCE_TYPE_COUNT, |
| + NO_STATE_PREFETCH_RESOURCE_TYPE_COUNT + 1, |
| + base::HistogramBase::kUmaTargetedHistogramFlag); |
| + histogram_pointer->Add(type); |
| +} |
| + |
| bool PrerenderHistograms::IsOriginWash() const { |
| if (!WithinWindow()) |
| return false; |