Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1234)

Unified Diff: chrome/browser/prerender/prerender_histograms.cc

Issue 2287993003: [NoStatePrefetch] Add UMA histogram to count prefetch requests (Closed)
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prerender/prerender_histograms.h ('k') | chrome/browser/prerender/prerender_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_histograms.cc
diff --git a/chrome/browser/prerender/prerender_histograms.cc b/chrome/browser/prerender/prerender_histograms.cc
index 9bf9ad997593953faf2825d2145f8263df88af45..895adb0c3cf6a42412dcee04f25e25c9fad529b5 100644
--- a/chrome/browser/prerender/prerender_histograms.cc
+++ b/chrome/browser/prerender/prerender_histograms.cc
@@ -7,18 +7,30 @@
#include <string>
#include "base/format_macros.h"
+#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.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
@@ -354,7 +366,7 @@ void PrerenderHistograms::RecordFinalStatus(
void PrerenderHistograms::RecordNetworkBytes(Origin origin,
bool used,
int64_t prerender_bytes,
- int64_t profile_bytes) {
+ int64_t profile_bytes) const {
const int kHistogramMin = 1;
const int kHistogramMax = 100000000; // 100M.
const int kBucketCount = 50;
@@ -383,6 +395,28 @@ void PrerenderHistograms::RecordNetworkBytes(Origin origin,
}
}
+void PrerenderHistograms::RecordResourcePrefetch(Origin origin,
+ bool is_main_resource,
+ bool is_no_store) const {
+ 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(), "NoStatePrefetchResourceTypes");
+
+ // 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;
« no previous file with comments | « chrome/browser/prerender/prerender_histograms.h ('k') | chrome/browser/prerender/prerender_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698