Chromium Code Reviews| Index: third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp |
| diff --git a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp |
| index 54b7d8c9ee460fd0d08a5fa332bd7e580f9171e3..dc64447df1f6ae35cf8c968e6783ccf5c661e715 100644 |
| --- a/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp |
| +++ b/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp |
| @@ -53,6 +53,8 @@ |
| #include <cmath> |
| #include <limits> |
| +#define MEDIA_KEY_SESSION_LOG_LEVEL 3 |
| + |
| namespace { |
| // Minimum and maximum length for session ids. |
| @@ -102,7 +104,7 @@ static String ConvertKeyStatusToString(const WebEncryptedMediaKeyInformation::Ke |
| return "internal-error"; |
| } |
| - ASSERT_NOT_REACHED(); |
| + NOTREACHED(); |
| return "internal-error"; |
| } |
| @@ -138,51 +140,51 @@ public: |
| DOMArrayBuffer* data() const |
| { |
| - ASSERT(m_type == GenerateRequest || m_type == Update); |
| + DCHECK(m_type == GenerateRequest || m_type == Update); |
| return m_data; |
| } |
| WebEncryptedMediaInitDataType initDataType() const |
| { |
| - ASSERT(m_type == GenerateRequest); |
| + DCHECK_EQ(m_type, GenerateRequest); |
|
jrummell
2016/05/23 22:53:56
Typically the expected value is first, the variabl
Srirama
2016/05/24 16:24:04
Done.
|
| return m_initDataType; |
| } |
| const String& sessionId() const |
| { |
| - ASSERT(m_type == Load); |
| + DCHECK_EQ(m_type, Load); |
| return m_stringData; |
| } |
| static PendingAction* CreatePendingGenerateRequest(ContentDecryptionModuleResult* result, WebEncryptedMediaInitDataType initDataType, DOMArrayBuffer* initData) |
| { |
| - ASSERT(result); |
| - ASSERT(initData); |
| + DCHECK(result); |
| + DCHECK(initData); |
| return new PendingAction(GenerateRequest, result, initDataType, initData, String()); |
| } |
| static PendingAction* CreatePendingLoadRequest(ContentDecryptionModuleResult* result, const String& sessionId) |
| { |
| - ASSERT(result); |
| + DCHECK(result); |
| return new PendingAction(Load, result, WebEncryptedMediaInitDataType::Unknown, nullptr, sessionId); |
| } |
| static PendingAction* CreatePendingUpdate(ContentDecryptionModuleResult* result, DOMArrayBuffer* data) |
| { |
| - ASSERT(result); |
| - ASSERT(data); |
| + DCHECK(result); |
| + DCHECK(data); |
| return new PendingAction(Update, result, WebEncryptedMediaInitDataType::Unknown, data, String()); |
| } |
| static PendingAction* CreatePendingClose(ContentDecryptionModuleResult* result) |
| { |
| - ASSERT(result); |
| + DCHECK(result); |
| return new PendingAction(Close, result, WebEncryptedMediaInitDataType::Unknown, nullptr, String()); |
| } |
| static PendingAction* CreatePendingRemove(ContentDecryptionModuleResult* result) |
| { |
| - ASSERT(result); |
| + DCHECK(result); |
| return new PendingAction(Remove, result, WebEncryptedMediaInitDataType::Unknown, nullptr, String()); |
| } |
| @@ -234,7 +236,7 @@ public: |
| void completeWithSession(WebContentDecryptionModuleResult::SessionStatus status) override |
| { |
| if (status != WebContentDecryptionModuleResult::NewSession) { |
| - ASSERT_NOT_REACHED(); |
| + NOTREACHED(); |
| reject(InvalidStateError, "Unexpected completion."); |
| } |
| @@ -283,12 +285,12 @@ public: |
| return; |
| case WebContentDecryptionModuleResult::SessionAlreadyExists: |
| - ASSERT_NOT_REACHED(); |
| + NOTREACHED(); |
| reject(InvalidStateError, "Unexpected completion."); |
| return; |
| } |
| - ASSERT_NOT_REACHED(); |
| + NOTREACHED(); |
| } |
| DEFINE_INLINE_TRACE() |
| @@ -322,7 +324,7 @@ MediaKeySession::MediaKeySession(ScriptState* scriptState, MediaKeys* mediaKeys, |
| , m_closedPromise(new ClosedPromise(scriptState->getExecutionContext(), this, ClosedPromise::Closed)) |
| , m_actionTimer(this, &MediaKeySession::actionTimerFired) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::MediaKeySession", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "MediaKeySession(" << this << ")"; |
|
jrummell
2016/05/23 22:53:56
To keep the message consistent I think this needs
Srirama
2016/05/24 16:24:04
DVLOG already prints filename and line number, so
jrummell
2016/05/24 18:07:11
Acknowledged.
|
| ThreadState::current()->registerPreFinalizer(this); |
| // Create the matching Chromium object. It will not be usable until |
| @@ -335,25 +337,25 @@ MediaKeySession::MediaKeySession(ScriptState* scriptState, MediaKeys* mediaKeys, |
| // From https://w3c.github.io/encrypted-media/#createSession: |
| // MediaKeys::createSession(), step 3. |
| // 3.1 Let the sessionId attribute be the empty string. |
| - ASSERT(sessionId().isEmpty()); |
| + DCHECK(sessionId().isEmpty()); |
| // 3.2 Let the expiration attribute be NaN. |
| - ASSERT(std::isnan(m_expiration)); |
| + DCHECK(std::isnan(m_expiration)); |
| // 3.3 Let the closed attribute be a new promise. |
| - ASSERT(!closed(scriptState).isUndefinedOrNull()); |
| + DCHECK(!closed(scriptState).isUndefinedOrNull()); |
| // 3.4 Let the keyStatuses attribute be empty. |
| - ASSERT(m_keyStatusesMap->size() == 0); |
| + DCHECK_EQ(m_keyStatusesMap->size(), 0u); |
| // 3.5 Let the session type be sessionType. |
| - ASSERT(m_sessionType != WebEncryptedMediaSessionType::Unknown); |
| + DCHECK(m_sessionType != WebEncryptedMediaSessionType::Unknown); |
| // 3.6 Let uninitialized be true. |
| - ASSERT(m_isUninitialized); |
| + DCHECK(m_isUninitialized); |
| // 3.7 Let callable be false. |
| - ASSERT(!m_isCallable); |
| + DCHECK(!m_isCallable); |
| // 3.8 Let the use distinctive identifier value be this object's |
| // use distinctive identifier. |
| @@ -365,7 +367,7 @@ MediaKeySession::MediaKeySession(ScriptState* scriptState, MediaKeys* mediaKeys, |
| MediaKeySession::~MediaKeySession() |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::~MediaKeySession", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "~MediaKeySession(" << this << ")"; |
| } |
| void MediaKeySession::dispose() |
| @@ -392,7 +394,7 @@ MediaKeyStatusMap* MediaKeySession::keyStatuses() |
| ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const String& initDataTypeString, const DOMArrayPiece& initData) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::generateRequest %s", this, initDataTypeString.ascii().data()); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "generateRequest(" << this << ") " << initDataTypeString; |
| // From https://w3c.github.io/encrypted-media/#generateRequest: |
| // Generates a request based on the initData. When this method is invoked, |
| @@ -447,7 +449,7 @@ ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S |
| // 9. Run the following steps asynchronously (documented in |
| // actionTimerFired()) |
| m_pendingActions.append(PendingAction::CreatePendingGenerateRequest(result, initDataType, initDataBuffer)); |
| - ASSERT(!m_actionTimer.isActive()); |
| + DCHECK(!m_actionTimer.isActive()); |
| m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| // 10. Return promise. |
| @@ -456,7 +458,7 @@ ScriptPromise MediaKeySession::generateRequest(ScriptState* scriptState, const S |
| ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sessionId) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::load %s", this, sessionId.ascii().data()); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "load(" << this << ") " << sessionId; |
| // From https://w3c.github.io/encrypted-media/#load: |
| // Loads the data stored for the specified session into this object. When |
| @@ -501,7 +503,7 @@ ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess |
| // 8. Run the following steps asynchronously (documented in |
| // actionTimerFired()) |
| m_pendingActions.append(PendingAction::CreatePendingLoadRequest(result, sessionId)); |
| - ASSERT(!m_actionTimer.isActive()); |
| + DCHECK(!m_actionTimer.isActive()); |
| m_actionTimer.startOneShot(0, BLINK_FROM_HERE); |
| // 9. Return promise. |
| @@ -510,8 +512,8 @@ ScriptPromise MediaKeySession::load(ScriptState* scriptState, const String& sess |
| ScriptPromise MediaKeySession::update(ScriptState* scriptState, const DOMArrayPiece& response) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::update", this); |
| - ASSERT(!m_isClosed); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "update(" << this << ")"; |
| + DCHECK(!m_isClosed); |
| // From https://w3c.github.io/encrypted-media/#update: |
| // Provides messages, including licenses, to the CDM. When this method is |
| @@ -548,7 +550,7 @@ ScriptPromise MediaKeySession::update(ScriptState* scriptState, const DOMArrayPi |
| ScriptPromise MediaKeySession::close(ScriptState* scriptState) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::close", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "close(" << this << ")"; |
| // From https://w3c.github.io/encrypted-media/#close: |
| // Indicates that the application no longer needs the session and the CDM |
| @@ -581,7 +583,7 @@ ScriptPromise MediaKeySession::close(ScriptState* scriptState) |
| ScriptPromise MediaKeySession::remove(ScriptState* scriptState) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::remove", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "remove(" << this << ")"; |
| // From https://w3c.github.io/encrypted-media/#remove: |
| // Removes stored session data associated with this object. When this |
| @@ -624,7 +626,7 @@ ScriptPromise MediaKeySession::remove(ScriptState* scriptState) |
| void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| { |
| - ASSERT(m_pendingActions.size()); |
| + DCHECK(m_pendingActions.size()); |
| // Resolving promises now run synchronously and may result in additional |
| // actions getting added to the queue. As a result, swap the queue to |
| @@ -638,7 +640,7 @@ void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| switch (action->getType()) { |
| case PendingAction::GenerateRequest: |
| // NOTE: Continue step 9 of MediaKeySession::generateRequest(). |
| - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: GenerateRequest", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") GenerateRequest"; |
| // initializeNewSession() in Chromium will execute steps 9.1 to 9.7. |
| m_session->initializeNewSession(action->initDataType(), static_cast<unsigned char*>(action->data()->data()), action->data()->byteLength(), m_sessionType, action->result()->result()); |
| @@ -649,7 +651,7 @@ void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| case PendingAction::Load: |
| // NOTE: Continue step 8 of MediaKeySession::load(). |
| - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Load", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Load"; |
| // 8.1 Let sanitized session ID be a validated and/or sanitized |
| // version of sessionId. The user agent should thoroughly |
| @@ -673,7 +675,7 @@ void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| // 8.4 Let expiration time be NaN. |
| // (Done in the constructor.) |
| - ASSERT(std::isnan(m_expiration)); |
| + DCHECK(std::isnan(m_expiration)); |
| // load() in Chromium will execute steps 8.5 through 8.8. |
| m_session->load(action->sessionId(), action->result()->result()); |
| @@ -684,7 +686,7 @@ void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| case PendingAction::Update: |
| // NOTE: Continue step 5 of MediaKeySession::update(). |
| - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Update", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Update"; |
| // update() in Chromium will execute steps 5.1 through 5.8. |
| m_session->update(static_cast<unsigned char*>(action->data()->data()), action->data()->byteLength(), action->result()->result()); |
| @@ -695,7 +697,7 @@ void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| case PendingAction::Close: |
| // NOTE: Continue step 4 of MediaKeySession::close(). |
| - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Close", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Close"; |
| // close() in Chromium will execute steps 4.1 through 4.2. |
| m_session->close(action->result()->result()); |
| @@ -706,7 +708,7 @@ void MediaKeySession::actionTimerFired(Timer<MediaKeySession>*) |
| case PendingAction::Remove: |
| // NOTE: Continue step 5 of MediaKeySession::remove(). |
| - WTF_LOG(Media, "MediaKeySession(%p)::actionTimerFired: Remove", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "actionTimerFired(" << this << ") Remove"; |
| // remove() in Chromium will execute steps 5.1 through 5.3. |
| m_session->remove(action->result()->result()); |
| @@ -725,7 +727,7 @@ void MediaKeySession::finishGenerateRequest() |
| // (Done by CDM calling result.completeWithError() as appropriate.) |
| // 9.9 Set the sessionId attribute to session id. |
| - ASSERT(!sessionId().isEmpty()); |
| + DCHECK(!sessionId().isEmpty()); |
| // 9.10 Let this object's callable be true. |
| m_isCallable = true; |
| @@ -745,7 +747,7 @@ void MediaKeySession::finishLoad() |
| // (Done by CDM calling result.completeWithError() as appropriate.) |
| // 8.10 Set the sessionId attribute to sanitized session ID. |
| - ASSERT(!sessionId().isEmpty()); |
| + DCHECK(!sessionId().isEmpty()); |
| // 8.11 Let this object's callable be true. |
| m_isCallable = true; |
| @@ -776,10 +778,10 @@ void MediaKeySession::finishLoad() |
| // Queue a task to fire a simple event named keymessage at the new object. |
| void MediaKeySession::message(MessageType messageType, const unsigned char* message, size_t messageLength) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::message", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "message(" << this << ")"; |
| // Verify that 'message' not fired before session initialization is complete. |
| - ASSERT(m_isCallable); |
| + DCHECK(m_isCallable); |
| // From https://w3c.github.io/encrypted-media/#queue-message: |
| // The following steps are run: |
| @@ -810,7 +812,7 @@ void MediaKeySession::message(MessageType messageType, const unsigned char* mess |
| void MediaKeySession::close() |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::close", this); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "close(" << this << ")"; |
| // From https://w3c.github.io/encrypted-media/#session-close: |
| // The following steps are run: |
| @@ -826,7 +828,7 @@ void MediaKeySession::close() |
| void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::expirationChanged %f", this, updatedExpiryTimeInMS); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "expirationChanged(" << this << ") " << updatedExpiryTimeInMS; |
| // From https://w3c.github.io/encrypted-media/#update-expiration: |
| // The following steps are run: |
| @@ -847,7 +849,7 @@ void MediaKeySession::expirationChanged(double updatedExpiryTimeInMS) |
| void MediaKeySession::keysStatusesChange(const WebVector<WebEncryptedMediaKeyInformation>& keys, bool hasAdditionalUsableKey) |
| { |
| - WTF_LOG(Media, "MediaKeySession(%p)::keysStatusesChange with %zu keys and hasAdditionalUsableKey is %s", this, keys.size(), hasAdditionalUsableKey ? "true" : "false"); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "keysStatusesChange(" << this << ") with " << keys.size() << " keys and hasAdditionalUsableKey is " << (hasAdditionalUsableKey ? "true" : "false"); |
| // From https://w3c.github.io/encrypted-media/#update-key-statuses: |
| // The following steps are run: |
| @@ -897,10 +899,10 @@ bool MediaKeySession::hasPendingActivity() const |
| { |
| // Remain around if there are pending events or MediaKeys is still around |
| // and we're not closed. |
| - WTF_LOG(Media, "MediaKeySession(%p)::hasPendingActivity %s%s%s", this, |
| - !m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "", |
| - m_asyncEventQueue->hasPendingEvents() ? " m_asyncEventQueue->hasPendingEvents()" : "", |
| - (m_mediaKeys && !m_isClosed) ? " m_mediaKeys && !m_isClosed" : ""); |
| + DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) << "hasPendingActivity(" << this << ") " |
| + << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") |
| + << (m_asyncEventQueue->hasPendingEvents() ? " m_asyncEventQueue->hasPendingEvents()" : "") |
| + << ((m_mediaKeys && !m_isClosed) ? " m_mediaKeys && !m_isClosed" : ""); |
| return !m_pendingActions.isEmpty() |
| || m_asyncEventQueue->hasPendingEvents() |