Changeset 265115 in webkit
- Timestamp:
- Jul 30, 2020, 4:08:00 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r265113 r265115 1 2020-07-30 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Adopt -[AVContentKeyRequest willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:] 4 https://bugs.webkit.org/show_bug.cgi?id=214659 5 <rdar://problem/63555006> 6 7 Reviewed by Darin Adler. 8 9 Add a new Observer template class. This allows classes to provide support for listeners without requiring 10 those listeners to subclass from a pure-virtual (and CanMakeWeakPtr capable) client class. Instead, clients 11 can just create one of these Observer objects, and pass a WeakPtr to that observer to the notifying object. 12 When the client object destroys the observer, it is automatically unregistered when the observing object 13 uses a WeakHashSet. 14 15 * WTF.xcodeproj/project.pbxproj: 16 * wtf/CMakeLists.txt: 17 * wtf/Observer.h: Added. 18 (WTF::Observer<Out): 19 1 20 2020-07-30 Keith Miller <keith_miller@apple.com> 2 21 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r264586 r265115 687 687 C8F597CA2A57417FBAB92FD6 /* RandomDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RandomDevice.cpp; sourceTree = "<group>"; }; 688 688 CD00360D21501F7800F4ED4C /* StringToIntegerConversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StringToIntegerConversion.h; sourceTree = "<group>"; }; 689 CD48A87024C8A21600F5800C /* Observer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Observer.h; sourceTree = "<group>"; }; 689 690 CD5497AA15857D0300B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; }; 690 691 CD5497AB15857D0300B5BC30 /* MediaTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaTime.h; sourceTree = "<group>"; }; … … 1127 1128 8348BA0D21FBC0D400FD3054 /* ObjectIdentifier.cpp */, 1128 1129 83A8AC3D1FABBE94002064AC /* ObjectIdentifier.h */, 1130 CD48A87024C8A21600F5800C /* Observer.h */, 1129 1131 1AFDE6521953B23D00C48FFA /* Optional.h */, 1130 1132 1A4656181C7FC68E00F5920F /* OptionSet.h */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r264586 r265115 157 157 ObjCRuntimeExtras.h 158 158 ObjectIdentifier.h 159 Observer.h 159 160 OptionSet.h 160 161 OptionSetHash.h -
trunk/Source/WebCore/ChangeLog
r265114 r265115 1 2020-07-30 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Adopt -[AVContentKeyRequest willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:] 4 https://bugs.webkit.org/show_bug.cgi?id=214659 5 <rdar://problem/63555006> 6 7 Reviewed by Darin Adler. 8 9 Use the new WTF::Observer object as the listener type for notifying clients of display changes. When a displayChanged 10 event is observed, use the new AVContentKeyRequest -willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays: 11 to set the keyStatus for that request appropriately. 12 13 * Modules/encryptedmedia/MediaKeySession.cpp: 14 (WebCore::MediaKeySession::MediaKeySession): 15 (WebCore::MediaKeySession::displayID): 16 (WebCore::MediaKeySession::displayChanged): 17 * Modules/encryptedmedia/MediaKeySession.h: 18 * dom/Document.cpp: 19 (WebCore::Document::windowScreenDidChange): 20 (WebCore::Document::addDisplayChangedObserver): 21 * dom/Document.h: 22 * platform/encryptedmedia/CDMInstanceSession.h: 23 (WebCore::CDMInstanceSession::displayChanged): 24 * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h: 25 * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm: 26 (-[WebCoreFPSContentKeySessionDelegate contentKeySession:externalProtectionStatusDidChangeForContentKeyRequest:]): 27 (WebCore::CDMInstanceFairPlayStreamingAVFObjC::externalProtectionStatusDidChangeForContentKeyRequest): 28 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::displayChanged): 29 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::externalProtectionStatusDidChangeForContentKeyRequest): 30 (WebCore::CDMInstanceSessionFairPlayStreamingAVFObjC::updateProtectionStatusForDisplayID): 31 1 32 2020-07-30 James Darpinian <jdarpinian@chromium.org> 2 33 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
r259252 r265115 77 77 , m_implementation(WTFMove(implementation)) 78 78 , m_instanceSession(WTFMove(instanceSession)) 79 , m_displayChangedObserver([this] (auto displayID) { displayChanged(displayID); }) 79 80 { 80 81 // https://w3c.github.io/encrypted-media/#dom-mediakeys-createsession … … 106 107 #endif 107 108 m_instanceSession->setClient(makeWeakPtr(*this)); 109 110 document.addDisplayChangedObserver(m_displayChangedObserver); 108 111 } 109 112 … … 723 726 } 724 727 728 PlatformDisplayID MediaKeySession::displayID() 729 { 730 auto* document = downcast<Document>(scriptExecutionContext()); 731 if (!document) 732 return 0; 733 734 if (auto* page = document->page()) 735 return page->displayID(); 736 737 return 0; 738 } 739 725 740 void MediaKeySession::updateExpiration(double) 726 741 { … … 791 806 #endif 792 807 808 void MediaKeySession::displayChanged(PlatformDisplayID displayID) 809 { 810 m_instanceSession->displayChanged(displayID); 811 } 812 793 813 } // namespace WebCore 794 814 -
trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h
r262781 r265115 38 38 #include "MediaKeySessionType.h" 39 39 #include "MediaKeyStatus.h" 40 #include <wtf/Observer.h> 40 41 #include <wtf/RefCounted.h> 41 42 #include <wtf/UniqueRef.h> … … 100 101 void sendMessage(CDMMessageType, Ref<SharedBuffer>&& message) final; 101 102 void sessionIdChanged(const String&) final; 103 PlatformDisplayID displayID() final; 102 104 103 105 // EventTarget … … 110 112 const char* activeDOMObjectName() const final; 111 113 bool virtualHasPendingActivity() const final; 114 115 // DisplayChangedObserver 116 void displayChanged(PlatformDisplayID); 112 117 113 118 #if !RELEASE_LOG_DISABLED … … 138 143 double m_latestDecryptTime { 0 }; 139 144 Vector<std::pair<Ref<SharedBuffer>, MediaKeyStatus>> m_statuses; 145 146 using DisplayChangedObserver = Observer<void(PlatformDisplayID)>; 147 DisplayChangedObserver m_displayChangedObserver; 140 148 }; 141 149 -
trunk/Source/WebCore/PAL/ChangeLog
r265073 r265115 1 2020-07-30 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Adopt -[AVContentKeyRequest willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:] 4 https://bugs.webkit.org/show_bug.cgi?id=214659 5 <rdar://problem/63555006> 6 7 Reviewed by Darin Adler. 8 9 * pal/spi/cocoa/AVFoundationSPI.h: 10 1 11 2020-07-29 Jer Noble <jer.noble@apple.com> 2 12 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h
r264719 r265115 197 197 - (nonnull AVContentKeyReportGroup *)makeContentKeyGroup; 198 198 @end 199 200 @interface AVContentKeyRequest (OutputObscured) 201 NS_ASSUME_NONNULL_BEGIN 202 - (BOOL)willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:(NSArray<NSNumber *> *)displays; 203 NS_ASSUME_NONNULL_END 204 @end 199 205 #endif // HAVE(AVCONTENTKEYSESSION) 200 206 -
trunk/Source/WebCore/dom/Document.cpp
r265044 r265115 6466 6466 view->compositor().windowScreenDidChange(displayID); 6467 6467 } 6468 6469 for (auto& observer : copyToVector(m_displayChangedObservers)) { 6470 if (observer) 6471 (*observer)(displayID); 6472 } 6468 6473 } 6469 6474 … … 6518 6523 6519 6524 return listener; 6525 } 6526 6527 void Document::addDisplayChangedObserver(const DisplayChangedObserver& observer) 6528 { 6529 ASSERT(!m_displayChangedObservers.contains(observer)); 6530 m_displayChangedObservers.add(observer); 6520 6531 } 6521 6532 -
trunk/Source/WebCore/dom/Document.h
r264269 r265115 73 73 #include <wtf/Logger.h> 74 74 #include <wtf/ObjectIdentifier.h> 75 #include <wtf/Observer.h> 75 76 #include <wtf/UniqueRef.h> 76 77 #include <wtf/WeakHashSet.h> … … 1170 1171 MediaCanStartListener* takeAnyMediaCanStartListener(); 1171 1172 1173 using DisplayChangedObserver = WTF::Observer<void(PlatformDisplayID)>; 1174 void addDisplayChangedObserver(const DisplayChangedObserver&); 1175 1172 1176 #if ENABLE(FULLSCREEN_API) 1173 1177 FullscreenManager& fullscreenManager() { return m_fullscreenManager; } … … 1843 1847 1844 1848 WeakHashSet<MediaCanStartListener> m_mediaCanStartListeners; 1849 WeakHashSet<DisplayChangedObserver> m_displayChangedObservers; 1845 1850 1846 1851 #if ENABLE(FULLSCREEN_API) -
trunk/Source/WebCore/platform/encryptedmedia/CDMInstanceSession.h
r258295 r265115 55 55 virtual void sendMessage(CDMMessageType, Ref<SharedBuffer>&& message) = 0; 56 56 virtual void sessionIdChanged(const String&) = 0; 57 using PlatformDisplayID = uint32_t; 58 virtual PlatformDisplayID displayID() = 0; 57 59 }; 58 60 … … 103 105 104 106 virtual void storeRecordOfKeyUsage(const String& sessionId) = 0; 107 108 using PlatformDisplayID = uint32_t; 109 virtual void displayChanged(PlatformDisplayID) { } 105 110 }; 106 111 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.h
r258295 r265115 67 67 virtual void groupSessionIdentifierChanged(AVContentKeyReportGroup*, NSData*) = 0; 68 68 virtual void outputObscuredDueToInsufficientExternalProtectionChanged(bool) = 0; 69 virtual void externalProtectionStatusDidChangeForContentKeyRequest(AVContentKeyRequest*) = 0; 69 70 }; 70 71 … … 112 113 void groupSessionIdentifierChanged(AVContentKeyReportGroup*, NSData*) final; 113 114 void outputObscuredDueToInsufficientExternalProtectionChanged(bool) final; 115 void externalProtectionStatusDidChangeForContentKeyRequest(AVContentKeyRequest*) final; 114 116 115 117 using Keys = Vector<Ref<SharedBuffer>>; … … 155 157 void removeSessionData(const String&, LicenseType, RemoveSessionDataCallback&&) final; 156 158 void storeRecordOfKeyUsage(const String&) final; 159 void displayChanged(PlatformDisplayID) final; 157 160 void setClient(WeakPtr<CDMInstanceSessionClient>&&) final; 158 161 void clearClient() final; … … 169 172 void groupSessionIdentifierChanged(AVContentKeyReportGroup*, NSData*) final; 170 173 void outputObscuredDueToInsufficientExternalProtectionChanged(bool) final; 174 void externalProtectionStatusDidChangeForContentKeyRequest(AVContentKeyRequest*) final; 171 175 172 176 using Keys = CDMInstanceFairPlayStreamingAVFObjC::Keys; … … 196 200 const char* logClassName() const { return "CDMInstanceSessionFairPlayStreamingAVFObjC"; } 197 201 #endif 202 203 void updateProtectionStatusForDisplayID(PlatformDisplayID); 198 204 199 205 Ref<CDMInstanceFairPlayStreamingAVFObjC> m_instance; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm
r263422 r265115 160 160 } 161 161 162 - (void)contentKeySession:(AVContentKeySession *)session externalProtectionStatusDidChangeForContentKeyRequest:(AVContentKeyRequest *)keyRequest 163 { 164 UNUSED_PARAM(session); 165 if (_parent) 166 _parent->externalProtectionStatusDidChangeForContentKeyRequest(keyRequest); 167 } 168 162 169 @end 163 170 … … 516 523 sessionInterface->outputObscuredDueToInsufficientExternalProtectionChanged(obscured); 517 524 } 525 } 526 527 void CDMInstanceFairPlayStreamingAVFObjC::externalProtectionStatusDidChangeForContentKeyRequest(AVContentKeyRequest* request) 528 { 529 if (auto* session = sessionForRequest(request)) { 530 session->externalProtectionStatusDidChangeForContentKeyRequest(request); 531 return; 532 } 533 534 ASSERT_NOT_REACHED(); 535 ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "- no responsible session; dropping"); 518 536 } 519 537 … … 982 1000 } 983 1001 1002 void CDMInstanceSessionFairPlayStreamingAVFObjC::displayChanged(PlatformDisplayID displayID) 1003 { 1004 updateProtectionStatusForDisplayID(displayID); 1005 } 1006 984 1007 void CDMInstanceSessionFairPlayStreamingAVFObjC::setClient(WeakPtr<CDMInstanceSessionClient>&& client) 985 1008 { … … 1348 1371 } 1349 1372 1373 void CDMInstanceSessionFairPlayStreamingAVFObjC::externalProtectionStatusDidChangeForContentKeyRequest(AVContentKeyRequest* request) 1374 { 1375 UNUSED_PARAM(request); 1376 if (!m_client) 1377 return; 1378 1379 updateProtectionStatusForDisplayID(m_client->displayID()); 1380 } 1381 1382 void CDMInstanceSessionFairPlayStreamingAVFObjC::updateProtectionStatusForDisplayID(PlatformDisplayID displayID) 1383 { 1384 if (m_requests.isEmpty()) 1385 return; 1386 1387 auto keyRequestHasInsufficientProtectionForDisplayID = [displayID] (auto& request) -> bool { 1388 if ([request respondsToSelector:@selector(willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:)]) 1389 return [request willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:@[ @(displayID) ]]; 1390 return false; 1391 }; 1392 1393 bool outputWillBeObscured = WTF::anyOf(m_requests, [&](Request& request) { 1394 return WTF::anyOf(request.requests, keyRequestHasInsufficientProtectionForDisplayID); 1395 }); 1396 outputObscuredDueToInsufficientExternalProtectionChanged(outputWillBeObscured); 1397 } 1398 1350 1399 bool CDMInstanceSessionFairPlayStreamingAVFObjC::ensureSessionOrGroup() 1351 1400 { -
trunk/Source/WebKit/ChangeLog
r265098 r265115 1 2020-07-30 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Adopt -[AVContentKeyRequest willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:] 4 https://bugs.webkit.org/show_bug.cgi?id=214659 5 <rdar://problem/63555006> 6 7 Reviewed by Darin Adler. 8 9 Support clients in the GPU process asking for (and receiving updates to) the current displayID. 10 11 * GPUProcess/media/RemoteCDMInstanceSessionProxy.cpp: 12 (WebKit::RemoteCDMInstanceSessionProxy::displayIDChanged): 13 * GPUProcess/media/RemoteCDMInstanceSessionProxy.h: 14 * GPUProcess/media/RemoteCDMInstanceSessionProxy.messages.in: 15 1 16 2020-07-30 Antoine Quint <graouts@webkit.org> 2 17 -
trunk/Source/WebKit/GPUProcess/media/RemoteCDMInstanceSessionProxy.cpp
r257867 r265115 128 128 } 129 129 130 void RemoteCDMInstanceSessionProxy::displayIDChanged(PlatformDisplayID displayID) 131 { 132 m_session->displayChanged(displayID); 133 } 134 130 135 void RemoteCDMInstanceSessionProxy::updateKeyStatuses(KeyStatusVector&& keyStatuses) 131 136 { -
trunk/Source/WebKit/GPUProcess/media/RemoteCDMInstanceSessionProxy.h
r257867 r265115 74 74 void removeSessionData(const String& sessionId, LicenseType, RemoveSessionDataCallback&&); 75 75 void storeRecordOfKeyUsage(const String& sessionId); 76 void displayIDChanged(PlatformDisplayID); 76 77 77 78 // CDMInstanceSessionClient … … 79 80 void sendMessage(WebCore::CDMMessageType, Ref<WebCore::SharedBuffer>&& message) final; 80 81 void sessionIdChanged(const String&) final; 82 PlatformDisplayID displayID() final { return m_displayID; } 81 83 82 84 WeakPtr<RemoteCDMProxy> m_cdm; 83 85 Ref<WebCore::CDMInstanceSession> m_session; 84 86 RemoteCDMInstanceSessionIdentifier m_identifier; 87 PlatformDisplayID m_displayID { 0 }; 85 88 }; 86 89 -
trunk/Source/WebKit/GPUProcess/media/RemoteCDMInstanceSessionProxy.messages.in
r257867 r265115 33 33 RemoveSessionData(String sessionId, WebCore::CDMInstanceSession::LicenseType type) -> (WebCore::CDMInstanceSession::KeyStatusVector changedKeys, Optional<IPC::SharedBufferDataReference> message, bool succeeded) Async 34 34 StoreRecordOfKeyUsage(String sessionId) 35 DisplayIDChanged(uint32_t displayID) 35 36 } 36 37 -
trunk/Tools/ChangeLog
r265096 r265115 1 2020-07-30 Jer Noble <jer.noble@apple.com> 2 3 [Cocoa] Adopt -[AVContentKeyRequest willOutputBeObscuredDueToInsufficientExternalProtectionForDisplays:] 4 https://bugs.webkit.org/show_bug.cgi?id=214659 5 <rdar://problem/63555006> 6 7 Reviewed by Darin Adler. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WTF/Observer.cpp: Added. 11 (TestWebKitAPI::TEST): 12 1 13 2020-07-30 David Kilzer <ddkilzer@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r265059 r265115 980 980 CD3065E02165682E00E895DF /* VideoQualityDisplayCompositing.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */; }; 981 981 CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */; }; 982 CD48A87324C8A66F00F5800C /* Observer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD48A87224C8A66F00F5800C /* Observer.cpp */; }; 982 983 CD577799211CE0E4001B371E /* web-audio-only.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD577798211CDE8F001B371E /* web-audio-only.html */; }; 983 984 CD57779C211CE91F001B371E /* audio-with-web-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD57779A211CE6B7001B371E /* audio-with-web-audio.html */; }; … … 2651 2652 CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoQualityDisplayCompositing.mm; sourceTree = "<group>"; }; 2652 2653 CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "video-with-muted-audio-and-webaudio.html"; sourceTree = "<group>"; }; 2654 CD48A87224C8A66F00F5800C /* Observer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Observer.cpp; sourceTree = "<group>"; }; 2653 2655 CD5393C91757BAC400C07123 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = "<group>"; }; 2654 2656 CD5451E919E41F9D0016936F /* CSSParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSParser.cpp; sourceTree = "<group>"; }; … … 4132 4134 FEB6F74E1B2BA44E009E4922 /* NakedPtr.cpp */, 4133 4135 A57D54F21F338C3600A97AA7 /* NeverDestroyed.cpp */, 4136 CD48A87224C8A66F00F5800C /* Observer.cpp */, 4134 4137 1AFDE6541953B2C000C48FFA /* Optional.cpp */, 4135 4138 CE50D8C81C8665CE0072EA5A /* OptionSet.cpp */, … … 4857 4860 E38D65CA23A45FAA0063D69A /* PackedRef.cpp in Sources */, 4858 4861 E38D65CB23A45FAA0063D69A /* PackedRefPtr.cpp in Sources */, 4862 CD48A87324C8A66F00F5800C /* Observer.cpp in Sources */, 4859 4863 7C83DF591D0A590C00FEBCF3 /* ParkingLot.cpp in Sources */, 4860 4864 53EC25411E96FD87000831B9 /* PriorityQueue.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.