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

Unified Diff: components/policy/core/common/cloud/cloud_policy_validator.cc

Issue 2830033003: Use {To/From}JavaTime for policy timestamps (Closed)
Patch Set: Created 3 years, 8 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: components/policy/core/common/cloud/cloud_policy_validator.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_validator.cc b/components/policy/core/common/cloud/cloud_policy_validator.cc
index 3ac136b7cd6c4dc3e58038eb409f4adea49672c6..91056ada5c94575f2c37683d1895ad03427de455 100644
--- a/components/policy/core/common/cloud/cloud_policy_validator.cc
+++ b/components/policy/core/common/cloud/cloud_policy_validator.cc
@@ -57,11 +57,10 @@ void CloudPolicyValidatorBase::ValidateTimestamp(
base::Time now,
ValidateTimestampOption timestamp_option) {
validation_flags_ |= VALIDATE_TIMESTAMP;
- timestamp_not_before_ =
- (not_before - base::Time::UnixEpoch()).InMilliseconds();
+ timestamp_not_before_ = not_before.ToJavaTime();
timestamp_not_after_ =
- ((now + base::TimeDelta::FromHours(kTimestampGraceIntervalHours)) -
- base::Time::UnixEpoch()).InMillisecondsRoundedUp();
+ (now + base::TimeDelta::FromHours(kTimestampGraceIntervalHours))
+ .ToJavaTime();
timestamp_option_ = timestamp_option;
}
@@ -153,9 +152,7 @@ void CloudPolicyValidatorBase::ValidateAgainstCurrentPolicy(
std::string expected_dm_token;
std::string expected_device_id;
if (policy_data) {
- last_policy_timestamp =
- base::Time::UnixEpoch() +
- base::TimeDelta::FromMilliseconds(policy_data->timestamp());
+ last_policy_timestamp = base::Time::FromJavaTime(policy_data->timestamp());
expected_dm_token = policy_data->request_token();
expected_device_id = policy_data->device_id();
}

Powered by Google App Engine
This is Rietveld 408576698