Skip to content

Commit

Permalink
media: Fix expiry time convertion from base::Time to JS time
Browse files Browse the repository at this point in the history
This is broken by https://codereview.chromium.org/2593073002/ where the
behavior of converting a null base::Time to JS time (double) has been
changed. We are discussing how to fix the base::Time API more properly.
For now, this check should work.

BUG=679079
TEST=Manually tested. I'll add auto tests later.

Review-Url: https://codereview.chromium.org/2650033007
Cr-Commit-Position: refs/heads/master@{#446246}
  • Loading branch information
xhwang-chromium authored and Commit bot committed Jan 26, 2017
1 parent b71beb8 commit d81adcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 5 additions & 1 deletion media/blink/webcontentdecryptionmodulesession_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,11 @@ void WebContentDecryptionModuleSessionImpl::OnSessionKeysChange(
void WebContentDecryptionModuleSessionImpl::OnSessionExpirationUpdate(
base::Time new_expiry_time) {
DCHECK(thread_checker_.CalledOnValidThread());
client_->expirationChanged(new_expiry_time.ToJsTime());
// The check works around an issue in base::Time that converts null base::Time
// to |1601-01-01 00:00:00 UTC| in ToJsTime(). See http://crbug.com/679079
client_->expirationChanged(new_expiry_time.is_null()
? std::numeric_limits<double>::quiet_NaN()
: new_expiry_time.ToJsTime());
}

void WebContentDecryptionModuleSessionImpl::OnSessionClosed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -959,9 +959,7 @@ void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) {

// 3. If the new expiration time is not NaN, let expiration time be the
// new expiration time in milliseconds since 01 January 1970 UTC.
// (Note that Chromium actually passes 0 to indicate no expiry.)
// FIXME: Get Chromium to pass NaN.
if (!std::isnan(updatedExpiryTimeInMS) && updatedExpiryTimeInMS != 0.0)
if (!std::isnan(updatedExpiryTimeInMS))
expirationTime = updatedExpiryTimeInMS;

// 4. Set the session's expiration attribute to expiration time.
Expand Down

0 comments on commit d81adcc

Please sign in to comment.