Title: [218498] trunk/Source/WebCore
Revision
218498
Author
cdu...@apple.com
Date
2017-06-19 10:44:20 -0700 (Mon, 19 Jun 2017)

Log Message

Use WTF::Function instead of std::function in WebCore/Modules
https://bugs.webkit.org/show_bug.cgi?id=173534

Reviewed by Alex Christensen.

Use WTF::Function instead of std::function in WebCore/Modules to avoid
copying.

* Modules/applepay/PaymentCoordinatorClient.h:
* Modules/encryptedmedia/CDM.h:
* Modules/encryptedmedia/legacy/LegacyCDM.cpp:
(WebCore::CDMFactory::CDMFactory):
(WebCore::CDM::registerCDMFactory):
* Modules/encryptedmedia/legacy/LegacyCDM.h:
* Modules/mediasession/MediaSession.cpp:
(WebCore::MediaSession::changeActiveMediaElements):
(WebCore::MediaSession::safelyIterateActiveMediaElements):
* Modules/mediasession/MediaSession.h:
* Modules/mediastream/MediaEndpointPeerConnection.cpp:
(WebCore::matchTransceiver):
* Modules/mediastream/MediaStreamRegistry.cpp:
(WebCore::MediaStreamRegistry::forEach):
* Modules/mediastream/MediaStreamRegistry.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218497 => 218498)


--- trunk/Source/WebCore/ChangeLog	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/ChangeLog	2017-06-19 17:44:20 UTC (rev 218498)
@@ -1,3 +1,29 @@
+2017-06-19  Chris Dumez  <cdu...@apple.com>
+
+        Use WTF::Function instead of std::function in WebCore/Modules
+        https://bugs.webkit.org/show_bug.cgi?id=173534
+
+        Reviewed by Alex Christensen.
+
+        Use WTF::Function instead of std::function in WebCore/Modules to avoid
+        copying.
+
+        * Modules/applepay/PaymentCoordinatorClient.h:
+        * Modules/encryptedmedia/CDM.h:
+        * Modules/encryptedmedia/legacy/LegacyCDM.cpp:
+        (WebCore::CDMFactory::CDMFactory):
+        (WebCore::CDM::registerCDMFactory):
+        * Modules/encryptedmedia/legacy/LegacyCDM.h:
+        * Modules/mediasession/MediaSession.cpp:
+        (WebCore::MediaSession::changeActiveMediaElements):
+        (WebCore::MediaSession::safelyIterateActiveMediaElements):
+        * Modules/mediasession/MediaSession.h:
+        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+        (WebCore::matchTransceiver):
+        * Modules/mediastream/MediaStreamRegistry.cpp:
+        (WebCore::MediaStreamRegistry::forEach):
+        * Modules/mediastream/MediaStreamRegistry.h:
+
 2017-06-19  Youenn Fablet  <you...@apple.com>
 
         A cloned MediaStreamTrack should mute independently other tracks using the same source

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h (218497 => 218498)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h	2017-06-19 17:44:20 UTC (rev 218498)
@@ -28,8 +28,8 @@
 #if ENABLE(APPLE_PAY)
 
 #include "PaymentRequest.h"
-#include <functional>
 #include <wtf/Forward.h>
+#include <wtf/Function.h>
 
 namespace WebCore {
 

Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp (218497 => 218498)


--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp	2017-06-19 17:44:20 UTC (rev 218498)
@@ -161,7 +161,7 @@
         // 23. Return accumulated configuration.
         callback(WTFMove(configuration));
     };
-    getConsentStatus(WTFMove(optionalConfiguration.value()), WTFMove(restrictions), consentCallback);
+    getConsentStatus(WTFMove(optionalConfiguration.value()), WTFMove(restrictions), WTFMove(consentCallback));
 }
 
 bool CDM::isPersistentType(MediaKeySessionType sessionType)

Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.h (218497 => 218498)


--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.h	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.h	2017-06-19 17:44:20 UTC (rev 218498)
@@ -30,7 +30,7 @@
 #include "ContextDestructionObserver.h"
 #include "MediaKeySystemConfiguration.h"
 #include "SharedBuffer.h"
-#include <functional>
+#include <wtf/Function.h>
 #include <wtf/HashSet.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
@@ -66,7 +66,7 @@
     static Ref<CDM> create(Document&, const String& keySystem);
     ~CDM();
 
-    using SupportedConfigurationCallback = std::function<void(std::optional<MediaKeySystemConfiguration>)>;
+    using SupportedConfigurationCallback = WTF::Function<void(std::optional<MediaKeySystemConfiguration>)>;
     void getSupportedConfiguration(MediaKeySystemConfiguration&& candidateConfiguration, SupportedConfigurationCallback&&);
 
     const String& keySystem() const { return m_keySystem; }
@@ -110,7 +110,7 @@
 
     WeakPtr<CDM> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
 
-    using ConsentStatusCallback = std::function<void(ConsentStatus, MediaKeySystemConfiguration&&, MediaKeysRestrictions&&)>;
+    using ConsentStatusCallback = WTF::Function<void(ConsentStatus, MediaKeySystemConfiguration&&, MediaKeysRestrictions&&)>;
     void getConsentStatus(MediaKeySystemConfiguration&& accumulatedConfiguration, MediaKeysRestrictions&&, ConsentStatusCallback&&);
     String m_keySystem;
     std::unique_ptr<CDMPrivate> m_private;

Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (218497 => 218498)


--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp	2017-06-19 17:44:20 UTC (rev 218498)
@@ -632,8 +632,9 @@
         case CDMInstance::KeyStatus::StatusPending:
             return MediaKeyStatus::StatusPending;
         case CDMInstance::KeyStatus::InternalError:
-            return MediaKeyStatus::InternalError;
+            break;
         };
+        return MediaKeyStatus::InternalError;
     };
 
     m_statuses.clear();

Modified: trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.cpp (218497 => 218498)


--- trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.cpp	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.cpp	2017-06-19 17:44:20 UTC (rev 218498)
@@ -46,8 +46,8 @@
 struct CDMFactory {
     WTF_MAKE_NONCOPYABLE(CDMFactory); WTF_MAKE_FAST_ALLOCATED;
 public:
-    CDMFactory(CreateCDM constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
-        : constructor(constructor)
+    CDMFactory(CreateCDM&& constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
+        : constructor(WTFMove(constructor))
         , supportsKeySystem(supportsKeySystem)
         , supportsKeySystemAndMimeType(supportsKeySystemAndMimeType)
     {
@@ -81,9 +81,9 @@
     return cdms;
 }
 
-void CDM::registerCDMFactory(CreateCDM constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
+void CDM::registerCDMFactory(CreateCDM&& constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
 {
-    installedCDMFactories().append(new CDMFactory(constructor, supportsKeySystem, supportsKeySystemAndMimeType));
+    installedCDMFactories().append(new CDMFactory(WTFMove(constructor), supportsKeySystem, supportsKeySystemAndMimeType));
 }
 
 static CDMFactory* CDMFactoryForKeySystem(const String& keySystem)

Modified: trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.h (218497 => 218498)


--- trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.h	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.h	2017-06-19 17:44:20 UTC (rev 218498)
@@ -30,6 +30,7 @@
 #include "LegacyCDMSession.h"
 #include <runtime/Uint8Array.h>
 #include <wtf/Forward.h>
+#include <wtf/Function.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -38,7 +39,7 @@
 class CDMPrivateInterface;
 class MediaPlayer;
 
-typedef std::function<std::unique_ptr<CDMPrivateInterface> (CDM*)> CreateCDM;
+using CreateCDM = WTF::Function<std::unique_ptr<CDMPrivateInterface> (CDM*)>;
 typedef bool (*CDMSupportsKeySystem)(const String&);
 typedef bool (*CDMSupportsKeySystemAndMimeType)(const String&, const String&);
 
@@ -57,7 +58,7 @@
     static bool supportsKeySystem(const String&);
     static bool keySystemSupportsMimeType(const String& keySystem, const String& mimeType);
     static std::unique_ptr<CDM> create(const String& keySystem);
-    WEBCORE_EXPORT static void registerCDMFactory(CreateCDM, CDMSupportsKeySystem, CDMSupportsKeySystemAndMimeType);
+    WEBCORE_EXPORT static void registerCDMFactory(CreateCDM&&, CDMSupportsKeySystem, CDMSupportsKeySystemAndMimeType);
     ~CDM();
 
     bool supportsMIMEType(const String&) const;

Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp (218497 => 218498)


--- trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp	2017-06-19 17:44:20 UTC (rev 218498)
@@ -83,7 +83,7 @@
         m_iteratedActiveParticipatingElements->remove(&element);
 }
 
-void MediaSession::changeActiveMediaElements(std::function<void(void)> worker)
+void MediaSession::changeActiveMediaElements(const WTF::Function<void(void)>& worker)
 {
     if (Page *page = m_document.page()) {
         bool hadActiveMediaElements = MediaSessionManager::singleton().hasActiveMediaElements();
@@ -237,7 +237,7 @@
     });
 }
 
-void MediaSession::safelyIterateActiveMediaElements(std::function<void(HTMLMediaElement*)> handler)
+void MediaSession::safelyIterateActiveMediaElements(const WTF::Function<void(HTMLMediaElement*)>& handler)
 {
     ASSERT(!m_iteratedActiveParticipatingElements);
 

Modified: trunk/Source/WebCore/Modules/mediasession/MediaSession.h (218497 => 218498)


--- trunk/Source/WebCore/Modules/mediasession/MediaSession.h	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSession.h	2017-06-19 17:44:20 UTC (rev 218498)
@@ -29,6 +29,7 @@
 
 #include "MediaRemoteControls.h"
 #include "MediaSessionMetadata.h"
+#include <wtf/Function.h>
 #include <wtf/HashSet.h>
 
 namespace WebCore {
@@ -88,8 +89,8 @@
     void addMediaElement(HTMLMediaElement&);
     void removeMediaElement(HTMLMediaElement&);
 
-    void safelyIterateActiveMediaElements(std::function<void(HTMLMediaElement*)>);
-    void changeActiveMediaElements(std::function<void(void)>);
+    void safelyIterateActiveMediaElements(const WTF::Function<void(HTMLMediaElement*)>&);
+    void changeActiveMediaElements(const WTF::Function<void(void)>&);
     void addActiveMediaElement(HTMLMediaElement&);
     bool isMediaElementActive(HTMLMediaElement&);
 

Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (218497 => 218498)


--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-06-19 17:44:20 UTC (rev 218498)
@@ -52,6 +52,7 @@
 #include "RTCRtpTransceiver.h"
 #include "RTCTrackEvent.h"
 #include "SDPProcessor.h"
+#include <wtf/Function.h>
 #include <wtf/MainThread.h>
 #include <wtf/text/Base64.h>
 
@@ -102,7 +103,7 @@
     m_mediaEndpoint->generateDtlsInfo();
 }
 
-static RTCRtpTransceiver* matchTransceiver(const RtpTransceiverVector& transceivers, const std::function<bool(RTCRtpTransceiver&)>& matchFunction)
+static RTCRtpTransceiver* matchTransceiver(const RtpTransceiverVector& transceivers, const WTF::Function<bool(RTCRtpTransceiver&)>& matchFunction)
 {
     for (auto& transceiver : transceivers) {
         if (matchFunction(*transceiver))

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.cpp (218497 => 218498)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.cpp	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.cpp	2017-06-19 17:44:20 UTC (rev 218498)
@@ -86,7 +86,7 @@
         allStreams.remove(pos);
 }
 
-void MediaStreamRegistry::forEach(std::function<void(MediaStream&)> callback) const
+void MediaStreamRegistry::forEach(const WTF::Function<void(MediaStream&)>& callback) const
 {
     for (auto& stream : mediaStreams())
         callback(*stream);

Modified: trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.h (218497 => 218498)


--- trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.h	2017-06-19 17:12:57 UTC (rev 218497)
+++ trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.h	2017-06-19 17:44:20 UTC (rev 218498)
@@ -28,7 +28,7 @@
 #if ENABLE(MEDIA_STREAM)
 
 #include "URLRegistry.h"
-#include <functional>
+#include <wtf/Function.h>
 #include <wtf/HashMap.h>
 #include <wtf/text/StringHash.h>
 
@@ -56,7 +56,7 @@
 
     MediaStream* lookUp(const URL&) const;
 
-    void forEach(std::function<void(MediaStream&)>) const;
+    void forEach(const WTF::Function<void(MediaStream&)>&) const;
 
 private:
     MediaStreamRegistry() = default;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to