<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[184912] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/184912">184912</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2015-05-27 11:53:49 -0700 (Wed, 27 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>WKWebsiteDataStore should handle media keys
https://bugs.webkit.org/show_bug.cgi?id=145394
rdar://problem/20617794.

Reviewed by Darin Adler.

* Shared/WebsiteData/WebsiteDataTypes.h:
Add WebsiteDataTypeMediaKeys enum.

* UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
(API::WebsiteDataStore::defaultDataStoreConfiguration):
Set up mediaKeysStorageDirectory.

* UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
(dataTypesToString):
* UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
(WebKit::toWebsiteDataTypes):
(WebKit::toWKWebsiteDataTypes):
* UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h: Added.
Add _WKWebsiteDataTypeMediaKeys.

* UIProcess/WebProcessPool.cpp:
(WebKit::legacyWebsiteDataStoreConfiguration):
Set up mediaKeysStorageDirectory.

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::WebsiteDataStore):
Set m_mediaKeysStorageDirectory.

(WebKit::WebsiteDataStore::fetchData):
Make CallbackAggregator ThreadSafeRefCounted.
Handle WebsiteDataTypeMediaKeys by calling mediaKeyOrigins on our background queue.

(WebKit::WebsiteDataStore::removeData):
Make CallbackAggregator ThreadSafeRefCounted.
Handle WebsiteDataTypeMediaKeys by calling removeMediaKeys on our background queue.

(WebKit::WebsiteDataStore::mediaKeyOrigins):
Compute the origins.

(WebKit::computeMediaKeyFile):
Add helper function that returns the media key given a containing directory.

(WebKit::WebsiteDataStore::removeMediaKeys):
Remove media key files.

* UIProcess/WebsiteData/WebsiteDataStore.h:
Add new members.

* WebKit2.xcodeproj/project.pbxproj:
Add new files.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedWebsiteDataWebsiteDataTypesh">trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaAPIWebsiteDataStoreCocoamm">trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolcpp">trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh">trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/ChangeLog        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2015-05-26  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        WKWebsiteDataStore should handle media keys
+        https://bugs.webkit.org/show_bug.cgi?id=145394
+        rdar://problem/20617794.
+
+        Reviewed by Darin Adler.
+
+        * Shared/WebsiteData/WebsiteDataTypes.h:
+        Add WebsiteDataTypeMediaKeys enum.
+
+        * UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
+        (API::WebsiteDataStore::defaultDataStoreConfiguration):
+        Set up mediaKeysStorageDirectory.
+
+        * UIProcess/API/Cocoa/WKWebsiteDataRecord.mm:
+        (dataTypesToString):
+        * UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h:
+        (WebKit::toWebsiteDataTypes):
+        (WebKit::toWKWebsiteDataTypes):
+        * UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h: Added.
+        Add _WKWebsiteDataTypeMediaKeys.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::legacyWebsiteDataStoreConfiguration):
+        Set up mediaKeysStorageDirectory.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::WebsiteDataStore):
+        Set m_mediaKeysStorageDirectory.
+
+        (WebKit::WebsiteDataStore::fetchData):
+        Make CallbackAggregator ThreadSafeRefCounted.
+        Handle WebsiteDataTypeMediaKeys by calling mediaKeyOrigins on our background queue.
+
+        (WebKit::WebsiteDataStore::removeData):
+        Make CallbackAggregator ThreadSafeRefCounted.
+        Handle WebsiteDataTypeMediaKeys by calling removeMediaKeys on our background queue.
+
+        (WebKit::WebsiteDataStore::mediaKeyOrigins):
+        Compute the origins.
+
+        (WebKit::computeMediaKeyFile):
+        Add helper function that returns the media key given a containing directory.
+
+        (WebKit::WebsiteDataStore::removeMediaKeys):
+        Remove media key files.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        Add new members.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add new files.
+
</ins><span class="cx"> 2015-05-27  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.9.2 release.
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebsiteDataWebsiteDataTypesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx">     WebsiteDataTypeLocalStorage = 1 &lt;&lt; 5,
</span><span class="cx">     WebsiteDataTypeWebSQLDatabases = 1 &lt;&lt; 6,
</span><span class="cx">     WebsiteDataTypeIndexedDBDatabases = 1 &lt;&lt; 7,
</span><ins>+    WebsiteDataTypeMediaKeys = 1 &lt;&lt; 8,
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaAPIWebsiteDataStoreCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -117,6 +117,7 @@
</span><span class="cx"> 
</span><span class="cx">     configuration.webSQLDatabaseDirectory = websiteDataDirectoryFileSystemRepresentation(&quot;WebSQL&quot;);
</span><span class="cx">     configuration.localStorageDirectory = websiteDataDirectoryFileSystemRepresentation(&quot;LocalStorage&quot;);
</span><ins>+    configuration.mediaKeysStorageDirectory = websiteDataDirectoryFileSystemRepresentation(&quot;MediaKeys&quot;);
</ins><span class="cx"> 
</span><span class="cx">     return configuration;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecord.mm        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -39,6 +39,8 @@
</span><span class="cx"> NSString * const WKWebsiteDataTypeWebSQLDatabases = @&quot;WKWebsiteDataTypeWebSQLDatabases&quot;;
</span><span class="cx"> NSString * const WKWebsiteDataTypeIndexedDBDatabases = @&quot;WKWebsiteDataTypeIndexedDBDatabases&quot;;
</span><span class="cx"> 
</span><ins>+NSString * const _WKWebsiteDataTypeMediaKeys = @&quot;_WKWebsiteDataTypeMediaKeys&quot;;
+
</ins><span class="cx"> @implementation WKWebsiteDataRecord
</span><span class="cx"> 
</span><span class="cx"> - (void)dealloc
</span><span class="lines">@@ -68,6 +70,8 @@
</span><span class="cx">         [array addObject:@&quot;Web SQL&quot;];
</span><span class="cx">     if ([dataTypes containsObject:WKWebsiteDataTypeIndexedDBDatabases])
</span><span class="cx">         [array addObject:@&quot;IndexedDB&quot;];
</span><ins>+    if ([dataTypes containsObject:_WKWebsiteDataTypeMediaKeys])
+        [array addObject:@&quot;Media Keys&quot;];
</ins><span class="cx"> 
</span><span class="cx">     return [array componentsJoinedByString:@&quot;, &quot;];
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordInternal.h        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#import &quot;WKWebsiteDataRecord.h&quot;
</del><ins>+#import &quot;WKWebsiteDataRecordPrivate.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> 
</span><span class="lines">@@ -60,6 +60,8 @@
</span><span class="cx">         websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeWebSQLDatabases;
</span><span class="cx">     if ([wkWebsiteDataTypes containsObject:WKWebsiteDataTypeIndexedDBDatabases])
</span><span class="cx">         websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeIndexedDBDatabases;
</span><ins>+    if ([wkWebsiteDataTypes containsObject:_WKWebsiteDataTypeMediaKeys])
+        websiteDataTypes |= WebsiteDataTypes::WebsiteDataTypeMediaKeys;
</ins><span class="cx"> 
</span><span class="cx">     return static_cast&lt;WebsiteDataTypes&gt;(websiteDataTypes);
</span><span class="cx"> }
</span><span class="lines">@@ -86,6 +88,8 @@
</span><span class="cx">         [wkWebsiteDataTypes addObject:WKWebsiteDataTypeWebSQLDatabases];
</span><span class="cx">     if (websiteDataTypes &amp; WebsiteDataTypes::WebsiteDataTypeIndexedDBDatabases)
</span><span class="cx">         [wkWebsiteDataTypes addObject:WKWebsiteDataTypeIndexedDBDatabases];
</span><ins>+    if (websiteDataTypes &amp; WebsiteDataTypes::WebsiteDataTypeMediaKeys)
+        [wkWebsiteDataTypes addObject:_WKWebsiteDataTypeMediaKeys];
</ins><span class="cx"> 
</span><span class="cx">     return wkWebsiteDataTypes;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebsiteDataRecordPrivatehfromrev184907trunkSourceWebKit2SharedWebsiteDataWebsiteDataTypesh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h (from rev 184907, trunk/Source/WebKit2/Shared/WebsiteData/WebsiteDataTypes.h) (0 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataRecordPrivate.h        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+/*
+ * Copyright (C) 2015 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.
+ */
+
+#import &lt;WebKit/WKWebsiteDataRecord.h&gt;
+
+#if WK_API_ENABLED
+
+WK_EXTERN NSString * const _WKWebsiteDataTypeMediaKeys WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -137,6 +137,7 @@
</span><span class="cx">     configuration.localStorageDirectory = processPoolConfiguration.localStorageDirectory();
</span><span class="cx">     configuration.webSQLDatabaseDirectory = processPoolConfiguration.webSQLDatabaseDirectory();
</span><span class="cx">     configuration.applicationCacheDirectory = WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory();
</span><ins>+    configuration.mediaKeysStorageDirectory = WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory();
</ins><span class="cx"> 
</span><span class="cx">     return configuration;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &lt;WebCore/ApplicationCacheStorage.h&gt;
</span><span class="cx"> #include &lt;WebCore/DatabaseTracker.h&gt;
</span><span class="cx"> #include &lt;WebCore/OriginLock.h&gt;
</span><ins>+#include &lt;WebCore/SecurityOrigin.h&gt;
</ins><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -69,6 +70,7 @@
</span><span class="cx">     , m_networkCacheDirectory(WTF::move(configuration.networkCacheDirectory))
</span><span class="cx">     , m_applicationCacheDirectory(WTF::move(configuration.applicationCacheDirectory))
</span><span class="cx">     , m_webSQLDatabaseDirectory(WTF::move(configuration.webSQLDatabaseDirectory))
</span><ins>+    , m_mediaKeysStorageDirectory(WTF::move(configuration.mediaKeysStorageDirectory))
</ins><span class="cx">     , m_storageManager(StorageManager::create(WTF::move(configuration.localStorageDirectory)))
</span><span class="cx">     , m_queue(WorkQueue::create(&quot;com.apple.WebKit.WebsiteDataStore&quot;))
</span><span class="cx"> {
</span><span class="lines">@@ -140,7 +142,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebsiteDataStore::fetchData(WebsiteDataTypes dataTypes, std::function&lt;void (Vector&lt;WebsiteDataRecord&gt;)&gt; completionHandler)
</span><span class="cx"> {
</span><del>-    struct CallbackAggregator final : public RefCounted&lt;CallbackAggregator&gt; {
</del><ins>+    struct CallbackAggregator final : ThreadSafeRefCounted&lt;CallbackAggregator&gt; {
</ins><span class="cx">         explicit CallbackAggregator(std::function&lt;void (Vector&lt;WebsiteDataRecord&gt;)&gt; completionHandler)
</span><span class="cx">             : completionHandler(WTF::move(completionHandler))
</span><span class="cx">         {
</span><span class="lines">@@ -343,6 +345,24 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    if (dataTypes &amp; WebsiteDataTypeMediaKeys &amp;&amp; isPersistent()) {
+        StringCapture mediaKeysStorageDirectory { m_mediaKeysStorageDirectory };
+
+        callbackAggregator-&gt;addPendingCallback();
+
+        m_queue-&gt;dispatch([mediaKeysStorageDirectory, callbackAggregator] {
+            auto origins = mediaKeyOrigins(mediaKeysStorageDirectory.string());
+
+            RunLoop::main().dispatch([callbackAggregator, origins]() mutable {
+                WebsiteData websiteData;
+                for (auto&amp; origin : origins)
+                    websiteData.entries.append(WebsiteData::Entry { WTF::move(origin), WebsiteDataTypeMediaKeys });
+
+                callbackAggregator-&gt;removePendingCallback(WTF::move(websiteData));
+            });
+        });
+    }
+
</ins><span class="cx">     callbackAggregator-&gt;callIfNeeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -377,7 +397,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebsiteDataStore::removeData(WebsiteDataTypes dataTypes, std::chrono::system_clock::time_point modifiedSince, std::function&lt;void ()&gt; completionHandler)
</span><span class="cx"> {
</span><del>-    struct CallbackAggregator : public RefCounted&lt;CallbackAggregator&gt; {
</del><ins>+    struct CallbackAggregator : ThreadSafeRefCounted&lt;CallbackAggregator&gt; {
</ins><span class="cx">         explicit CallbackAggregator (std::function&lt;void ()&gt; completionHandler)
</span><span class="cx">             : completionHandler(WTF::move(completionHandler))
</span><span class="cx">         {
</span><span class="lines">@@ -516,6 +536,20 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    if (dataTypes &amp; WebsiteDataTypeMediaKeys &amp;&amp; isPersistent()) {
+        StringCapture mediaKeysStorageDirectory { m_mediaKeysStorageDirectory };
+
+        callbackAggregator-&gt;addPendingCallback();
+
+        m_queue-&gt;dispatch([mediaKeysStorageDirectory, callbackAggregator, modifiedSince] {
+            removeMediaKeys(mediaKeysStorageDirectory.string(), modifiedSince);
+
+            RunLoop::main().dispatch([callbackAggregator] {
+                callbackAggregator-&gt;removePendingCallback();
+            });
+        });
+    }
+
</ins><span class="cx">     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
</span><span class="cx">     callbackAggregator-&gt;callIfNeeded();
</span><span class="cx"> }
</span><span class="lines">@@ -529,7 +563,7 @@
</span><span class="cx">             origins.append(origin);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    struct CallbackAggregator : public ThreadSafeRefCounted&lt;CallbackAggregator&gt; {
</del><ins>+    struct CallbackAggregator : ThreadSafeRefCounted&lt;CallbackAggregator&gt; {
</ins><span class="cx">         explicit CallbackAggregator (std::function&lt;void ()&gt; completionHandler)
</span><span class="cx">             : completionHandler(WTF::move(completionHandler))
</span><span class="cx">         {
</span><span class="lines">@@ -689,6 +723,25 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    if (dataTypes &amp; WebsiteDataTypeMediaKeys &amp;&amp; isPersistent()) {
+        StringCapture mediaKeysStorageDirectory { m_mediaKeysStorageDirectory };
+        HashSet&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt; origins;
+        for (const auto&amp; dataRecord : dataRecords) {
+            for (const auto&amp; origin : dataRecord.origins)
+                origins.add(origin);
+        }
+
+        callbackAggregator-&gt;addPendingCallback();
+        m_queue-&gt;dispatch([mediaKeysStorageDirectory, callbackAggregator, origins] {
+
+            removeMediaKeys(mediaKeysStorageDirectory.string(), origins);
+
+            RunLoop::main().dispatch([callbackAggregator] {
+                callbackAggregator-&gt;removePendingCallback();
+            });
+        });
+    }
+
</ins><span class="cx">     // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
</span><span class="cx">     callbackAggregator-&gt;callIfNeeded();
</span><span class="cx"> }
</span><span class="lines">@@ -756,4 +809,60 @@
</span><span class="cx">     return processPools;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt; WebsiteDataStore::mediaKeyOrigins(const String&amp; mediaKeysStorageDirectory)
+{
+    ASSERT(!mediaKeysStorageDirectory.isEmpty());
+
+    Vector&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt; origins;
+
+    for (const auto&amp; originPath : WebCore::listDirectory(mediaKeysStorageDirectory, &quot;*&quot;)) {
+        auto mediaKeyIdentifier = WebCore::pathGetFileName(originPath);
+
+        if (auto securityOrigin = WebCore::SecurityOrigin::maybeCreateFromDatabaseIdentifier(mediaKeyIdentifier))
+            origins.append(WTF::move(securityOrigin));
+    }
+
+    return origins;
</ins><span class="cx"> }
</span><ins>+
+static String computeMediaKeyFile(const String&amp; mediaKeyDirectory)
+{
+    return WebCore::pathByAppendingComponent(mediaKeyDirectory, &quot;SecureStop.plist&quot;);
+}
+
+void WebsiteDataStore::removeMediaKeys(const String&amp; mediaKeysStorageDirectory, std::chrono::system_clock::time_point modifiedSince)
+{
+    ASSERT(!mediaKeysStorageDirectory.isEmpty());
+
+    for (const auto&amp; mediaKeyDirectory : WebCore::listDirectory(mediaKeysStorageDirectory, &quot;*&quot;)) {
+        auto mediaKeyFile = computeMediaKeyFile(mediaKeyDirectory);
+
+        if (!WebCore::fileExists(mediaKeyFile))
+            continue;
+
+        time_t modificationTime;
+        if (!WebCore::getFileModificationTime(mediaKeyFile, modificationTime))
+            continue;
+
+        if (std::chrono::system_clock::from_time_t(modificationTime) &lt; modifiedSince)
+            continue;
+
+        WebCore::deleteFile(mediaKeyFile);
+        WebCore::deleteEmptyDirectory(mediaKeyDirectory);
+    }
+}
+
+void WebsiteDataStore::removeMediaKeys(const String&amp; mediaKeysStorageDirectory, const HashSet&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt;&amp; origins)
+{
+    ASSERT(!mediaKeysStorageDirectory.isEmpty());
+
+    for (const auto&amp; origin : origins) {
+        auto mediaKeyDirectory = WebCore::pathByAppendingComponent(mediaKeysStorageDirectory, origin-&gt;databaseIdentifier());
+        auto mediaKeyFile = WebCore::pathByAppendingComponent(mediaKeyDirectory, &quot;SecureStop.plist&quot;);
+
+        WebCore::deleteFile(mediaKeyFile);
+        WebCore::deleteEmptyDirectory(mediaKeyDirectory);
+    }
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;WebProcessLifetimeObserver.h&quot;
</span><span class="cx"> #include &quot;WebsiteDataTypes.h&quot;
</span><ins>+#include &lt;WebCore/SecurityOriginHash.h&gt;
</ins><span class="cx"> #include &lt;WebCore/SessionID.h&gt;
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="lines">@@ -36,6 +37,10 @@
</span><span class="cx"> #include &lt;wtf/WorkQueue.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+class SecurityOrigin;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class StorageManager;
</span><span class="lines">@@ -51,6 +56,7 @@
</span><span class="cx"> 
</span><span class="cx">         String webSQLDatabaseDirectory;
</span><span class="cx">         String localStorageDirectory;
</span><ins>+        String mediaKeysStorageDirectory;
</ins><span class="cx">     };
</span><span class="cx">     static RefPtr&lt;WebsiteDataStore&gt; createNonPersistent();
</span><span class="cx">     static RefPtr&lt;WebsiteDataStore&gt; create(Configuration);
</span><span class="lines">@@ -86,6 +92,10 @@
</span><span class="cx"> 
</span><span class="cx">     HashSet&lt;RefPtr&lt;WebProcessPool&gt;&gt; processPools() const;
</span><span class="cx"> 
</span><ins>+    static Vector&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt; mediaKeyOrigins(const String&amp; mediaKeysStorageDirectory);
+    static void removeMediaKeys(const String&amp; mediaKeysStorageDirectory, std::chrono::system_clock::time_point modifiedSince);
+    static void removeMediaKeys(const String&amp; mediaKeysStorageDirectory, const HashSet&lt;RefPtr&lt;WebCore::SecurityOrigin&gt;&gt;&amp;);
+
</ins><span class="cx">     const uint64_t m_identifier;
</span><span class="cx">     const WebCore::SessionID m_sessionID;
</span><span class="cx"> 
</span><span class="lines">@@ -93,6 +103,7 @@
</span><span class="cx">     const String m_applicationCacheDirectory;
</span><span class="cx"> 
</span><span class="cx">     const String m_webSQLDatabaseDirectory;
</span><ins>+    const String m_mediaKeysStorageDirectory;
</ins><span class="cx">     const RefPtr&lt;StorageManager&gt; m_storageManager;
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;WorkQueue&gt; m_queue;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (184911 => 184912)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-05-27 18:39:07 UTC (rev 184911)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-05-27 18:53:49 UTC (rev 184912)
</span><span class="lines">@@ -358,6 +358,7 @@
</span><span class="cx">                 1AA576021496B97900A4EE06 /* EventDispatcherMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA575FF1496B7C000A4EE06 /* EventDispatcherMessageReceiver.cpp */; };
</span><span class="cx">                 1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA5889011EE70400061B882 /* NetscapePluginStream.h */; };
</span><span class="cx">                 1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA5889111EE70400061B882 /* NetscapePluginStream.cpp */; };
</span><ins>+                1AA654D11B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA654D01B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 1AA83F6C1A5B63FF00026EC6 /* WebDatabaseProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AA83F6A1A5B63FF00026EC6 /* WebDatabaseProvider.cpp */; };
</span><span class="cx">                 1AA83F6D1A5B63FF00026EC6 /* WebDatabaseProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA83F6B1A5B63FF00026EC6 /* WebDatabaseProvider.h */; };
</span><span class="cx">                 1AA9BAE1184FFAC7003B6BC6 /* WeakObjCPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AA9BAE0184FFAC7003B6BC6 /* WeakObjCPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2502,6 +2503,7 @@
</span><span class="cx">                 1AA576001496B7C000A4EE06 /* EventDispatcherMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventDispatcherMessages.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AA5889011EE70400061B882 /* NetscapePluginStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetscapePluginStream.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AA5889111EE70400061B882 /* NetscapePluginStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetscapePluginStream.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1AA654D01B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebsiteDataRecordPrivate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1AA83F6A1A5B63FF00026EC6 /* WebDatabaseProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebDatabaseProvider.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AA83F6B1A5B63FF00026EC6 /* WebDatabaseProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDatabaseProvider.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1AA9BAE0184FFAC7003B6BC6 /* WeakObjCPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakObjCPtr.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5448,6 +5450,7 @@
</span><span class="cx">                                 1AAF089C19267FC800B6390C /* WKUserScriptInternal.h */,
</span><span class="cx">                                 1A4832CA1A9BC465008B4DFE /* WKWebsiteDataRecord.h */,
</span><span class="cx">                                 1A4832C91A9BC465008B4DFE /* WKWebsiteDataRecord.mm */,
</span><ins>+                                1AA654D01B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h */,
</ins><span class="cx">                                 1A4832CD1A9BC484008B4DFE /* WKWebsiteDataRecordInternal.h */,
</span><span class="cx">                                 75A8D2C4187CCF9F00C39C9E /* WKWebsiteDataStore.h */,
</span><span class="cx">                                 75A8D2C5187CCF9F00C39C9E /* WKWebsiteDataStore.mm */,
</span><span class="lines">@@ -8087,6 +8090,7 @@
</span><span class="cx">                                 1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */,
</span><span class="cx">                                 1C891D6619B124FF00BA79DD /* WebInspectorUI.h in Headers */,
</span><span class="cx">                                 1CBBE4A119B66C53006B7D81 /* WebInspectorUIMessages.h in Headers */,
</span><ins>+                                1AA654D11B14F71400BF1D3E /* WKWebsiteDataRecordPrivate.h in Headers */,
</ins><span class="cx">                                 2DA944A01884E4F000ED86DB /* WebIOSEventFactory.h in Headers */,
</span><span class="cx">                                 51A9E1061315CCFC009E7031 /* WebKeyValueStorageManager.h in Headers */,
</span><span class="cx">                                 1A6280C51919949F006AD9F9 /* WebKit.h in Headers */,
</span></span></pre>
</div>
</div>

</body>
</html>