Remove unnecessary create() factory functions in CDMFoo, NamedNodeMap
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 01:04:19 +0000 (01:04 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2015 01:04:19 +0000 (01:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141902

Reviewed by Darin Adler.

Create instance using std::make_unique<> in CDMFactory directly. To do that,
CDMFactory uses lambdas. Additionally this patch removes NamedNodeMap::create() as well.

No new tests, no behavior changes.

* Modules/encryptedmedia/CDM.cpp:
(WebCore::installedCDMFactories):
* Modules/encryptedmedia/CDM.h:
* Modules/encryptedmedia/CDMPrivateClearKey.h:
(WebCore::CDMPrivateClearKey::CDMPrivateClearKey):
(WebCore::CDMPrivateClearKey::create): Deleted.
* Modules/encryptedmedia/CDMPrivateMediaPlayer.h:
(WebCore::CDMPrivateMediaPlayer::create): Deleted.
* dom/Element.cpp:
(WebCore::Element::attributes):
* dom/NamedNodeMap.h:
(WebCore::NamedNodeMap::NamedNodeMap):
(WebCore::NamedNodeMap::create): Deleted.
* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h:
(WebCore::CDMPrivateMediaSourceAVFObjC::create): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180712 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/encryptedmedia/CDM.cpp
Source/WebCore/Modules/encryptedmedia/CDM.h
Source/WebCore/Modules/encryptedmedia/CDMPrivateClearKey.h
Source/WebCore/Modules/encryptedmedia/CDMPrivateMediaPlayer.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/NamedNodeMap.h
Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/MockCDM.h

index 7a9354e..6bdf8d7 100644 (file)
@@ -1,3 +1,31 @@
+2015-02-26  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
+        Remove unnecessary create() factory functions in CDMFoo, NamedNodeMap
+        https://bugs.webkit.org/show_bug.cgi?id=141902
+
+        Reviewed by Darin Adler.
+
+        Create instance using std::make_unique<> in CDMFactory directly. To do that,
+        CDMFactory uses lambdas. Additionally this patch removes NamedNodeMap::create() as well.
+
+        No new tests, no behavior changes.
+
+        * Modules/encryptedmedia/CDM.cpp:
+        (WebCore::installedCDMFactories):
+        * Modules/encryptedmedia/CDM.h:
+        * Modules/encryptedmedia/CDMPrivateClearKey.h:
+        (WebCore::CDMPrivateClearKey::CDMPrivateClearKey):
+        (WebCore::CDMPrivateClearKey::create): Deleted.
+        * Modules/encryptedmedia/CDMPrivateMediaPlayer.h:
+        (WebCore::CDMPrivateMediaPlayer::create): Deleted.
+        * dom/Element.cpp:
+        (WebCore::Element::attributes):
+        * dom/NamedNodeMap.h:
+        (WebCore::NamedNodeMap::NamedNodeMap):
+        (WebCore::NamedNodeMap::create): Deleted.
+        * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.h:
+        (WebCore::CDMPrivateMediaSourceAVFObjC::create): Deleted.
+
 2015-02-26  Andy Estes  <aestes@apple.com>
 
         [Content Filtering] Move WebFilterEvaluator and NEFilterSource declarations to SPI headers
index 5d20b94..ad2fa77 100644 (file)
@@ -66,13 +66,16 @@ static Vector<CDMFactory*>& installedCDMFactories()
     if (!queriedCDMs) {
         queriedCDMs = true;
 
-        cdms.get().append(new CDMFactory(CDMPrivateClearKey::create, CDMPrivateClearKey::supportsKeySystem, CDMPrivateClearKey::supportsKeySystemAndMimeType));
+        cdms.get().append(new CDMFactory([](CDM* cdm) { return std::make_unique<CDMPrivateClearKey>(cdm); },
+            CDMPrivateClearKey::supportsKeySystem, CDMPrivateClearKey::supportsKeySystemAndMimeType));
 
         // FIXME: initialize specific UA CDMs. http://webkit.org/b/109318, http://webkit.org/b/109320
-        cdms.get().append(new CDMFactory(CDMPrivateMediaPlayer::create, CDMPrivateMediaPlayer::supportsKeySystem, CDMPrivateMediaPlayer::supportsKeySystemAndMimeType));
+        cdms.get().append(new CDMFactory([](CDM* cdm) { return std::make_unique<CDMPrivateMediaPlayer>(cdm); },
+            CDMPrivateMediaPlayer::supportsKeySystem, CDMPrivateMediaPlayer::supportsKeySystemAndMimeType));
 
 #if PLATFORM(MAC) && ENABLE(MEDIA_SOURCE)
-        cdms.get().append(new CDMFactory(CDMPrivateMediaSourceAVFObjC::create, CDMPrivateMediaSourceAVFObjC::supportsKeySystem, CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType));
+        cdms.get().append(new CDMFactory([](CDM* cdm) { return std::make_unique<CDMPrivateMediaSourceAVFObjC>(cdm); },
+            CDMPrivateMediaSourceAVFObjC::supportsKeySystem, CDMPrivateMediaSourceAVFObjC::supportsKeySystemAndMimeType));
 #endif
     }
 
index c04486c..5aecfc9 100644 (file)
@@ -40,7 +40,7 @@ class CDM;
 class CDMPrivateInterface;
 class MediaPlayer;
 
-typedef std::unique_ptr<CDMPrivateInterface> (*CreateCDM)(CDM*);
+typedef std::function<std::unique_ptr<CDMPrivateInterface> (CDM*)> CreateCDM;
 typedef bool (*CDMSupportsKeySystem)(const String&);
 typedef bool (*CDMSupportsKeySystemAndMimeType)(const String&, const String&);
 
index 235897d..d53b49c 100644 (file)
@@ -36,7 +36,11 @@ class CDM;
 
 class CDMPrivateClearKey : public CDMPrivateInterface {
 public:
-    static std::unique_ptr<CDMPrivateInterface> create(CDM* cdm) { return std::unique_ptr<CDMPrivateInterface>(new CDMPrivateClearKey(cdm)); }
+    explicit CDMPrivateClearKey(CDM* cdm)
+        : m_cdm(cdm)
+    {
+    }
+
     virtual ~CDMPrivateClearKey() { }
 
     static bool supportsKeySystem(const String&);
@@ -46,11 +50,6 @@ public:
     virtual std::unique_ptr<CDMSession> createSession() override;
 
 protected:
-    explicit CDMPrivateClearKey(CDM* cdm)
-        : m_cdm(cdm)
-    {
-    }
-
     CDM* m_cdm;
 };
 
index a49279f..de7e228 100644 (file)
@@ -42,7 +42,6 @@ public:
         : m_cdm(cdm)
     { }
 
-    static std::unique_ptr<CDMPrivateInterface> create(CDM* cdm) { return std::make_unique<CDMPrivateMediaPlayer>(cdm); }
     static bool supportsKeySystem(const String&);
     static bool supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType);
 
index 2a28398..d093222 100644 (file)
@@ -381,7 +381,7 @@ NamedNodeMap& Element::attributes() const
     if (NamedNodeMap* attributeMap = rareData.attributeMap())
         return *attributeMap;
 
-    rareData.setAttributeMap(NamedNodeMap::create(const_cast<Element&>(*this)));
+    rareData.setAttributeMap(std::make_unique<NamedNodeMap>(const_cast<Element&>(*this)));
     return *rareData.attributeMap();
 }
 
index 8273048..50eecdf 100644 (file)
@@ -40,9 +40,10 @@ class NamedNodeMap : public ScriptWrappable {
     WTF_MAKE_FAST_ALLOCATED;
     friend class Element;
 public:
-    static std::unique_ptr<NamedNodeMap> create(Element& element)
+    explicit NamedNodeMap(Element& element)
+        : m_element(element)
     {
-        return std::unique_ptr<NamedNodeMap>(new NamedNodeMap(element));
+        // Only supports NamedNodeMaps with Element associated, DocumentType.entities and DocumentType.notations are not supported yet.
     }
 
     void ref();
@@ -65,12 +66,6 @@ public:
     Element& element() const { return m_element; }
 
 private:
-    explicit NamedNodeMap(Element& element)
-        : m_element(element)
-    {
-        // Only supports NamedNodeMaps with Element associated, DocumentType.entities and DocumentType.notations are not supported yet.
-    }
-
     Element& m_element;
 };
 
index f560918..7a82b7a 100644 (file)
@@ -41,7 +41,6 @@ public:
     { }
     virtual ~CDMPrivateMediaSourceAVFObjC() { }
 
-    static std::unique_ptr<CDMPrivateInterface> create(CDM* cdm) { return std::make_unique<CDMPrivateMediaSourceAVFObjC>(cdm); }
     static bool supportsKeySystem(const String&);
     static bool supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType);
 
index 1085075..da6e709 100644 (file)
@@ -2127,7 +2127,8 @@ void Internals::forceReload(bool endToEnd)
 #if ENABLE(ENCRYPTED_MEDIA_V2)
 void Internals::initializeMockCDM()
 {
-    CDM::registerCDMFactory(MockCDM::create, MockCDM::supportsKeySystem, MockCDM::supportsKeySystemAndMimeType);
+    CDM::registerCDMFactory([](CDM* cdm) { return std::make_unique<MockCDM>(cdm); },
+        MockCDM::supportsKeySystem, MockCDM::supportsKeySystemAndMimeType);
 }
 #endif
 
index b7be8fa..74f38b9 100644 (file)
@@ -41,7 +41,6 @@ public:
     { }
 
     // CDMFactory support:
-    static std::unique_ptr<CDMPrivateInterface> create(CDM* cdm) { return std::make_unique<MockCDM>(cdm); }
     static bool supportsKeySystem(const String&);
     static bool supportsKeySystemAndMimeType(const String& keySystem, const String& mimeType);