| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 Member<MediaKeys> m_mediaKeys; | 125 Member<MediaKeys> m_mediaKeys; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 MediaKeys* MediaKeys::create( | 128 MediaKeys* MediaKeys::create( |
| 129 ExecutionContext* context, | 129 ExecutionContext* context, |
| 130 const WebVector<WebEncryptedMediaSessionType>& supportedSessionTypes, | 130 const WebVector<WebEncryptedMediaSessionType>& supportedSessionTypes, |
| 131 std::unique_ptr<WebContentDecryptionModule> cdm) { | 131 std::unique_ptr<WebContentDecryptionModule> cdm) { |
| 132 MediaKeys* mediaKeys = | 132 return new MediaKeys(context, supportedSessionTypes, std::move(cdm)); |
| 133 new MediaKeys(context, supportedSessionTypes, std::move(cdm)); | |
| 134 mediaKeys->suspendIfNeeded(); | |
| 135 return mediaKeys; | |
| 136 } | 133 } |
| 137 | 134 |
| 138 MediaKeys::MediaKeys( | 135 MediaKeys::MediaKeys( |
| 139 ExecutionContext* context, | 136 ExecutionContext* context, |
| 140 const WebVector<WebEncryptedMediaSessionType>& supportedSessionTypes, | 137 const WebVector<WebEncryptedMediaSessionType>& supportedSessionTypes, |
| 141 std::unique_ptr<WebContentDecryptionModule> cdm) | 138 std::unique_ptr<WebContentDecryptionModule> cdm) |
| 142 : SuspendableObject(context), | 139 : ContextLifecycleObserver(context), |
| 143 m_supportedSessionTypes(supportedSessionTypes), | 140 m_supportedSessionTypes(supportedSessionTypes), |
| 144 m_cdm(std::move(cdm)), | 141 m_cdm(std::move(cdm)), |
| 145 m_mediaElement(nullptr), | 142 m_mediaElement(nullptr), |
| 146 m_reservedForMediaElement(false), | 143 m_reservedForMediaElement(false), |
| 147 m_timer(this, &MediaKeys::timerFired) { | 144 m_timer(this, &MediaKeys::timerFired) { |
| 148 DVLOG(MEDIA_KEYS_LOG_LEVEL) << __func__ << "(" << this << ")"; | 145 DVLOG(MEDIA_KEYS_LOG_LEVEL) << __func__ << "(" << this << ")"; |
| 149 } | 146 } |
| 150 | 147 |
| 151 MediaKeys::~MediaKeys() { | 148 MediaKeys::~MediaKeys() { |
| 152 DVLOG(MEDIA_KEYS_LOG_LEVEL) << __func__ << "(" << this << ")"; | 149 DVLOG(MEDIA_KEYS_LOG_LEVEL) << __func__ << "(" << this << ")"; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 282 } |
| 286 } | 283 } |
| 287 | 284 |
| 288 WebContentDecryptionModule* MediaKeys::contentDecryptionModule() { | 285 WebContentDecryptionModule* MediaKeys::contentDecryptionModule() { |
| 289 return m_cdm.get(); | 286 return m_cdm.get(); |
| 290 } | 287 } |
| 291 | 288 |
| 292 DEFINE_TRACE(MediaKeys) { | 289 DEFINE_TRACE(MediaKeys) { |
| 293 visitor->trace(m_pendingActions); | 290 visitor->trace(m_pendingActions); |
| 294 visitor->trace(m_mediaElement); | 291 visitor->trace(m_mediaElement); |
| 295 SuspendableObject::trace(visitor); | 292 ContextLifecycleObserver::trace(visitor); |
| 296 } | 293 } |
| 297 | 294 |
| 298 void MediaKeys::contextDestroyed() { | 295 void MediaKeys::contextDestroyed() { |
| 299 m_timer.stop(); | 296 m_timer.stop(); |
| 300 m_pendingActions.clear(); | 297 m_pendingActions.clear(); |
| 301 | 298 |
| 302 // We don't need the CDM anymore. Only destroyed after all related | 299 // We don't need the CDM anymore. Only destroyed after all related |
| 303 // SuspendableObjects have been stopped. | 300 // ContextLifecycleObservers have been stopped. |
| 304 m_cdm.reset(); | 301 m_cdm.reset(); |
| 305 } | 302 } |
| 306 | 303 |
| 307 bool MediaKeys::hasPendingActivity() const { | 304 bool MediaKeys::hasPendingActivity() const { |
| 308 // Remain around if there are pending events. | 305 // Remain around if there are pending events. |
| 309 DVLOG(MEDIA_KEYS_LOG_LEVEL) | 306 DVLOG(MEDIA_KEYS_LOG_LEVEL) |
| 310 << __func__ << "(" << this << ")" | 307 << __func__ << "(" << this << ")" |
| 311 << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") | 308 << (!m_pendingActions.isEmpty() ? " !m_pendingActions.isEmpty()" : "") |
| 312 << (m_reservedForMediaElement ? " m_reservedForMediaElement" : ""); | 309 << (m_reservedForMediaElement ? " m_reservedForMediaElement" : ""); |
| 313 | 310 |
| 314 return !m_pendingActions.isEmpty() || m_reservedForMediaElement; | 311 return !m_pendingActions.isEmpty() || m_reservedForMediaElement; |
| 315 } | 312 } |
| 316 | 313 |
| 317 } // namespace blink | 314 } // namespace blink |
| OLD | NEW |