Commit 2126a491 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Replace mismatch macro with function

Change-Id: I61465c05b77282e229bf472a57f044c092fe4079
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001121
Commit-Queue: Carlos Knippschild <carlosk@chromium.org>
Auto-Submit: Dan H <harringtond@chromium.org>
Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732246}
parent 4bb37d93
...@@ -41,21 +41,16 @@ enum class FeedHostMismatch { ...@@ -41,21 +41,16 @@ enum class FeedHostMismatch {
kMaxValue = kBothAreSet, kMaxValue = kBothAreSet,
}; };
// Copies boolean args into temps to avoid evaluating them multiple times. FeedHostMismatch GetMismatch(bool feed_is_set, bool host_is_set) {
#define UMA_HISTOGRAM_MISMATCH(name, feed_is_set, host_is_set) \ if (feed_is_set && host_is_set) {
do { \ return FeedHostMismatch::kBothAreSet;
bool copied_feed_is_set = feed_is_set; \ } else if (feed_is_set) {
bool copied_host_is_set = host_is_set; \ return FeedHostMismatch::kFeedIsSetOnly;
FeedHostMismatch status = FeedHostMismatch::kNeitherAreSet; \ } else if (host_is_set) {
if (copied_feed_is_set && copied_host_is_set) { \ return FeedHostMismatch::kHostIsSetOnly;
status = FeedHostMismatch::kBothAreSet; \ }
} else if (copied_feed_is_set) { \ return FeedHostMismatch::kNeitherAreSet;
status = FeedHostMismatch::kFeedIsSetOnly; \ }
} else if (copied_host_is_set) { \
status = FeedHostMismatch::kHostIsSetOnly; \
} \
UMA_HISTOGRAM_ENUMERATION(name, status); \
} while (false);
struct ParamPair { struct ParamPair {
std::string name; std::string name;
...@@ -292,9 +287,10 @@ NativeRequestBehavior FeedSchedulerHost::ShouldSessionRequestData( ...@@ -292,9 +287,10 @@ NativeRequestBehavior FeedSchedulerHost::ShouldSessionRequestData(
// Both the Feed and the scheduler track if there are outstanding requests. // Both the Feed and the scheduler track if there are outstanding requests.
// It's possible that this data gets out of sync. We treat the Feed as // It's possible that this data gets out of sync. We treat the Feed as
// authoritative and we change our values to match. // authoritative and we change our values to match.
UMA_HISTOGRAM_MISMATCH("ContentSuggestions.Feed.Scheduler.OutstandingRequest", UMA_HISTOGRAM_ENUMERATION(
has_outstanding_request, "ContentSuggestions.Feed.Scheduler.OutstandingRequest",
!outstanding_request_until_.is_null()); GetMismatch(has_outstanding_request,
!outstanding_request_until_.is_null()));
if (has_outstanding_request == outstanding_request_until_.is_null()) { if (has_outstanding_request == outstanding_request_until_.is_null()) {
if (has_outstanding_request) { if (has_outstanding_request) {
outstanding_request_until_ = outstanding_request_until_ =
...@@ -312,8 +308,9 @@ NativeRequestBehavior FeedSchedulerHost::ShouldSessionRequestData( ...@@ -312,8 +308,9 @@ NativeRequestBehavior FeedSchedulerHost::ShouldSessionRequestData(
bool scheduler_thinks_has_content = bool scheduler_thinks_has_content =
!profile_prefs_->FindPreference(prefs::kLastFetchAttemptTime) !profile_prefs_->FindPreference(prefs::kLastFetchAttemptTime)
->IsDefaultValue(); ->IsDefaultValue();
UMA_HISTOGRAM_MISMATCH("ContentSuggestions.Feed.Scheduler.HasContent", UMA_HISTOGRAM_ENUMERATION(
has_content, scheduler_thinks_has_content); "ContentSuggestions.Feed.Scheduler.HasContent",
GetMismatch(has_content, scheduler_thinks_has_content));
if (has_content != scheduler_thinks_has_content) { if (has_content != scheduler_thinks_has_content) {
if (has_content) { if (has_content) {
profile_prefs_->SetTime(prefs::kLastFetchAttemptTime, profile_prefs_->SetTime(prefs::kLastFetchAttemptTime,
......
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