Changeset 218498 in webkit


Ignore:
Timestamp:
Jun 19, 2017 10:44:20 AM (7 years ago)
Author:
Chris Dumez
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:
Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r218497 r218498  
     12017-06-19  Chris Dumez  <cdumez@apple.com>
     2
     3        Use WTF::Function instead of std::function in WebCore/Modules
     4        https://bugs.webkit.org/show_bug.cgi?id=173534
     5
     6        Reviewed by Alex Christensen.
     7
     8        Use WTF::Function instead of std::function in WebCore/Modules to avoid
     9        copying.
     10
     11        * Modules/applepay/PaymentCoordinatorClient.h:
     12        * Modules/encryptedmedia/CDM.h:
     13        * Modules/encryptedmedia/legacy/LegacyCDM.cpp:
     14        (WebCore::CDMFactory::CDMFactory):
     15        (WebCore::CDM::registerCDMFactory):
     16        * Modules/encryptedmedia/legacy/LegacyCDM.h:
     17        * Modules/mediasession/MediaSession.cpp:
     18        (WebCore::MediaSession::changeActiveMediaElements):
     19        (WebCore::MediaSession::safelyIterateActiveMediaElements):
     20        * Modules/mediasession/MediaSession.h:
     21        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
     22        (WebCore::matchTransceiver):
     23        * Modules/mediastream/MediaStreamRegistry.cpp:
     24        (WebCore::MediaStreamRegistry::forEach):
     25        * Modules/mediastream/MediaStreamRegistry.h:
     26
    1272017-06-19  Youenn Fablet  <youenn@apple.com>
    228
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h

    r218457 r218498  
    2929
    3030#include "PaymentRequest.h"
    31 #include <functional>
    3231#include <wtf/Forward.h>
     32#include <wtf/Function.h>
    3333
    3434namespace WebCore {
  • trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp

    r217973 r218498  
    162162        callback(WTFMove(configuration));
    163163    };
    164     getConsentStatus(WTFMove(optionalConfiguration.value()), WTFMove(restrictions), consentCallback);
     164    getConsentStatus(WTFMove(optionalConfiguration.value()), WTFMove(restrictions), WTFMove(consentCallback));
    165165}
    166166
  • trunk/Source/WebCore/Modules/encryptedmedia/CDM.h

    r212110 r218498  
    3131#include "MediaKeySystemConfiguration.h"
    3232#include "SharedBuffer.h"
    33 #include <functional>
     33#include <wtf/Function.h>
    3434#include <wtf/HashSet.h>
    3535#include <wtf/Ref.h>
     
    6767    ~CDM();
    6868
    69     using SupportedConfigurationCallback = std::function<void(std::optional<MediaKeySystemConfiguration>)>;
     69    using SupportedConfigurationCallback = WTF::Function<void(std::optional<MediaKeySystemConfiguration>)>;
    7070    void getSupportedConfiguration(MediaKeySystemConfiguration&& candidateConfiguration, SupportedConfigurationCallback&&);
    7171
     
    111111    WeakPtr<CDM> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); }
    112112
    113     using ConsentStatusCallback = std::function<void(ConsentStatus, MediaKeySystemConfiguration&&, MediaKeysRestrictions&&)>;
     113    using ConsentStatusCallback = WTF::Function<void(ConsentStatus, MediaKeySystemConfiguration&&, MediaKeysRestrictions&&)>;
    114114    void getConsentStatus(MediaKeySystemConfiguration&& accumulatedConfiguration, MediaKeysRestrictions&&, ConsentStatusCallback&&);
    115115    String m_keySystem;
  • trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp

    r215686 r218498  
    633633            return MediaKeyStatus::StatusPending;
    634634        case CDMInstance::KeyStatus::InternalError:
    635             return MediaKeyStatus::InternalError;
     635            break;
    636636        };
     637        return MediaKeyStatus::InternalError;
    637638    };
    638639
  • trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.cpp

    r209936 r218498  
    4747    WTF_MAKE_NONCOPYABLE(CDMFactory); WTF_MAKE_FAST_ALLOCATED;
    4848public:
    49     CDMFactory(CreateCDM constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
    50         : constructor(constructor)
     49    CDMFactory(CreateCDM&& constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
     50        : constructor(WTFMove(constructor))
    5151        , supportsKeySystem(supportsKeySystem)
    5252        , supportsKeySystemAndMimeType(supportsKeySystemAndMimeType)
     
    8282}
    8383
    84 void CDM::registerCDMFactory(CreateCDM constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
     84void CDM::registerCDMFactory(CreateCDM&& constructor, CDMSupportsKeySystem supportsKeySystem, CDMSupportsKeySystemAndMimeType supportsKeySystemAndMimeType)
    8585{
    86     installedCDMFactories().append(new CDMFactory(constructor, supportsKeySystem, supportsKeySystemAndMimeType));
     86    installedCDMFactories().append(new CDMFactory(WTFMove(constructor), supportsKeySystem, supportsKeySystemAndMimeType));
    8787}
    8888
  • trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDM.h

    r209936 r218498  
    3131#include <runtime/Uint8Array.h>
    3232#include <wtf/Forward.h>
     33#include <wtf/Function.h>
    3334#include <wtf/text/WTFString.h>
    3435
     
    3940class MediaPlayer;
    4041
    41 typedef std::function<std::unique_ptr<CDMPrivateInterface> (CDM*)> CreateCDM;
     42using CreateCDM = WTF::Function<std::unique_ptr<CDMPrivateInterface> (CDM*)>;
    4243typedef bool (*CDMSupportsKeySystem)(const String&);
    4344typedef bool (*CDMSupportsKeySystemAndMimeType)(const String&, const String&);
     
    5859    static bool keySystemSupportsMimeType(const String& keySystem, const String& mimeType);
    5960    static std::unique_ptr<CDM> create(const String& keySystem);
    60     WEBCORE_EXPORT static void registerCDMFactory(CreateCDM, CDMSupportsKeySystem, CDMSupportsKeySystemAndMimeType);
     61    WEBCORE_EXPORT static void registerCDMFactory(CreateCDM&&, CDMSupportsKeySystem, CDMSupportsKeySystemAndMimeType);
    6162    ~CDM();
    6263
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp

    r209240 r218498  
    8484}
    8585
    86 void MediaSession::changeActiveMediaElements(std::function<void(void)> worker)
     86void MediaSession::changeActiveMediaElements(const WTF::Function<void(void)>& worker)
    8787{
    8888    if (Page *page = m_document.page()) {
     
    238238}
    239239
    240 void MediaSession::safelyIterateActiveMediaElements(std::function<void(HTMLMediaElement*)> handler)
     240void MediaSession::safelyIterateActiveMediaElements(const WTF::Function<void(HTMLMediaElement*)>& handler)
    241241{
    242242    ASSERT(!m_iteratedActiveParticipatingElements);
  • trunk/Source/WebCore/Modules/mediasession/MediaSession.h

    r209240 r218498  
    3030#include "MediaRemoteControls.h"
    3131#include "MediaSessionMetadata.h"
     32#include <wtf/Function.h>
    3233#include <wtf/HashSet.h>
    3334
     
    8990    void removeMediaElement(HTMLMediaElement&);
    9091
    91     void safelyIterateActiveMediaElements(std::function<void(HTMLMediaElement*)>);
    92     void changeActiveMediaElements(std::function<void(void)>);
     92    void safelyIterateActiveMediaElements(const WTF::Function<void(HTMLMediaElement*)>&);
     93    void changeActiveMediaElements(const WTF::Function<void(void)>&);
    9394    void addActiveMediaElement(HTMLMediaElement&);
    9495    bool isMediaElementActive(HTMLMediaElement&);
  • trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp

    r216501 r218498  
    5353#include "RTCTrackEvent.h"
    5454#include "SDPProcessor.h"
     55#include <wtf/Function.h>
    5556#include <wtf/MainThread.h>
    5657#include <wtf/text/Base64.h>
     
    103104}
    104105
    105 static RTCRtpTransceiver* matchTransceiver(const RtpTransceiverVector& transceivers, const std::function<bool(RTCRtpTransceiver&)>& matchFunction)
     106static RTCRtpTransceiver* matchTransceiver(const RtpTransceiverVector& transceivers, const WTF::Function<bool(RTCRtpTransceiver&)>& matchFunction)
    106107{
    107108    for (auto& transceiver : transceivers) {
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.cpp

    r216197 r218498  
    8787}
    8888
    89 void MediaStreamRegistry::forEach(std::function<void(MediaStream&)> callback) const
     89void MediaStreamRegistry::forEach(const WTF::Function<void(MediaStream&)>& callback) const
    9090{
    9191    for (auto& stream : mediaStreams())
  • trunk/Source/WebCore/Modules/mediastream/MediaStreamRegistry.h

    r218488 r218498  
    2929
    3030#include "URLRegistry.h"
    31 #include <functional>
     31#include <wtf/Function.h>
    3232#include <wtf/HashMap.h>
    3333#include <wtf/text/StringHash.h>
     
    5757    MediaStream* lookUp(const URL&) const;
    5858
    59     void forEach(std::function<void(MediaStream&)>) const;
     59    void forEach(const WTF::Function<void(MediaStream&)>&) const;
    6060
    6161private:
Note: See TracChangeset for help on using the changeset viewer.