Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (220263 => 220264)
--- trunk/Source/WebCore/CMakeLists.txt 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-08-04 09:54:42 UTC (rev 220264)
@@ -2303,6 +2303,8 @@
platform/audio/VectorMath.cpp
platform/audio/ZeroPole.cpp
+ platform/encryptedmedia/CDMFactory.cpp
+
platform/graphics/BitmapImage.cpp
platform/graphics/Color.cpp
platform/graphics/ComplexTextController.cpp
Modified: trunk/Source/WebCore/ChangeLog (220263 => 220264)
--- trunk/Source/WebCore/ChangeLog 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/ChangeLog 2017-08-04 09:54:42 UTC (rev 220264)
@@ -1,3 +1,59 @@
+2017-08-04 Zan Dobersek <[email protected]>
+
+ [EME] Push CDMFactory into the platform layer
+ https://bugs.webkit.org/show_bug.cgi?id=175129
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ This is a follow-up to r219678 that moved the majority of CDM abstraction
+ classes into the platform layer, but missed the CDMFactory class.
+
+ The CDMFactory abstraction is now also placed in the platform layer. Only
+ change to the interface is that the createCDM() method can't accept a CDM
+ object reference anymore since that class is cemented into the WebCore
+ layer, and no current implementation used it anyway.
+
+ Additionally, the static Vector object of registered factories is moved
+ under the CDMFactory class, along with the register and unregister
+ functions. The platformRegisterFactories() function is added to allow for
+ platform-specific factory registrations to occur when the registered
+ factories are queried for the first time. Empty implementation for this
+ function is provided for non-GStreamer platforms, while for GStreamer
+ the implementation is kept in CDMFactoryGStreamer.cpp. It's still empty
+ for now, but it will register the ClearKey factory there in the near
+ future.
+
+ No new tests -- none affected, only refactoring.
+
+ * CMakeLists.txt:
+ * Modules/encryptedmedia/CDM.cpp:
+ (WebCore::createCDMPrivateForKeySystem):
+ (WebCore::CDM::supportsKeySystem):
+ (WebCore::CDM::CDM):
+ (): Deleted.
+ (WebCore::CDM::registerCDMFactory): Deleted.
+ (WebCore::CDM::unregisterCDMFactory): Deleted.
+ * Modules/encryptedmedia/CDM.h:
+ (WebCore::CDMFactory::~CDMFactory): Deleted.
+ * PlatformWPE.cmake:
+ * platform/GStreamer.cmake:
+ * platform/encryptedmedia/CDMFactory.cpp: Added.
+ (WebCore::CDMFactory::registerFactory):
+ (WebCore::CDMFactory::unregisterFactory):
+ (WebCore::CDMFactory::platformRegisterFactories):
+ * platform/encryptedmedia/CDMFactory.h: Added.
+ (WebCore::CDMFactory::~CDMFactory):
+ * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
+ (WebCore::CDMFactoryClearKey::createCDM):
+ * platform/encryptedmedia/clearkey/CDMClearKey.h:
+ * platform/encryptedmedia/gstreamer/CDMFactoryGStreamer.cpp: Added.
+ (WebCore::CDMFactory::platformRegisterFactories):
+ * testing/MockCDMFactory.cpp:
+ (WebCore::m_weakPtrFactory):
+ (WebCore::MockCDMFactory::unregister):
+ (WebCore::MockCDMFactory::createCDM):
+ * testing/MockCDMFactory.h:
+
2017-08-04 Frederic Wang <[email protected]>
ScrollingTreeOverflowScrollingNodeIOS uses the wrong fixed position rectangle
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp (220263 => 220264)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.cpp 2017-08-04 09:54:42 UTC (rev 220264)
@@ -28,6 +28,7 @@
#if ENABLE(ENCRYPTED_MEDIA)
+#include "CDMFactory.h"
#include "CDMPrivate.h"
#include "Document.h"
#include "InitDataRegistry.h"
@@ -41,27 +42,9 @@
namespace WebCore {
-static Vector<CDMFactory*>& cdmFactories()
-{
- static NeverDestroyed<Vector<CDMFactory*>> factories;
- return factories;
-}
-
-void CDM::registerCDMFactory(CDMFactory& factory)
-{
- ASSERT(!cdmFactories().contains(&factory));
- cdmFactories().append(&factory);
-}
-
-void CDM::unregisterCDMFactory(CDMFactory& factory)
-{
- ASSERT(cdmFactories().contains(&factory));
- cdmFactories().removeAll(&factory);
-}
-
bool CDM::supportsKeySystem(const String& keySystem)
{
- for (auto* factory : cdmFactories()) {
+ for (auto* factory : CDMFactory::registeredFactories()) {
if (factory->supportsKeySystem(keySystem))
return true;
}
@@ -79,9 +62,9 @@
, m_weakPtrFactory(this)
{
ASSERT(supportsKeySystem(keySystem));
- for (auto* factory : cdmFactories()) {
+ for (auto* factory : CDMFactory::registeredFactories()) {
if (factory->supportsKeySystem(keySystem)) {
- m_private = factory->createCDM(*this);
+ m_private = factory->createCDM();
break;
}
}
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDM.h (220263 => 220264)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDM.h 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDM.h 2017-08-04 09:54:42 UTC (rev 220264)
@@ -42,7 +42,7 @@
namespace WebCore {
-class CDM;
+class CDMFactory;
class CDMInstance;
class CDMPrivate;
class Document;
@@ -49,18 +49,8 @@
class ScriptExecutionContext;
class SharedBuffer;
-class CDMFactory {
-public:
- virtual ~CDMFactory() { };
- virtual std::unique_ptr<CDMPrivate> createCDM(CDM&) = 0;
- virtual bool supportsKeySystem(const String&) = 0;
-};
-
class CDM : public RefCounted<CDM>, private ContextDestructionObserver {
public:
- WEBCORE_EXPORT static void registerCDMFactory(CDMFactory&);
- WEBCORE_EXPORT static void unregisterCDMFactory(CDMFactory&);
-
static bool supportsKeySystem(const String&);
static bool isPersistentType(MediaKeySessionType);
Modified: trunk/Source/WebCore/PlatformWPE.cmake (220263 => 220264)
--- trunk/Source/WebCore/PlatformWPE.cmake 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/PlatformWPE.cmake 2017-08-04 09:54:42 UTC (rev 220264)
@@ -150,15 +150,6 @@
platform/wpe/WidgetWPE.cpp
)
-if (ENABLE_ENCRYPTED_MEDIA)
- list(APPEND WebCore_INCLUDE_DIRECTORIES
- "${WEBCORE_DIR}/platform/encryptedmedia/clearkey"
- )
- list(APPEND WebCore_SOURCES
- platform/encryptedmedia/clearkey/CDMClearKey.cpp
- )
-endif ()
-
list(APPEND WebCore_USER_AGENT_STYLE_SHEETS
${WEBCORE_DIR}/Modules/mediacontrols/mediaControlsBase.css
)
Modified: trunk/Source/WebCore/platform/GStreamer.cmake (220263 => 220264)
--- trunk/Source/WebCore/platform/GStreamer.cmake 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/platform/GStreamer.cmake 2017-08-04 09:54:42 UTC (rev 220264)
@@ -133,8 +133,14 @@
if (ENABLE_ENCRYPTED_MEDIA)
list(APPEND WebCore_INCLUDE_DIRECTORIES
+ "${WEBCORE_DIR}/platform/encryptedmedia/clearkey"
${LIBGCRYPT_INCLUDE_DIRS}
)
+ list(APPEND WebCore_SOURCES
+ platform/encryptedmedia/clearkey/CDMClearKey.cpp
+
+ platform/graphics/gstreamer/eme/CDMFactoryGStreamer.cpp
+ )
list(APPEND WebCore_LIBRARIES
${LIBGCRYPT_LIBRARIES} -lgpg-error
)
Added: trunk/Source/WebCore/platform/encryptedmedia/CDMFactory.cpp (0 => 220264)
--- trunk/Source/WebCore/platform/encryptedmedia/CDMFactory.cpp (rev 0)
+++ trunk/Source/WebCore/platform/encryptedmedia/CDMFactory.cpp 2017-08-04 09:54:42 UTC (rev 220264)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Metrological Group B.V.
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CDMFactory.h"
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+#include <mutex>
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+Vector<CDMFactory*>& CDMFactory::registeredFactories()
+{
+ static NeverDestroyed<Vector<CDMFactory*>> factories;
+ static std::once_flag once;
+ std::call_once(once, [&] { platformRegisterFactories(factories); });
+
+ return factories;
+}
+
+void CDMFactory::registerFactory(CDMFactory& factory)
+{
+ ASSERT(!registeredFactories().contains(&factory));
+ registeredFactories().append(&factory);
+}
+
+void CDMFactory::unregisterFactory(CDMFactory& factory)
+{
+ ASSERT(registeredFactories().contains(&factory));
+ registeredFactories().removeAll(&factory);
+}
+
+#if !USE(GSTREAMER)
+void CDMFactory::platformRegisterFactories()
+{
+}
+#endif
+
+} // namespace WebCore
+
+#endif // ENABLE(ENCRYPTED_MEDIA)
Added: trunk/Source/WebCore/platform/encryptedmedia/CDMFactory.h (0 => 220264)
--- trunk/Source/WebCore/platform/encryptedmedia/CDMFactory.h (rev 0)
+++ trunk/Source/WebCore/platform/encryptedmedia/CDMFactory.h 2017-08-04 09:54:42 UTC (rev 220264)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Metrological Group B.V.
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+#include <memory>
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class CDMPrivate;
+
+class CDMFactory {
+public:
+ virtual ~CDMFactory() { };
+ virtual std::unique_ptr<CDMPrivate> createCDM() = 0;
+ virtual bool supportsKeySystem(const String&) = 0;
+
+ static Vector<CDMFactory*>& registeredFactories();
+ WEBCORE_EXPORT static void registerFactory(CDMFactory&);
+ WEBCORE_EXPORT static void unregisterFactory(CDMFactory&);
+
+ // Platform-specific function that's called when the list of
+ // registered CDMFactory objects is queried for the first time.
+ static void platformRegisterFactories(Vector<CDMFactory*>&);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(ENCRYPTED_MEDIA)
Modified: trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp (220263 => 220264)
--- trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp 2017-08-04 09:54:42 UTC (rev 220264)
@@ -31,12 +31,14 @@
#if ENABLE(ENCRYPTED_MEDIA)
+#include "SharedBuffer.h"
+
namespace WebCore {
CDMFactoryClearKey::CDMFactoryClearKey() = default;
CDMFactoryClearKey::~CDMFactoryClearKey() = default;
-std::unique_ptr<CDMPrivate> CDMFactoryClearKey::createCDM(CDM&)
+std::unique_ptr<CDMPrivate> CDMFactoryClearKey::createCDM()
{
return std::unique_ptr<CDMPrivate>(new CDMPrivateClearKey);
}
Modified: trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h (220263 => 220264)
--- trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.h 2017-08-04 09:54:42 UTC (rev 220264)
@@ -30,7 +30,7 @@
#if ENABLE(ENCRYPTED_MEDIA)
-#include "CDM.h"
+#include "CDMFactory.h"
#include "CDMInstance.h"
#include "CDMPrivate.h"
@@ -41,7 +41,7 @@
CDMFactoryClearKey();
virtual ~CDMFactoryClearKey();
- std::unique_ptr<CDMPrivate> createCDM(CDM&) override;
+ std::unique_ptr<CDMPrivate> createCDM() override;
bool supportsKeySystem(const String&) override;
};
Added: trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMFactoryGStreamer.cpp (0 => 220264)
--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMFactoryGStreamer.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMFactoryGStreamer.cpp 2017-08-04 09:54:42 UTC (rev 220264)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2016 Metrological Group B.V.
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CDMFactory.h"
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+namespace WebCore {
+
+void CDMFactory::platformRegisterFactories(Vector<CDMFactory*>& factories)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(ENCRYPTED_MEDIA)
Modified: trunk/Source/WebCore/testing/MockCDMFactory.cpp (220263 => 220264)
--- trunk/Source/WebCore/testing/MockCDMFactory.cpp 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/testing/MockCDMFactory.cpp 2017-08-04 09:54:42 UTC (rev 220264)
@@ -40,7 +40,7 @@
: m_supportedSessionTypes({ MediaKeySessionType::Temporary, MediaKeySessionType::PersistentUsageRecord, MediaKeySessionType::PersistentLicense })
, m_weakPtrFactory(this)
{
- CDM::registerCDMFactory(*this);
+ CDMFactory::registerFactory(*this);
}
MockCDMFactory::~MockCDMFactory()
@@ -51,7 +51,7 @@
void MockCDMFactory::unregister()
{
if (m_registered) {
- CDM::unregisterCDMFactory(*this);
+ CDMFactory::unregisterFactory(*this);
m_registered = false;
}
}
@@ -96,7 +96,7 @@
m_supportedDataTypes.append(type);
}
-std::unique_ptr<CDMPrivate> MockCDMFactory::createCDM(CDM&)
+std::unique_ptr<CDMPrivate> MockCDMFactory::createCDM()
{
return std::make_unique<MockCDM>(m_weakPtrFactory.createWeakPtr());
}
Modified: trunk/Source/WebCore/testing/MockCDMFactory.h (220263 => 220264)
--- trunk/Source/WebCore/testing/MockCDMFactory.h 2017-08-04 09:08:27 UTC (rev 220263)
+++ trunk/Source/WebCore/testing/MockCDMFactory.h 2017-08-04 09:54:42 UTC (rev 220264)
@@ -28,6 +28,7 @@
#if ENABLE(ENCRYPTED_MEDIA)
#include "CDM.h"
+#include "CDMFactory.h"
#include "CDMInstance.h"
#include "CDMPrivate.h"
#include "MediaKeysRequirement.h"
@@ -77,7 +78,7 @@
private:
MockCDMFactory();
- std::unique_ptr<CDMPrivate> createCDM(CDM&) final;
+ std::unique_ptr<CDMPrivate> createCDM() final;
bool supportsKeySystem(const String&) final;
MediaKeysRequirement m_distinctiveIdentifiersRequirement { MediaKeysRequirement::Optional };