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

Unified Diff: ios/chrome/browser/desktop_promotion/histogram_macros.h

Issue 2643723004: Add Desktop iOS promotion logging to chrome ios app. (Closed)
Patch Set: create new file for sync service & move prefs to pref_names.h Created 3 years, 11 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
Index: ios/chrome/browser/desktop_promotion/histogram_macros.h
diff --git a/ios/chrome/browser/desktop_promotion/histogram_macros.h b/ios/chrome/browser/desktop_promotion/histogram_macros.h
new file mode 100644
index 0000000000000000000000000000000000000000..289a9774d3a68f6e5f951e0192933c73ca0d485f
--- /dev/null
+++ b/ios/chrome/browser/desktop_promotion/histogram_macros.h
@@ -0,0 +1,38 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_DESKTOP_PROMOTION_HISTOGRAM_MACROS_H_
+#define IOS_CHROME_BROWSER_DESKTOP_PROMOTION_HISTOGRAM_MACROS_H_
+
+#include "base/metrics/histogram.h"
+
+// HISTOGRAM_POINTER_BLOCK differ from STATIC_HISTOGRAM_POINTER_BLOCK
+// on using static histogram pointer, in this one we create a new histogram
+// from the histogram_factory_get_invocation each time this is called.
+// This is needed on the desktop promotion logging as there are cases where the
+// same call will be trying to log different histogram names.
+#define HISTOGRAM_POINTER_BLOCK(constant_histogram_name, \
+ histogram_add_method_invocation, \
+ histogram_factory_get_invocation) \
+ do { \
+ base::HistogramBase* histogram_pointer = histogram_factory_get_invocation; \
+ histogram_pointer->histogram_add_method_invocation; \
+ } while (0)
+
+// This UMA_HISTOGRAM_CUSTOM_COUNT_NO_CACHE uses the HISTOGRAM_POINTER_BLOCK
+// instead of STATIC_HISTOGRAM_POINTER_BLOCK which handles being called with
+// different names from same function.
+#define UMA_HISTOGRAM_CUSTOM_COUNT_NO_CACHE(name, sample, min, max, \
+ bucket_count) \
+ HISTOGRAM_POINTER_BLOCK(name, Add(sample), \
+ base::Histogram::FactoryGet( \
+ name, min, max, bucket_count, \
+ base::HistogramBase::kUmaTargetedHistogramFlag))
+
+// Count histogram with no caching. This is used for collecting numeric data
+// when the number of buckets is 50 and the max value doesn't exceed 1000.
+#define UMA_HISTOGRAM_COUNT_1000_NO_CACHE(name, sample) \
+ UMA_HISTOGRAM_CUSTOM_COUNT_NO_CACHE(name, sample, 1, 1000, 50)
+
+#endif // IOS_CHROME_BROWSER_DESKTOP_PROMOTION_HISTOGRAM_MACROS_H_

Powered by Google App Engine
This is Rietveld 408576698