summaryrefslogtreecommitdiff
path: root/Source/WebKit2/WebProcess/MediaCache
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/WebProcess/MediaCache
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebKit2/WebProcess/MediaCache')
-rw-r--r--Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp76
-rw-r--r--Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.h58
-rw-r--r--Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.messages.in27
-rw-r--r--Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp135
-rw-r--r--Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.h65
5 files changed, 200 insertions, 161 deletions
diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp
deleted file mode 100644
index 588b1bf99..000000000
--- a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
- *
- * 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 "WebMediaCacheManager.h"
-
-#include "WebMediaCacheManagerMessages.h"
-#include "WebMediaCacheManagerProxyMessages.h"
-#include "WebProcess.h"
-#include <WebCore/HTMLMediaElement.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-const char* WebMediaCacheManager::supplementName()
-{
- return "WebMediaCacheManager";
-}
-
-WebMediaCacheManager::WebMediaCacheManager(WebProcess* process)
- : m_process(process)
-{
- m_process->addMessageReceiver(Messages::WebMediaCacheManager::messageReceiverName(), *this);
-}
-
-void WebMediaCacheManager::getHostnamesWithMediaCache(uint64_t callbackID)
-{
- Vector<String> mediaCacheHostnames;
-
-#if ENABLE(VIDEO)
- HTMLMediaElement::getSitesInMediaCache(mediaCacheHostnames);
-#endif
-
- m_process->send(Messages::WebMediaCacheManagerProxy::DidGetHostnamesWithMediaCache(mediaCacheHostnames, callbackID), 0);
-}
-
-void WebMediaCacheManager::clearCacheForHostname(const String& hostname)
-{
-#if ENABLE(VIDEO)
- HTMLMediaElement::clearMediaCacheForSite(hostname);
-#else
- UNUSED_PARAM(hostname);
-#endif
-}
-
-void WebMediaCacheManager::clearCacheForAllHostnames()
-{
-#if ENABLE(VIDEO)
- HTMLMediaElement::clearMediaCache();
-#endif
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.h b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.h
deleted file mode 100644
index c62511b02..000000000
--- a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
- *
- * 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.
- */
-
-#ifndef WebMediaCacheManager_h
-#define WebMediaCacheManager_h
-
-#include "MessageReceiver.h"
-#include "WebProcessSupplement.h"
-#include <stdint.h>
-#include <wtf/Forward.h>
-#include <wtf/Noncopyable.h>
-
-namespace WebKit {
-
-class WebProcess;
-
-class WebMediaCacheManager : public WebProcessSupplement, public IPC::MessageReceiver {
- WTF_MAKE_NONCOPYABLE(WebMediaCacheManager);
-public:
- explicit WebMediaCacheManager(WebProcess*);
-
- static const char* supplementName();
-
-private:
- virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
-
- void getHostnamesWithMediaCache(uint64_t callbackID);
- void clearCacheForHostname(const String&);
- void clearCacheForAllHostnames();
-
- WebProcess* m_process;
-};
-
-} // namespace WebKit
-
-#endif // WebMediaCacheManager_h
diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.messages.in b/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.messages.in
deleted file mode 100644
index c0cf8f809..000000000
--- a/Source/WebKit2/WebProcess/MediaCache/WebMediaCacheManager.messages.in
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2011 Apple Inc. All rights reserved.
-#
-# 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.
-
-messages -> WebMediaCacheManager {
- void GetHostnamesWithMediaCache(uint64_t callbackID)
- void ClearCacheForHostname(String hostname)
- void ClearCacheForAllHostnames()
-}
diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp b/Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp
new file mode 100644
index 000000000..fb7f9c6ca
--- /dev/null
+++ b/Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. 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 "WebMediaKeyStorageManager.h"
+
+#include "WebProcessCreationParameters.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/SecurityOrigin.h>
+#include <WebCore/SecurityOriginData.h>
+#include <WebCore/URL.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebMediaKeyStorageManager::initialize(const WebProcessCreationParameters &parameters)
+{
+ ASSERT(!parameters.mediaKeyStorageDirectory.isEmpty());
+ m_mediaKeyStorageDirectory = parameters.mediaKeyStorageDirectory;
+}
+
+const char* WebMediaKeyStorageManager::supplementName()
+{
+ return "WebMediaKeyStorageManager";
+}
+
+String WebMediaKeyStorageManager::mediaKeyStorageDirectoryForOrigin(const SecurityOriginData& originData)
+{
+ if (!m_mediaKeyStorageDirectory)
+ return emptyString();
+
+ return pathByAppendingComponent(m_mediaKeyStorageDirectory, originData.databaseIdentifier());
+}
+
+Vector<SecurityOriginData> WebMediaKeyStorageManager::getMediaKeyOrigins()
+{
+ Vector<SecurityOriginData> results;
+
+ if (m_mediaKeyStorageDirectory.isEmpty())
+ return results;
+
+ Vector<String> originPaths = listDirectory(m_mediaKeyStorageDirectory, "*");
+ for (const auto& originPath : originPaths) {
+ URL url;
+ url.setProtocol(ASCIILiteral("file"));
+ url.setPath(originPath);
+
+ String mediaKeyIdentifier = url.lastPathComponent();
+
+ auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(mediaKeyIdentifier);
+ if (!securityOrigin)
+ continue;
+
+ results.append(*securityOrigin);
+ }
+
+ return results;
+}
+
+static void removeAllMediaKeyStorageForOriginPath(const String& originPath, double startDate, double endDate)
+{
+ Vector<String> mediaKeyPaths = listDirectory(originPath, "*");
+
+ for (const auto& mediaKeyPath : mediaKeyPaths) {
+ String mediaKeyFile = pathByAppendingComponent(mediaKeyPath, "SecureStop.plist");
+
+ if (!fileExists(mediaKeyFile))
+ continue;
+
+ time_t modTime;
+ getFileModificationTime(mediaKeyFile, modTime);
+
+ if (modTime < startDate || modTime > endDate)
+ continue;
+
+ deleteFile(mediaKeyFile);
+ deleteEmptyDirectory(mediaKeyPath);
+ }
+
+ deleteEmptyDirectory(originPath);
+}
+
+void WebMediaKeyStorageManager::deleteMediaKeyEntriesForOrigin(const SecurityOriginData& originData)
+{
+ if (m_mediaKeyStorageDirectory.isEmpty())
+ return;
+
+ String originPath = mediaKeyStorageDirectoryForOrigin(originData);
+ removeAllMediaKeyStorageForOriginPath(originPath, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
+}
+
+void WebMediaKeyStorageManager::deleteMediaKeyEntriesModifiedBetweenDates(double startDate, double endDate)
+{
+ if (m_mediaKeyStorageDirectory.isEmpty())
+ return;
+
+ Vector<String> originPaths = listDirectory(m_mediaKeyStorageDirectory, "*");
+ for (auto& originPath : originPaths)
+ removeAllMediaKeyStorageForOriginPath(originPath, startDate, endDate);
+}
+
+void WebMediaKeyStorageManager::deleteAllMediaKeyEntries()
+{
+ if (m_mediaKeyStorageDirectory.isEmpty())
+ return;
+
+ Vector<String> originPaths = listDirectory(m_mediaKeyStorageDirectory, "*");
+ for (auto& originPath : originPaths)
+ removeAllMediaKeyStorageForOriginPath(originPath, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max());
+}
+
+}
diff --git a/Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.h b/Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.h
new file mode 100644
index 000000000..ef746fee6
--- /dev/null
+++ b/Source/WebKit2/WebProcess/MediaCache/WebMediaKeyStorageManager.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * 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 COMPUTER, INC. ``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 COMPUTER, INC. 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.
+ */
+
+#ifndef WebMediaKeyStorageManager_h
+#define WebMediaKeyStorageManager_h
+
+#include "WebProcessSupplement.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+struct SecurityOriginData;
+}
+
+namespace WebKit {
+
+class WebProcess;
+
+class WebMediaKeyStorageManager : public WebProcessSupplement {
+ WTF_MAKE_NONCOPYABLE(WebMediaKeyStorageManager);
+public:
+ explicit WebMediaKeyStorageManager(WebProcess*) { }
+ virtual ~WebMediaKeyStorageManager() { }
+
+ static const char* supplementName();
+
+ const String& mediaKeyStorageDirectory() const { return m_mediaKeyStorageDirectory; }
+ String mediaKeyStorageDirectoryForOrigin(const WebCore::SecurityOriginData&);
+
+ Vector<WebCore::SecurityOriginData> getMediaKeyOrigins();
+ void deleteMediaKeyEntriesForOrigin(const WebCore::SecurityOriginData&);
+ void deleteMediaKeyEntriesModifiedBetweenDates(double startDate, double endDate);
+ void deleteAllMediaKeyEntries();
+
+private:
+ void initialize(const WebProcessCreationParameters&) override;
+
+ String m_mediaKeyStorageDirectory;
+};
+
+}
+
+#endif