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

Side by Side Diff: chrome/browser/policy/cloud/cloud_policy_invalidator.cc

Issue 2886933003: Use stricter type checking in UMA_HISTOGRAM_ENUMERATION (Closed)
Patch Set: simplify type checking Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h" 5 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/hash.h" 10 #include "base/hash.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // The invalidation version is the timestamp in microseconds. If the 403 // The invalidation version is the timestamp in microseconds. If the
404 // invalidation occurred before the last policy fetch, then the invalidation 404 // invalidation occurred before the last policy fetch, then the invalidation
405 // is expired. Time is added to the invalidation to err on the side of not 405 // is expired. Time is added to the invalidation to err on the side of not
406 // expired. 406 // expired.
407 base::Time invalidation_time = base::Time::UnixEpoch() + 407 base::Time invalidation_time = base::Time::UnixEpoch() +
408 base::TimeDelta::FromMicroseconds(version) + 408 base::TimeDelta::FromMicroseconds(version) +
409 base::TimeDelta::FromSeconds(kMaxInvalidationTimeDelta); 409 base::TimeDelta::FromSeconds(kMaxInvalidationTimeDelta);
410 return invalidation_time < last_fetch_time; 410 return invalidation_time < last_fetch_time;
411 } 411 }
412 412
413 int CloudPolicyInvalidator::GetPolicyRefreshMetric(bool policy_changed) { 413 MetricPolicyRefresh CloudPolicyInvalidator::GetPolicyRefreshMetric(
414 bool policy_changed) {
414 if (policy_changed) { 415 if (policy_changed) {
415 if (invalid_) 416 if (invalid_)
416 return METRIC_POLICY_REFRESH_INVALIDATED_CHANGED; 417 return METRIC_POLICY_REFRESH_INVALIDATED_CHANGED;
417 if (GetInvalidationsEnabled()) 418 if (GetInvalidationsEnabled())
418 return METRIC_POLICY_REFRESH_CHANGED; 419 return METRIC_POLICY_REFRESH_CHANGED;
419 return METRIC_POLICY_REFRESH_CHANGED_NO_INVALIDATIONS; 420 return METRIC_POLICY_REFRESH_CHANGED_NO_INVALIDATIONS;
420 } 421 }
421 if (invalid_) 422 if (invalid_)
422 return METRIC_POLICY_REFRESH_INVALIDATED_UNCHANGED; 423 return METRIC_POLICY_REFRESH_INVALIDATED_UNCHANGED;
423 return METRIC_POLICY_REFRESH_UNCHANGED; 424 return METRIC_POLICY_REFRESH_UNCHANGED;
424 } 425 }
425 426
426 int CloudPolicyInvalidator::GetInvalidationMetric(bool is_missing_payload, 427 PolicyInvalidationType CloudPolicyInvalidator::GetInvalidationMetric(
427 bool is_expired) { 428 bool is_missing_payload,
429 bool is_expired) {
428 if (is_expired) { 430 if (is_expired) {
429 if (is_missing_payload) 431 if (is_missing_payload)
430 return POLICY_INVALIDATION_TYPE_NO_PAYLOAD_EXPIRED; 432 return POLICY_INVALIDATION_TYPE_NO_PAYLOAD_EXPIRED;
431 return POLICY_INVALIDATION_TYPE_EXPIRED; 433 return POLICY_INVALIDATION_TYPE_EXPIRED;
432 } 434 }
433 if (is_missing_payload) 435 if (is_missing_payload)
434 return POLICY_INVALIDATION_TYPE_NO_PAYLOAD; 436 return POLICY_INVALIDATION_TYPE_NO_PAYLOAD;
435 return POLICY_INVALIDATION_TYPE_NORMAL; 437 return POLICY_INVALIDATION_TYPE_NORMAL;
436 } 438 }
437 439
438 bool CloudPolicyInvalidator::GetInvalidationsEnabled() { 440 bool CloudPolicyInvalidator::GetInvalidationsEnabled() {
439 if (!invalidations_enabled_) 441 if (!invalidations_enabled_)
440 return false; 442 return false;
441 // If invalidations have been enabled for less than the grace period, then 443 // If invalidations have been enabled for less than the grace period, then
442 // consider invalidations to be disabled for metrics reporting. 444 // consider invalidations to be disabled for metrics reporting.
443 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_; 445 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_;
444 return elapsed.InSeconds() >= kInvalidationGracePeriod; 446 return elapsed.InSeconds() >= kInvalidationGracePeriod;
445 } 447 }
446 448
447 } // namespace policy 449 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/cloud_policy_invalidator.h ('k') | chrome/browser/prerender/prerender_link_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698