| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 private: | 348 private: |
| 349 // Keep track of the MediaKeySession that created this promise so that it | 349 // Keep track of the MediaKeySession that created this promise so that it |
| 350 // remains reachable as long as this promise is reachable. | 350 // remains reachable as long as this promise is reachable. |
| 351 Member<MediaKeySession> m_session; | 351 Member<MediaKeySession> m_session; |
| 352 }; | 352 }; |
| 353 | 353 |
| 354 MediaKeySession* MediaKeySession::create( | 354 MediaKeySession* MediaKeySession::create( |
| 355 ScriptState* scriptState, | 355 ScriptState* scriptState, |
| 356 MediaKeys* mediaKeys, | 356 MediaKeys* mediaKeys, |
| 357 WebEncryptedMediaSessionType sessionType) { | 357 WebEncryptedMediaSessionType sessionType) { |
| 358 MediaKeySession* session = | 358 return new MediaKeySession(scriptState, mediaKeys, sessionType); |
| 359 new MediaKeySession(scriptState, mediaKeys, sessionType); | |
| 360 session->suspendIfNeeded(); | |
| 361 return session; | |
| 362 } | 359 } |
| 363 | 360 |
| 364 MediaKeySession::MediaKeySession(ScriptState* scriptState, | 361 MediaKeySession::MediaKeySession(ScriptState* scriptState, |
| 365 MediaKeys* mediaKeys, | 362 MediaKeys* mediaKeys, |
| 366 WebEncryptedMediaSessionType sessionType) | 363 WebEncryptedMediaSessionType sessionType) |
| 367 : SuspendableObject(scriptState->getExecutionContext()), | 364 : ContextLifecycleObserver(scriptState->getExecutionContext()), |
| 368 m_asyncEventQueue(GenericEventQueue::create(this)), | 365 m_asyncEventQueue(GenericEventQueue::create(this)), |
| 369 m_mediaKeys(mediaKeys), | 366 m_mediaKeys(mediaKeys), |
| 370 m_sessionType(sessionType), | 367 m_sessionType(sessionType), |
| 371 m_expiration(std::numeric_limits<double>::quiet_NaN()), | 368 m_expiration(std::numeric_limits<double>::quiet_NaN()), |
| 372 m_keyStatusesMap(new MediaKeyStatusMap()), | 369 m_keyStatusesMap(new MediaKeyStatusMap()), |
| 373 m_isUninitialized(true), | 370 m_isUninitialized(true), |
| 374 m_isCallable(false), | 371 m_isCallable(false), |
| 375 m_isClosed(false), | 372 m_isClosed(false), |
| 376 m_closedPromise(new ClosedPromise(scriptState->getExecutionContext(), | 373 m_closedPromise(new ClosedPromise(scriptState->getExecutionContext(), |
| 377 this, | 374 this, |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 // may choose to skip this step if it knows resuming will fail. | 1002 // may choose to skip this step if it knows resuming will fail. |
| 1006 // FIXME: Attempt to resume playback if |hasAdditionalUsableKey| is true. | 1003 // FIXME: Attempt to resume playback if |hasAdditionalUsableKey| is true. |
| 1007 // http://crbug.com/413413 | 1004 // http://crbug.com/413413 |
| 1008 } | 1005 } |
| 1009 | 1006 |
| 1010 const AtomicString& MediaKeySession::interfaceName() const { | 1007 const AtomicString& MediaKeySession::interfaceName() const { |
| 1011 return EventTargetNames::MediaKeySession; | 1008 return EventTargetNames::MediaKeySession; |
| 1012 } | 1009 } |
| 1013 | 1010 |
| 1014 ExecutionContext* MediaKeySession::getExecutionContext() const { | 1011 ExecutionContext* MediaKeySession::getExecutionContext() const { |
| 1015 return SuspendableObject::getExecutionContext(); | 1012 return ContextLifecycleObserver::getExecutionContext(); |
| 1016 } | 1013 } |
| 1017 | 1014 |
| 1018 bool MediaKeySession::hasPendingActivity() const { | 1015 bool MediaKeySession::hasPendingActivity() const { |
| 1019 // Remain around if there are pending events or MediaKeys is still around | 1016 // Remain around if there are pending events or MediaKeys is still around |
| 1020 // and we're not closed. | 1017 // and we're not closed. |
| 1021 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) | 1018 DVLOG(MEDIA_KEY_SESSION_LOG_LEVEL) |
| 1022 << __func__ << "(" << this << ")" | 1019 << __func__ << "(" << this << ")" |
| 1023 << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") | 1020 << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") |
| 1024 << (m_asyncEventQueue->hasPendingEvents() | 1021 << (m_asyncEventQueue->hasPendingEvents() |
| 1025 ? " m_asyncEventQueue->hasPendingEvents()" | 1022 ? " m_asyncEventQueue->hasPendingEvents()" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1039 m_asyncEventQueue->close(); | 1036 m_asyncEventQueue->close(); |
| 1040 } | 1037 } |
| 1041 | 1038 |
| 1042 DEFINE_TRACE(MediaKeySession) { | 1039 DEFINE_TRACE(MediaKeySession) { |
| 1043 visitor->trace(m_asyncEventQueue); | 1040 visitor->trace(m_asyncEventQueue); |
| 1044 visitor->trace(m_pendingActions); | 1041 visitor->trace(m_pendingActions); |
| 1045 visitor->trace(m_mediaKeys); | 1042 visitor->trace(m_mediaKeys); |
| 1046 visitor->trace(m_keyStatusesMap); | 1043 visitor->trace(m_keyStatusesMap); |
| 1047 visitor->trace(m_closedPromise); | 1044 visitor->trace(m_closedPromise); |
| 1048 EventTargetWithInlineData::trace(visitor); | 1045 EventTargetWithInlineData::trace(visitor); |
| 1049 SuspendableObject::trace(visitor); | 1046 ContextLifecycleObserver::trace(visitor); |
| 1050 } | 1047 } |
| 1051 | 1048 |
| 1052 } // namespace blink | 1049 } // namespace blink |
| OLD | NEW |