Commit a67dd55f authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Normalize definition of CacheMetrics::kMaxValue.

For consistency, kMaxValue should share the value of the highest enumerator,
not be unique.

This also updates the internal macros for enumeration histograms to allow
flags to be passed through, so it can be reused for both the regular and
the local versions of the histogram macros.

Bug: 705169, 742517
Change-Id: Ia93e18e3a69bd828f4cbc4c7f1020b4cf3f13ca1
Reviewed-on: https://chromium-review.googlesource.com/988678
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547363}
parent 10ca7222
......@@ -79,7 +79,8 @@
#define UMA_HISTOGRAM_ENUMERATION(name, ...) \
CR_EXPAND_ARG(INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \
__VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \
INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY)(name, __VA_ARGS__))
INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY)( \
name, __VA_ARGS__, base::HistogramBase::kUmaTargetedHistogramFlag))
// Histogram for boolean values.
......
......@@ -158,16 +158,16 @@ struct EnumSizeTraits<
// arguments.
#define INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO(_1, _2, NAME, ...) NAME
#define INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY(name, sample) \
#define INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY(name, sample, \
flags) \
INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \
name, sample, base::internal::EnumSizeTraits<decltype(sample)>::Count(), \
base::HistogramBase::kUmaTargetedHistogramFlag)
flags)
// Note: The value in |sample| must be strictly less than |enum_size|.
#define INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY(name, sample, \
enum_size) \
INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \
name, sample, enum_size, base::HistogramBase::kUmaTargetedHistogramFlag)
#define INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY(name, sample, \
enum_size, flags) \
INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG(name, sample, enum_size, flags)
// Similar to the previous macro but intended for enumerations. This delegates
// the work to the previous macro, but supports scoped enumerations as well by
......
......@@ -18,10 +18,11 @@
//
// For usage details, see the equivalents in histogram_macros.h.
#define LOCAL_HISTOGRAM_ENUMERATION(name, sample, enum_max) \
INTERNAL_HISTOGRAM_ENUMERATION_WITH_FLAG( \
name, sample, enum_max, \
base::HistogramBase::kNoFlags)
#define LOCAL_HISTOGRAM_ENUMERATION(name, ...) \
CR_EXPAND_ARG(INTERNAL_UMA_HISTOGRAM_ENUMERATION_GET_MACRO( \
__VA_ARGS__, INTERNAL_UMA_HISTOGRAM_ENUMERATION_SPECIFY_BOUNDARY, \
INTERNAL_UMA_HISTOGRAM_ENUMERATION_DEDUCE_BOUNDARY)( \
name, __VA_ARGS__, base::HistogramBase::kNoFlags))
#define LOCAL_HISTOGRAM_BOOLEAN(name, sample) \
STATIC_HISTOGRAM_POINTER_BLOCK(name, AddBoolean(sample), \
......
......@@ -87,7 +87,7 @@ scoped_refptr<LocalStorageCachedArea> LocalStorageCachedAreas::GetCachedArea(
kMiss = 0, // Area not in cache.
kHit = 1, // Area with refcount = 0 loaded from cache.
kUnused = 2, // Cache was not used. Area had refcount > 0.
kMaxValue
kMaxValue = kUnused,
};
auto namespace_it = cached_namespaces_.find(namespace_id);
......@@ -110,13 +110,10 @@ scoped_refptr<LocalStorageCachedArea> LocalStorageCachedAreas::GetCachedArea(
result = cache_it->second;
}
}
if (namespace_id == kLocalStorageNamespaceId) {
UMA_HISTOGRAM_ENUMERATION("LocalStorage.RendererAreaCacheHit", metric,
CacheMetrics::kMaxValue);
} else {
LOCAL_HISTOGRAM_ENUMERATION("SessionStorage.RendererAreaCacheHit", metric,
CacheMetrics::kMaxValue);
}
if (namespace_id == kLocalStorageNamespaceId)
UMA_HISTOGRAM_ENUMERATION("LocalStorage.RendererAreaCacheHit", metric);
else
LOCAL_HISTOGRAM_ENUMERATION("SessionStorage.RendererAreaCacheHit", metric);
if (!result) {
ClearAreasIfNeeded();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment