Rename "Is*Expired" to "Has*Expired" in PolicyEngine

[ Merge of http://go/wvgerrit/22516 ]

b/34211676

Test: All unittests other than some oemcrypto, request_license_test
passed. Those tests failed with or without this CL.

Change-Id: Ie973f468f9efd05bdafcf90164dae185a6ce11dc
This commit is contained in:
Rahul Frias
2017-01-11 13:15:38 -08:00
parent 8e3206c1be
commit 516718727e
3 changed files with 17 additions and 16 deletions

View File

@@ -84,9 +84,9 @@ class PolicyEngine {
int64_t last_playback_time); int64_t last_playback_time);
bool IsLicenseForFuture() { return license_state_ == kLicenseStatePending; } bool IsLicenseForFuture() { return license_state_ == kLicenseStatePending; }
bool IsPlaybackStarted() { return playback_start_time_ > 0; } bool HasPlaybackStarted() { return playback_start_time_ > 0; }
bool IsLicenseOrPlaybackDurationExpired(int64_t current_time); bool HasLicenseOrPlaybackDurationExpired(int64_t current_time);
int64_t GetLicenseOrPlaybackDurationRemaining(); int64_t GetLicenseOrPlaybackDurationRemaining();
bool CanRenew() { return policy_.can_renew(); } bool CanRenew() { return policy_.can_renew(); }
@@ -124,9 +124,9 @@ class PolicyEngine {
int64_t GetLicenseOrRentalDurationRemaining(int64_t current_time); int64_t GetLicenseOrRentalDurationRemaining(int64_t current_time);
int64_t GetPlaybackDurationRemaining(int64_t current_time); int64_t GetPlaybackDurationRemaining(int64_t current_time);
bool IsRenewalDelayExpired(int64_t current_time); bool HasRenewalDelayExpired(int64_t current_time);
bool IsRenewalRecoveryDurationExpired(int64_t current_time); bool HasRenewalRecoveryDurationExpired(int64_t current_time);
bool IsRenewalRetryIntervalExpired(int64_t current_time); bool HasRenewalRetryIntervalExpired(int64_t current_time);
void UpdateRenewalRequest(int64_t current_time); void UpdateRenewalRequest(int64_t current_time);

View File

@@ -412,7 +412,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
} else { } else {
Clock clock; Clock clock;
int64_t current_time = clock.GetCurrentTime(); int64_t current_time = clock.GetCurrentTime();
if (policy_engine_->IsLicenseOrPlaybackDurationExpired(current_time)) { if (policy_engine_->HasLicenseOrPlaybackDurationExpired(current_time)) {
return NEED_KEY; return NEED_KEY;
} }
} }

View File

@@ -78,7 +78,7 @@ void PolicyEngine::OnTimerEvent() {
int64_t current_time = clock_->GetCurrentTime(); int64_t current_time = clock_->GetCurrentTime();
// License expiration trumps all. // License expiration trumps all.
if (IsLicenseOrPlaybackDurationExpired(current_time) && if (HasLicenseOrPlaybackDurationExpired(current_time) &&
license_state_ != kLicenseStateExpired) { license_state_ != kLicenseStateExpired) {
license_state_ = kLicenseStateExpired; license_state_ = kLicenseStateExpired;
NotifyKeysChange(kKeyStatusExpired); NotifyKeysChange(kKeyStatusExpired);
@@ -93,7 +93,7 @@ void PolicyEngine::OnTimerEvent() {
// Test to determine if renewal should be attempted. // Test to determine if renewal should be attempted.
switch (license_state_) { switch (license_state_) {
case kLicenseStateCanPlay: { case kLicenseStateCanPlay: {
if (IsRenewalDelayExpired(current_time)) renewal_needed = true; if (HasRenewalDelayExpired(current_time)) renewal_needed = true;
// HDCP may change, so force a check. // HDCP may change, so force a check.
NotifyKeysChange(kKeyStatusUsable); NotifyKeysChange(kKeyStatusUsable);
break; break;
@@ -105,7 +105,7 @@ void PolicyEngine::OnTimerEvent() {
} }
case kLicenseStateWaitingLicenseUpdate: { case kLicenseStateWaitingLicenseUpdate: {
if (IsRenewalRetryIntervalExpired(current_time)) renewal_needed = true; if (HasRenewalRetryIntervalExpired(current_time)) renewal_needed = true;
break; break;
} }
@@ -179,7 +179,8 @@ void PolicyEngine::UpdateLicense(const License& license) {
next_renewal_time_ = license_start_time_ + policy_.renewal_delay_seconds(); next_renewal_time_ = license_start_time_ + policy_.renewal_delay_seconds();
int64_t current_time = clock_->GetCurrentTime(); int64_t current_time = clock_->GetCurrentTime();
if (!policy_.can_play() || IsLicenseOrPlaybackDurationExpired(current_time)) { if (!policy_.can_play() ||
HasLicenseOrPlaybackDurationExpired(current_time)) {
license_state_ = kLicenseStateExpired; license_state_ = kLicenseStateExpired;
NotifyKeysChange(kKeyStatusExpired); NotifyKeysChange(kKeyStatusExpired);
return; return;
@@ -307,7 +308,7 @@ void PolicyEngine::UpdateRenewalRequest(int64_t current_time) {
next_renewal_time_ = current_time + policy_.renewal_retry_interval_seconds(); next_renewal_time_ = current_time + policy_.renewal_retry_interval_seconds();
} }
bool PolicyEngine::IsLicenseOrPlaybackDurationExpired(int64_t current_time) { bool PolicyEngine::HasLicenseOrPlaybackDurationExpired(int64_t current_time) {
const int64_t expiry_time = GetExpiryTime(); const int64_t expiry_time = GetExpiryTime();
return (expiry_time == NEVER_EXPIRES) ? false : (expiry_time <= current_time); return (expiry_time == NEVER_EXPIRES) ? false : (expiry_time <= current_time);
} }
@@ -332,7 +333,7 @@ int64_t PolicyEngine::GetRentalExpiryTime() {
} }
int64_t PolicyEngine::GetExpiryTime() { int64_t PolicyEngine::GetExpiryTime() {
if (!IsPlaybackStarted()) if (!HasPlaybackStarted())
return GetRentalExpiryTime(); return GetRentalExpiryTime();
const int64_t hard_limit = GetHardLicenseExpiryTime(); const int64_t hard_limit = GetHardLicenseExpiryTime();
@@ -350,7 +351,7 @@ int64_t PolicyEngine::GetLicenseOrRentalDurationRemaining(
// This is only used in Query. This should return the time remaining on // This is only used in Query. This should return the time remaining on
// license_duration_seconds for streaming licenses and rental_duration_seconds // license_duration_seconds for streaming licenses and rental_duration_seconds
// for offline licenses. // for offline licenses.
if (IsLicenseOrPlaybackDurationExpired(current_time)) return 0; if (HasLicenseOrPlaybackDurationExpired(current_time)) return 0;
const int64_t license_expiry_time = GetRentalExpiryTime(); const int64_t license_expiry_time = GetRentalExpiryTime();
if (license_expiry_time == NEVER_EXPIRES) return LLONG_MAX; if (license_expiry_time == NEVER_EXPIRES) return LLONG_MAX;
if (license_expiry_time < current_time) return 0; if (license_expiry_time < current_time) return 0;
@@ -371,19 +372,19 @@ int64_t PolicyEngine::GetPlaybackDurationRemaining(int64_t current_time) {
policy_.playback_duration_seconds()); policy_.playback_duration_seconds());
} }
bool PolicyEngine::IsRenewalDelayExpired(int64_t current_time) { bool PolicyEngine::HasRenewalDelayExpired(int64_t current_time) {
return policy_.can_renew() && (policy_.renewal_delay_seconds() > 0) && return policy_.can_renew() && (policy_.renewal_delay_seconds() > 0) &&
license_start_time_ + policy_.renewal_delay_seconds() <= current_time; license_start_time_ + policy_.renewal_delay_seconds() <= current_time;
} }
bool PolicyEngine::IsRenewalRecoveryDurationExpired(int64_t current_time) { bool PolicyEngine::HasRenewalRecoveryDurationExpired(int64_t current_time) {
// NOTE: Renewal Recovery Duration is currently not used. // NOTE: Renewal Recovery Duration is currently not used.
return (policy_.renewal_recovery_duration_seconds() > 0) && return (policy_.renewal_recovery_duration_seconds() > 0) &&
license_start_time_ + policy_.renewal_recovery_duration_seconds() <= license_start_time_ + policy_.renewal_recovery_duration_seconds() <=
current_time; current_time;
} }
bool PolicyEngine::IsRenewalRetryIntervalExpired(int64_t current_time) { bool PolicyEngine::HasRenewalRetryIntervalExpired(int64_t current_time) {
return policy_.can_renew() && return policy_.can_renew() &&
(policy_.renewal_retry_interval_seconds() > 0) && (policy_.renewal_retry_interval_seconds() > 0) &&
next_renewal_time_ <= current_time; next_renewal_time_ <= current_time;