Changeset 252033 in webkit
- Timestamp:
- Nov 4, 2019 7:03:36 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r252032 r252033 1 2019-11-04 Chris Dumez <cdumez@apple.com> 2 3 MediaKeySession / WebKitMediaKeySession should not prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203089 5 6 Reviewed by Youenn Fablet. 7 8 Add layout test coverage. 9 10 * http/tests/navigation/page-cache-mediakeysession-expected.txt: Added. 11 * http/tests/navigation/page-cache-mediakeysession.html: Added. 12 1 13 2019-11-04 Yusuke Suzuki <ysuzuki@apple.com> 2 14 -
trunk/Source/WebCore/ChangeLog
r252030 r252033 1 2019-11-04 Chris Dumez <cdumez@apple.com> 2 3 MediaKeySession / WebKitMediaKeySession should not prevent entering the back/forward cache 4 https://bugs.webkit.org/show_bug.cgi?id=203089 5 6 Reviewed by Youenn Fablet. 7 8 Port MediaKeySession / WebKitMediaKeySession to the HTML5 event loop instead of using its 9 own GenericEventQueue / GenericTaskQueue. Because the HTML5 event loop plays nicely with 10 the back/forward cache, we can now let pages using MediaKeySession / WebKitMediaKeySession 11 into the back/forward cache. 12 13 Test: http/tests/navigation/page-cache-mediakeysession.html 14 15 * Modules/encryptedmedia/MediaKeySession.cpp: 16 (WebCore::MediaKeySession::MediaKeySession): 17 (WebCore::MediaKeySession::generateRequest): 18 (WebCore::MediaKeySession::load): 19 (WebCore::MediaKeySession::update): 20 (WebCore::MediaKeySession::close): 21 (WebCore::MediaKeySession::remove): 22 (WebCore::MediaKeySession::enqueueMessage): 23 (WebCore::MediaKeySession::updateKeyStatuses): 24 (WebCore::MediaKeySession::hasPendingActivity const): 25 (WebCore::MediaKeySession::activeDOMObjectName const): 26 (WebCore::MediaKeySession::enqueueTask): 27 (WebCore::MediaKeySession::enqueueEvent): 28 (WebCore::MediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted. 29 (WebCore::MediaKeySession::stop): Deleted. 30 * Modules/encryptedmedia/MediaKeySession.h: 31 * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp: 32 (WebCore::WebKitMediaKeySession::WebKitMediaKeySession): 33 (WebCore::WebKitMediaKeySession::~WebKitMediaKeySession): 34 (WebCore::WebKitMediaKeySession::addKeyTimerFired): 35 (WebCore::WebKitMediaKeySession::sendMessage): 36 (WebCore::WebKitMediaKeySession::sendError): 37 (WebCore::WebKitMediaKeySession::hasPendingActivity const): 38 (WebCore::WebKitMediaKeySession::enqueueEvent): 39 (WebCore::WebKitMediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED const): Deleted. 40 * Modules/encryptedmedia/legacy/WebKitMediaKeySession.h: 41 1 42 2019-11-04 Ross Kirsling <ross.kirsling@sony.com> 2 43 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
r252008 r252033 32 32 #if ENABLE(ENCRYPTED_MEDIA) 33 33 34 #include "AbstractEventLoop.h" 34 35 #include "CDM.h" 35 36 #include "CDMInstance.h" … … 71 72 , m_implementation(WTFMove(implementation)) 72 73 , m_instanceSession(WTFMove(instanceSession)) 73 , m_eventQueue(MainThreadGenericEventQueue::create(*this))74 74 { 75 75 // https://w3c.github.io/encrypted-media/#dom-mediakeys-createsession … … 158 158 // 9. Let promise be a new promise. 159 159 // 10. Run the following steps in parallel: 160 m_taskQueue.enqueueTask([this, initData = SharedBuffer::create(initData.data(), initData.length()), initDataType, promise = WTFMove(promise)] () mutable {160 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, initData = SharedBuffer::create(initData.data(), initData.length()), initDataType, promise = WTFMove(promise)] () mutable { 161 161 // 10.1. If the init data is not valid for initDataType, reject promise with a newly created TypeError. 162 162 // 10.2. Let sanitized init data be a validated and sanitized version of init data. … … 227 227 228 228 // 10.10. Queue a task to run the following steps: 229 m_taskQueue.enqueueTask([this, promise = WTFMove(promise), message = WTFMove(message), messageType, sessionId, succeeded] () mutable {229 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, promise = WTFMove(promise), message = WTFMove(message), messageType, sessionId, succeeded] () mutable { 230 230 // 10.10.1. If any of the preceding steps failed, reject promise with a new DOMException whose name is the appropriate error name. 231 231 if (succeeded == CDMInstanceSession::SuccessValue::Failed) { … … 278 278 // 7. Let promise be a new promise. 279 279 // 8. Run the following steps in parallel: 280 m_taskQueue.enqueueTask([this, sessionId, promise = WTFMove(promise)] () mutable {280 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, sessionId, promise = WTFMove(promise)] () mutable { 281 281 // 8.1. Let sanitized session ID be a validated and/or sanitized version of sessionId. 282 282 // 8.2. If the preceding step failed, or if sanitized session ID is empty, reject promise with a newly created TypeError. … … 330 330 331 331 // 8.9. Queue a task to run the following steps: 332 m_taskQueue.enqueueTask([this, knownKeys = WTFMove(knownKeys), expiration = WTFMove(expiration), message = WTFMove(message), sanitizedSessionId, succeeded, promise = WTFMove(promise)] () mutable {332 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, knownKeys = WTFMove(knownKeys), expiration = WTFMove(expiration), message = WTFMove(message), sanitizedSessionId, succeeded, promise = WTFMove(promise)] () mutable { 333 333 // 8.9.1. If any of the preceding steps failed, reject promise with a the appropriate error name. 334 334 if (succeeded == CDMInstanceSession::SuccessValue::Failed) { … … 387 387 // 5. Let promise be a new promise. 388 388 // 6. Run the following steps in parallel: 389 m_taskQueue.enqueueTask([this, response = SharedBuffer::create(response.data(), response.length()), promise = WTFMove(promise)] () mutable {389 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, response = SharedBuffer::create(response.data(), response.length()), promise = WTFMove(promise)] () mutable { 390 390 // 6.1. Let sanitized response be a validated and/or sanitized version of response copy. 391 391 RefPtr<SharedBuffer> sanitizedResponse = m_implementation->sanitizeResponse(response); … … 438 438 // 6.7.3.2. Let message type be the appropriate MediaKeyMessageType for the message. 439 439 // 6.8. Queue a task to run the following steps: 440 m_taskQueue.enqueueTask([this, sessionWasClosed, changedKeys = WTFMove(changedKeys), changedExpiration = WTFMove(changedExpiration), message = WTFMove(message), promise = WTFMove(promise)] () mutable {440 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, sessionWasClosed, changedKeys = WTFMove(changedKeys), changedExpiration = WTFMove(changedExpiration), message = WTFMove(message), promise = WTFMove(promise)] () mutable { 441 441 LOG(EME, "EME - updating CDM license succeeded for session %s, sending a message to the license server", m_sessionId.utf8().data()); 442 442 // 6.8.1. … … 515 515 // 4. Let promise be a new promise. 516 516 // 5. Run the following steps in parallel: 517 m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {517 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, promise = WTFMove(promise)] () mutable { 518 518 // 5.1. Let cdm be the CDM instance represented by session's cdm instance value. 519 519 // 5.2. Use cdm to close the key session associated with session. … … 524 524 525 525 // 5.3. Queue a task to run the following steps: 526 m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {526 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, promise = WTFMove(promise)] () mutable { 527 527 // 5.3.1. Run the Session Closed algorithm on the session. 528 528 sessionClosed(); … … 553 553 // 3. Let promise be a new promise. 554 554 // 4. Run the following steps in parallel: 555 m_taskQueue.enqueueTask([this, promise = WTFMove(promise)] () mutable {555 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, promise = WTFMove(promise)] () mutable { 556 556 // 4.1. Let cdm be the CDM instance represented by this object's cdm instance value. 557 557 // 4.2. Let message be null. … … 578 578 579 579 // 4.5. Queue a task to run the following steps: 580 m_taskQueue.enqueueTask([this, keys = WTFMove(keys), message = WTFMove(message), succeeded, promise = WTFMove(promise)] () mutable {580 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, [this, keys = WTFMove(keys), message = WTFMove(message), succeeded, promise = WTFMove(promise)] () mutable { 581 581 // 4.5.1. Run the Update Key Statuses algorithm on the session, providing all key ID(s) in the session along with the "released" MediaKeyStatus value for each. 582 582 updateKeyStatuses(WTFMove(keys)); … … 617 617 // session. 618 618 auto messageEvent = MediaKeyMessageEvent::create(eventNames().messageEvent, {messageType, message.tryCreateArrayBuffer()}, Event::IsTrusted::Yes); 619 m_eventQueue->enqueueEvent(WTFMove(messageEvent));619 queueTaskToDispatchEvent(*this, TaskSource::Networking, WTFMove(messageEvent)); 620 620 } 621 621 … … 662 662 663 663 // 5. Queue a task to fire a simple event named keystatuseschange at the session. 664 m_eventQueue->enqueueEvent(Event::create(eventNames().keystatuseschangeEvent, Event::CanBubble::No, Event::IsCancelable::No));664 queueTaskToDispatchEvent(*this, TaskSource::Networking, Event::create(eventNames().keystatuseschangeEvent, Event::CanBubble::No, Event::IsCancelable::No)); 665 665 666 666 // 6. Queue a task to run the Attempt to Resume Playback If Necessary algorithm on each of the media element(s) whose mediaKeys attribute is the MediaKeys object that created the session. 667 m_taskQueue.enqueueTask(667 queueTaskKeepingObjectAlive(*this, TaskSource::Networking, 668 668 [this] () mutable { 669 669 if (m_keys) … … 734 734 bool MediaKeySession::hasPendingActivity() const 735 735 { 736 notImplemented();737 return false;736 // A MediaKeySession object SHALL NOT be destroyed and SHALL continue to receive events if it is not closed and the MediaKeys object that created it remains accessible. 737 return (!m_closed && m_keys) || ActiveDOMObject::hasPendingActivity(); 738 738 } 739 739 740 740 const char* MediaKeySession::activeDOMObjectName() const 741 741 { 742 notImplemented();743 742 return "MediaKeySession"; 744 743 } 745 744 746 // FIXME: This should never prevent entering the back/forward cache.747 bool MediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED() const748 {749 notImplemented();750 return true;751 }752 753 void MediaKeySession::stop()754 {755 notImplemented();756 }757 758 745 } // namespace WebCore 759 746 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
r252008 r252033 34 34 #include "CDMInstanceSession.h" 35 35 #include "EventTarget.h" 36 #include "GenericEventQueue.h"37 #include "GenericTaskQueue.h"38 36 #include "IDLTypes.h" 39 37 #include "MediaKeyMessageType.h" … … 41 39 #include "MediaKeyStatus.h" 42 40 #include <wtf/RefCounted.h> 41 #include <wtf/UniqueRef.h> 43 42 #include <wtf/Vector.h> 44 43 #include <wtf/WeakPtr.h> … … 105 104 // ActiveDOMObject 106 105 const char* activeDOMObjectName() const override; 107 bool shouldPreventEnteringBackForwardCache_DEPRECATED() const override;108 void stop() override;109 106 110 107 WeakPtr<MediaKeys> m_keys; … … 120 117 Ref<CDM> m_implementation; 121 118 Ref<CDMInstanceSession> m_instanceSession; 122 UniqueRef<MainThreadGenericEventQueue> m_eventQueue;123 GenericTaskQueue<Timer> m_taskQueue;124 119 Vector<Ref<SharedBuffer>> m_recordOfKeyUsage; 125 120 double m_firstDecryptTime { 0 }; -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.cpp
r250735 r252033 32 32 #if ENABLE(ENCRYPTED_MEDIA) 33 33 34 #include "AbstractEventLoop.h" 34 35 #include "CDM.h" 35 36 #include "CDMClient.h" … … 38 39 #include "Logging.h" 39 40 #include "MediaKeySession.h" 41 #include "ScriptExecutionContext.h" 40 42 #include "SharedBuffer.h" 41 43 … … 80 82 } 81 83 82 void MediaKeys::setServerCertificate( const BufferSource& serverCertificate, Ref<DeferredPromise>&& promise)84 void MediaKeys::setServerCertificate(ScriptExecutionContext& context, const BufferSource& serverCertificate, Ref<DeferredPromise>&& promise) 83 85 { 84 86 // https://w3c.github.io/encrypted-media/#dom-mediakeys-setservercertificate … … 105 107 // 5. Run the following steps in parallel: 106 108 107 m_taskQueue.enqueueTask([this, certificate = WTFMove(certificate), promise = WTFMove(promise)] () mutable {109 context.eventLoop().queueTask(TaskSource::Networking, context, [this, certificate = WTFMove(certificate), promise = WTFMove(promise)] () mutable { 108 110 // 5.1. Use this object's cdm instance to process certificate. 109 111 if (m_instance->setServerCertificate(WTFMove(certificate)) == CDMInstance::Failed) { -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.h
r250735 r252033 32 32 33 33 #include "ExceptionOr.h" 34 #include "GenericTaskQueue.h"35 34 #include "MediaKeySessionType.h" 36 35 #include <wtf/Ref.h> … … 60 59 61 60 ExceptionOr<Ref<MediaKeySession>> createSession(ScriptExecutionContext&, MediaKeySessionType); 62 void setServerCertificate( const BufferSource&, Ref<DeferredPromise>&&);61 void setServerCertificate(ScriptExecutionContext&, const BufferSource&, Ref<DeferredPromise>&&); 63 62 64 63 void attachCDMClient(CDMClient&); … … 81 80 Vector<Ref<MediaKeySession>> m_sessions; 82 81 Vector<CDMClient*> m_cdmClients; 83 GenericTaskQueue<Timer> m_taskQueue;84 82 }; 85 83 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeys.idl
r236818 r252033 34 34 ] interface MediaKeys { 35 35 [CallWith=ScriptExecutionContext, MayThrowException] MediaKeySession createSession(optional MediaKeySessionType sessionType = "temporary"); 36 Promise<bool> setServerCertificate(BufferSource serverCertificate);36 [CallWith=ScriptExecutionContext] Promise<bool> setServerCertificate(BufferSource serverCertificate); 37 37 }; -
trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp
r252008 r252033 29 29 #if ENABLE(LEGACY_ENCRYPTED_MEDIA) 30 30 31 #include "AbstractEventLoop.h" 31 32 #include "Document.h" 32 33 #include "EventNames.h" … … 55 56 , m_keys(&keys) 56 57 , m_keySystem(keySystem) 57 , m_asyncEventQueue(MainThreadGenericEventQueue::create(*this))58 58 , m_session(keys.cdm().createSession(*this)) 59 59 , m_keyRequestTimer(*this, &WebKitMediaKeySession::keyRequestTimerFired) … … 68 68 if (m_session) 69 69 m_session->setClient(nullptr); 70 71 m_asyncEventQueue->cancelAllEvents();72 70 } 73 71 … … 184 182 auto keyaddedEvent = Event::create(eventNames().webkitkeyaddedEvent, Event::CanBubble::No, Event::IsCancelable::No); 185 183 keyaddedEvent->setTarget(this); 186 m_asyncEventQueue->enqueueEvent(WTFMove(keyaddedEvent));184 queueTaskToDispatchEvent(*this, TaskSource::Networking, WTFMove(keyaddedEvent)); 187 185 188 186 ASSERT(m_keys); … … 208 206 auto event = WebKitMediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, message, destinationURL); 209 207 event->setTarget(this); 210 m_asyncEventQueue->enqueueEvent(WTFMove(event));208 queueTaskToDispatchEvent(*this, TaskSource::Networking, WTFMove(event)); 211 209 } 212 210 … … 217 215 auto keyerrorEvent = Event::create(eventNames().webkitkeyerrorEvent, Event::CanBubble::No, Event::IsCancelable::No); 218 216 keyerrorEvent->setTarget(this); 219 m_asyncEventQueue->enqueueEvent(WTFMove(keyerrorEvent));217 queueTaskToDispatchEvent(*this, TaskSource::Networking, WTFMove(keyerrorEvent)); 220 218 } 221 219 … … 239 237 bool WebKitMediaKeySession::hasPendingActivity() const 240 238 { 241 return (m_keys && m_session) || m_asyncEventQueue->hasPendingEvents();239 return (m_keys && m_session) || ActiveDOMObject::hasPendingActivity(); 242 240 } 243 241 … … 252 250 } 253 251 254 bool WebKitMediaKeySession::shouldPreventEnteringBackForwardCache_DEPRECATED() const255 {256 // FIXME: This should never prevent entering the back/forward cache.257 return true;258 }259 260 252 } 261 253 -
trunk/Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.h
r252008 r252033 31 31 #include "EventTarget.h" 32 32 #include "ExceptionOr.h" 33 #include "GenericEventQueue.h"34 33 #include "LegacyCDMSession.h" 35 34 #include "Timer.h" … … 42 41 class WebKitMediaKeys; 43 42 44 class WebKitMediaKeySession final : public RefCounted<WebKitMediaKeySession>, public EventTargetWithInlineData, p rivateActiveDOMObject, private LegacyCDMSessionClient {43 class WebKitMediaKeySession final : public RefCounted<WebKitMediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, private LegacyCDMSessionClient { 45 44 WTF_MAKE_ISO_ALLOCATED(WebKitMediaKeySession); 46 45 public: … … 79 78 80 79 void stop() final; 81 bool shouldPreventEnteringBackForwardCache_DEPRECATED() const final;82 80 const char* activeDOMObjectName() const final; 83 81 … … 89 87 String m_sessionId; 90 88 RefPtr<WebKitMediaKeyError> m_error; 91 UniqueRef<MainThreadGenericEventQueue> m_asyncEventQueue;92 89 std::unique_ptr<LegacyCDMSession> m_session; 93 90
Note: See TracChangeset
for help on using the changeset viewer.