<!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>[207218] trunk</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/207218">207218</a></dd>
<dt>Author</dt> <dd>pvollan@apple.com</dd>
<dt>Date</dt> <dd>2016-10-12 09:36:11 -0700 (Wed, 12 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win] Parallel DRTs are sharing preferences and cache.
https://bugs.webkit.org/show_bug.cgi?id=163013

Reviewed by Brent Fulgham.

Source/WebKit/win:

Make it possible for a WebKit client to use separate preferences and cache.

* Interfaces/IWebPreferencesPrivate.idl:
* WebApplicationCache.cpp:
(applicationCachePath):
* WebCache.cpp:
(WebCache::cacheFolder):
(WebCache::setCacheFolder):
* WebDatabaseManager.cpp:
(databasesDirectory):
* WebPreferences.cpp:
(WebPreferences::applicationId):
(WebPreferences::valueForKey):
(WebPreferences::setValueForKey):
(WebPreferences::save):
(WebPreferences::QueryInterface):
(WebPreferences::modernMediaControlsEnabled):
(WebPreferences::setApplicationId):
* WebPreferences.h:
* WebView.cpp:
(WebView::setCacheModel):

Tools:

Use separate cache and preferences for each DRT instance.

* DumpRenderTree/win/DumpRenderTree.cpp:
(applicationId):
(setApplicationId):
(setCacheFolder):
(setDefaultsToConsistentValuesForTesting):
* Scripts/webkitpy/port/win.py:
(WinPort.setup_test_run):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitwinChangeLog">trunk/Source/WebKit/win/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitwinInterfacesIWebPreferencesPrivateidl">trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl</a></li>
<li><a href="#trunkSourceWebKitwinWebApplicationCachecpp">trunk/Source/WebKit/win/WebApplicationCache.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebCachecpp">trunk/Source/WebKit/win/WebCache.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebDatabaseManagercpp">trunk/Source/WebKit/win/WebDatabaseManager.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebPreferencescpp">trunk/Source/WebKit/win/WebPreferences.cpp</a></li>
<li><a href="#trunkSourceWebKitwinWebPreferencesh">trunk/Source/WebKit/win/WebPreferences.h</a></li>
<li><a href="#trunkSourceWebKitwinWebViewcpp">trunk/Source/WebKit/win/WebView.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreewinDumpRenderTreecpp">trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp</a></li>
<li><a href="#trunkToolsScriptswebkitpyportwinpy">trunk/Tools/Scripts/webkitpy/port/win.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitwinChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/ChangeLog (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/ChangeLog        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/ChangeLog        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2016-10-12  Per Arne Vollan  &lt;pvollan@apple.com&gt;
+
+        [Win] Parallel DRTs are sharing preferences and cache.
+        https://bugs.webkit.org/show_bug.cgi?id=163013
+
+        Reviewed by Brent Fulgham.
+
+        Make it possible for a WebKit client to use separate preferences and cache.
+
+        * Interfaces/IWebPreferencesPrivate.idl:
+        * WebApplicationCache.cpp:
+        (applicationCachePath):
+        * WebCache.cpp:
+        (WebCache::cacheFolder):
+        (WebCache::setCacheFolder):
+        * WebDatabaseManager.cpp:
+        (databasesDirectory):
+        * WebPreferences.cpp:
+        (WebPreferences::applicationId):
+        (WebPreferences::valueForKey):
+        (WebPreferences::setValueForKey):
+        (WebPreferences::save):
+        (WebPreferences::QueryInterface):
+        (WebPreferences::modernMediaControlsEnabled):
+        (WebPreferences::setApplicationId):
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::setCacheModel):
+
</ins><span class="cx"> 2016-10-11  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove dead networking code
</span></span></pre></div>
<a id="trunkSourceWebKitwinInterfacesIWebPreferencesPrivateidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/Interfaces/IWebPreferencesPrivate.idl        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -187,3 +187,8 @@
</span><span class="cx">     HRESULT setModernMediaControlsEnabled([in] BOOL enabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+[uuid(F9582D72-6348-45B1-AB09-39E33459B5B9)]
+interface IWebPreferencesPrivate4 : IWebPreferencesPrivate3
+{
+    HRESULT setApplicationId([in] BSTR applicationId);
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebApplicationCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebApplicationCache.cpp (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebApplicationCache.cpp        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/WebApplicationCache.cpp        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CFDictionaryPropertyBag.h&quot;
</span><span class="cx"> #include &quot;MarshallingHelpers.h&quot;
</span><ins>+#include &quot;WebPreferences.h&quot;
</ins><span class="cx"> #include &quot;WebSecurityOrigin.h&quot;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> #include &lt;WebCore/ApplicationCache.h&gt;
</span><span class="lines">@@ -68,7 +69,7 @@
</span><span class="cx">     String path = localUserSpecificStorageDirectory();
</span><span class="cx"> 
</span><span class="cx"> #if USE(CF)
</span><del>-    auto cacheDirectoryPreference = adoptCF(CFPreferencesCopyAppValue(WebKitLocalCacheDefaultsKey, kCFPreferencesCurrentApplication));
</del><ins>+    auto cacheDirectoryPreference = adoptCF(CFPreferencesCopyAppValue(WebKitLocalCacheDefaultsKey, WebPreferences::applicationId()));
</ins><span class="cx">     if (cacheDirectoryPreference &amp;&amp; CFStringGetTypeID() == CFGetTypeID(cacheDirectoryPreference.get()))
</span><span class="cx">         path = static_cast&lt;CFStringRef&gt;(cacheDirectoryPreference.get());
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebCache.cpp (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebCache.cpp        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/WebCache.cpp        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -35,8 +35,13 @@
</span><span class="cx"> 
</span><span class="cx"> #if USE(CURL)
</span><span class="cx"> #include &lt;WebCore/CurlCacheManager.h&gt;
</span><ins>+#elif USE(CFNETWORK)
+#include &lt;CFNetwork/CFURLCachePriv.h&gt;
+#include &lt;WebKitSystemInterface/WebKitSystemInterface.h&gt;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+using namespace WebCore;
+
</ins><span class="cx"> // WebCache ---------------------------------------------------------------------------
</span><span class="cx"> 
</span><span class="cx"> WebCache::WebCache()
</span><span class="lines">@@ -243,8 +248,10 @@
</span><span class="cx">     String cacheFolder = WebCore::CurlCacheManager::getInstance().cacheDirectory();
</span><span class="cx">     *location = WebCore::BString(cacheFolder).release();
</span><span class="cx">     return S_OK;
</span><del>-#else
-    return E_NOTIMPL;
</del><ins>+#elif USE(CFNETWORK)
+    RetainPtr&lt;CFStringRef&gt; cfurlCacheDirectory = adoptCF(wkCopyFoundationCacheDirectory(0));
+    *location = BString(cfurlCacheDirectory.get()).release();
+    return S_OK;
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -254,7 +261,12 @@
</span><span class="cx">     String cacheFolder(location, SysStringLen(location));
</span><span class="cx">     WebCore::CurlCacheManager::getInstance().setCacheDirectory(cacheFolder);
</span><span class="cx">     return S_OK;
</span><del>-#else
-    return E_NOTIMPL;
</del><ins>+#elif USE(CFNETWORK)
+    RetainPtr&lt;CFURLCacheRef&gt; cache = adoptCF(CFURLCacheCopySharedURLCache());
+    CFIndex memoryCapacity = CFURLCacheMemoryCapacity(cache.get());
+    CFIndex diskCapacity = CFURLCacheDiskCapacity(cache.get());
+    RetainPtr&lt;CFURLCacheRef&gt; newCache = adoptCF(CFURLCacheCreate(kCFAllocatorDefault, memoryCapacity, diskCapacity, String(location).createCFString().get()));
+    CFURLCacheSetSharedURLCache(newCache.get());
+    return S_OK;
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebDatabaseManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebDatabaseManager.cpp (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebDatabaseManager.cpp        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/WebDatabaseManager.cpp        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;COMPropertyBag.h&quot;
</span><span class="cx"> #include &quot;MarshallingHelpers.h&quot;
</span><span class="cx"> #include &quot;WebNotificationCenter.h&quot;
</span><ins>+#include &quot;WebPreferences.h&quot;
</ins><span class="cx"> #include &quot;WebSecurityOrigin.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;WebCore/BString.h&gt;
</span><span class="lines">@@ -420,7 +421,7 @@
</span><span class="cx"> static WTF::String databasesDirectory()
</span><span class="cx"> {
</span><span class="cx"> #if USE(CF)
</span><del>-    RetainPtr&lt;CFPropertyListRef&gt; directoryPref = adoptCF(CFPreferencesCopyAppValue(WebDatabaseDirectoryDefaultsKey, kCFPreferencesCurrentApplication));
</del><ins>+    RetainPtr&lt;CFPropertyListRef&gt; directoryPref = adoptCF(CFPreferencesCopyAppValue(WebDatabaseDirectoryDefaultsKey, WebPreferences::applicationId()));
</ins><span class="cx">     if (directoryPref &amp;&amp; (CFStringGetTypeID() == CFGetTypeID(directoryPref.get())))
</span><span class="cx">         return static_cast&lt;CFStringRef&gt;(directoryPref.get());
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitwinWebPreferencescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebPreferences.cpp (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebPreferences.cpp        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/WebPreferences.cpp        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -101,6 +101,8 @@
</span><span class="cx"> 
</span><span class="cx"> static CFDictionaryRef defaultSettings;
</span><span class="cx"> 
</span><ins>+RetainPtr&lt;CFStringRef&gt; WebPreferences::m_applicationId = kCFPreferencesCurrentApplication;
+
</ins><span class="cx"> static HashMap&lt;WTF::String, COMPtr&lt;WebPreferences&gt;&gt;&amp; webPreferencesInstances()
</span><span class="cx"> {
</span><span class="cx">     static NeverDestroyed&lt;HashMap&lt;WTF::String, COMPtr&lt;WebPreferences&gt;&gt;&gt; webPreferencesInstances;
</span><span class="lines">@@ -183,6 +185,11 @@
</span><span class="cx">         webPreferencesInstances().remove(identifierString);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+CFStringRef WebPreferences::applicationId()
+{
+    return m_applicationId.get();
+}
+
</ins><span class="cx"> void WebPreferences::initializeDefaultSettings()
</span><span class="cx"> {
</span><span class="cx">     if (defaultSettings)
</span><span class="lines">@@ -306,7 +313,7 @@
</span><span class="cx">     if (value)
</span><span class="cx">         return value;
</span><span class="cx"> 
</span><del>-    value = adoptCF(CFPreferencesCopyAppValue(key, kCFPreferencesCurrentApplication));
</del><ins>+    value = adoptCF(CFPreferencesCopyAppValue(key, applicationId()));
</ins><span class="cx">     if (value)
</span><span class="cx">         return value;
</span><span class="cx"> 
</span><span class="lines">@@ -317,7 +324,7 @@
</span><span class="cx"> {
</span><span class="cx">     CFDictionarySetValue(m_privatePrefs.get(), key, value);
</span><span class="cx">     if (m_autoSaves) {
</span><del>-        CFPreferencesSetAppValue(key, value, kCFPreferencesCurrentApplication);
</del><ins>+        CFPreferencesSetAppValue(key, value, applicationId());
</ins><span class="cx">         save();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -448,7 +455,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPreferences::save()
</span><span class="cx"> {
</span><del>-    CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
</del><ins>+    CFPreferencesAppSynchronize(applicationId());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPreferences::load()
</span><span class="lines">@@ -540,6 +547,8 @@
</span><span class="cx">         *ppvObject = static_cast&lt;IWebPreferencesPrivate2*&gt;(this);
</span><span class="cx">     else if (IsEqualGUID(riid, IID_IWebPreferencesPrivate3))
</span><span class="cx">         *ppvObject = static_cast&lt;IWebPreferencesPrivate3*&gt;(this);
</span><ins>+    else if (IsEqualGUID(riid, IID_IWebPreferencesPrivate4))
+        *ppvObject = static_cast&lt;IWebPreferencesPrivate4*&gt;(this);
</ins><span class="cx">     else if (IsEqualGUID(riid, CLSID_WebPreferences))
</span><span class="cx">         *ppvObject = this;
</span><span class="cx">     else
</span><span class="lines">@@ -1993,3 +2002,9 @@
</span><span class="cx">     *enabled = boolValueForKey(WebKitModernMediaControlsEnabledPreferenceKey);
</span><span class="cx">     return S_OK;
</span><span class="cx"> }
</span><ins>+
+HRESULT WebPreferences::setApplicationId(BSTR applicationId)
+{
+    m_applicationId = String(applicationId).createCFString();
+    return S_OK;
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitwinWebPreferencesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebPreferences.h (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebPreferences.h        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/WebPreferences.h        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -23,8 +23,7 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#ifndef WebPreferences_H
-#define WebPreferences_H
</del><ins>+#pragma once
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;WebKit.h&quot;
</span><span class="cx"> #include &lt;CoreFoundation/CoreFoundation.h&gt;
</span><span class="lines">@@ -31,7 +30,7 @@
</span><span class="cx"> #include &lt;WebCore/BString.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><del>-class WebPreferences : public IWebPreferences, public IWebPreferencesPrivate3 {
</del><ins>+class WebPreferences : public IWebPreferences, public IWebPreferencesPrivate4 {
</ins><span class="cx"> public:
</span><span class="cx">     static WebPreferences* createInstance();
</span><span class="cx"> protected:
</span><span class="lines">@@ -244,6 +243,9 @@
</span><span class="cx">     virtual HRESULT STDMETHODCALLTYPE modernMediaControlsEnabled(_Out_ BOOL*);
</span><span class="cx">     virtual HRESULT STDMETHODCALLTYPE setModernMediaControlsEnabled(BOOL);
</span><span class="cx"> 
</span><ins>+    // IWebPreferencesPrivate4
+    virtual HRESULT STDMETHODCALLTYPE setApplicationId(BSTR);
+
</ins><span class="cx">     // WebPreferences
</span><span class="cx"> 
</span><span class="cx">     // This method accesses a different preference key than developerExtrasEnabled.
</span><span class="lines">@@ -257,6 +259,8 @@
</span><span class="cx">     static void removeReferenceForIdentifier(BSTR identifier);
</span><span class="cx">     static WebPreferences* sharedStandardPreferences();
</span><span class="cx"> 
</span><ins>+    static CFStringRef applicationId();
+
</ins><span class="cx">     // From WebHistory.h
</span><span class="cx">     HRESULT historyItemLimit(_Out_ int*);
</span><span class="cx">     HRESULT setHistoryItemLimit(int);
</span><span class="lines">@@ -263,8 +267,8 @@
</span><span class="cx">     HRESULT historyAgeInDaysLimit(_Out_ int*);
</span><span class="cx">     HRESULT setHistoryAgeInDaysLimit(int);
</span><span class="cx"> 
</span><del>-     void willAddToWebView();
-     void didRemoveFromWebView();
</del><ins>+    void willAddToWebView();
+    void didRemoveFromWebView();
</ins><span class="cx"> 
</span><span class="cx">     HRESULT postPreferencesChangesNotification();
</span><span class="cx"> 
</span><span class="lines">@@ -297,6 +301,5 @@
</span><span class="cx">     bool m_autoSaves { false };
</span><span class="cx">     bool m_automaticallyDetectsCacheModel { true };
</span><span class="cx">     unsigned m_numWebViews { 0 };
</span><ins>+    static RetainPtr&lt;CFStringRef&gt; m_applicationId;
</ins><span class="cx"> };
</span><del>-
-#endif
</del></span></pre></div>
<a id="trunkSourceWebKitwinWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/win/WebView.cpp (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/win/WebView.cpp        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Source/WebKit/win/WebView.cpp        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -501,7 +501,7 @@
</span><span class="cx">     RetainPtr&lt;CFURLCacheRef&gt; cfurlCache = adoptCF(CFURLCacheCopySharedURLCache());
</span><span class="cx">     RetainPtr&lt;CFStringRef&gt; cfurlCacheDirectory = adoptCF(wkCopyFoundationCacheDirectory(0));
</span><span class="cx">     if (!cfurlCacheDirectory) {
</span><del>-        RetainPtr&lt;CFPropertyListRef&gt; preference = adoptCF(CFPreferencesCopyAppValue(WebKitLocalCacheDefaultsKey, kCFPreferencesCurrentApplication));
</del><ins>+        RetainPtr&lt;CFPropertyListRef&gt; preference = adoptCF(CFPreferencesCopyAppValue(WebKitLocalCacheDefaultsKey, WebPreferences::applicationId()));
</ins><span class="cx">         if (preference &amp;&amp; (CFStringGetTypeID() == CFGetTypeID(preference.get())))
</span><span class="cx">             cfurlCacheDirectory = adoptCF(static_cast&lt;CFStringRef&gt;(preference.leakRef()));
</span><span class="cx">         else
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Tools/ChangeLog        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-10-12  Per Arne Vollan  &lt;pvollan@apple.com&gt;
+
+        [Win] Parallel DRTs are sharing preferences and cache.
+        https://bugs.webkit.org/show_bug.cgi?id=163013
+
+        Reviewed by Brent Fulgham.
+
+        Use separate cache and preferences for each DRT instance.
+
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (applicationId):
+        (setApplicationId):
+        (setCacheFolder):
+        (setDefaultsToConsistentValuesForTesting):
+        * Scripts/webkitpy/port/win.py:
+        (WinPort.setup_test_run):
+
</ins><span class="cx"> 2016-10-11  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Update API test expectation after r207162.
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreewinDumpRenderTreecpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Tools/DumpRenderTree/win/DumpRenderTree.cpp        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> #include &lt;fstream&gt;
</span><span class="cx"> #include &lt;io.h&gt;
</span><span class="cx"> #include &lt;math.h&gt;
</span><ins>+#include &lt;shlobj.h&gt;
</ins><span class="cx"> #include &lt;shlwapi.h&gt;
</span><span class="cx"> #include &lt;tchar.h&gt;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="lines">@@ -859,16 +860,52 @@
</span><span class="cx">     setAlwaysAcceptCookies(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static String applicationId()
+{
+    DWORD processId = ::GetCurrentProcessId();
+    return String::format(&quot;com.apple.DumpRenderTree.%d&quot;, processId);
+}
+
+static void setApplicationId()
+{
+    COMPtr&lt;IWebPreferences&gt; preferences;
+    if (SUCCEEDED(WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences, (void**)&amp;preferences))) {
+        COMPtr&lt;IWebPreferencesPrivate4&gt; prefsPrivate4(Query, preferences);
+        ASSERT(prefsPrivate4);
+        _bstr_t fileName = applicationId().charactersWithNullTermination().data();
+        prefsPrivate4-&gt;setApplicationId(fileName);
+    }
+}
+
+static void setCacheFolder()
+{
+    String libraryPath = libraryPathForDumpRenderTree();
+
+    COMPtr&lt;IWebCache&gt; webCache;
+    if (SUCCEEDED(WebKitCreateInstance(CLSID_WebCache, 0, IID_IWebCache, (void**)&amp;webCache))) {
+        _bstr_t cacheFolder = WebCore::pathByAppendingComponent(libraryPath, &quot;LocalCache&quot;).utf8().data();
+        webCache-&gt;setCacheFolder(cacheFolder);
+    }
+}
+
</ins><span class="cx"> // Called once on DumpRenderTree startup.
</span><span class="cx"> static void setDefaultsToConsistentValuesForTesting()
</span><span class="cx"> {
</span><span class="cx"> #if USE(CF)
</span><ins>+    // Create separate preferences for each DRT instance
+    setApplicationId();
+
+    RetainPtr&lt;CFStringRef&gt; appId = applicationId().createCFString();
+
</ins><span class="cx">     String libraryPath = libraryPathForDumpRenderTree();
</span><span class="cx"> 
</span><span class="cx">     // Set up these values before creating the WebView so that the various initializations will see these preferred values.
</span><del>-    CFPreferencesSetAppValue(WebDatabaseDirectoryDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;Databases&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
-    CFPreferencesSetAppValue(WebStorageDirectoryDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;LocalStorage&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
-    CFPreferencesSetAppValue(WebKitLocalCacheDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;LocalCache&quot;).createCFString().get(), kCFPreferencesCurrentApplication);
</del><ins>+    CFPreferencesSetAppValue(WebDatabaseDirectoryDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;Databases&quot;).createCFString().get(), appId.get());
+    CFPreferencesSetAppValue(WebStorageDirectoryDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;LocalStorage&quot;).createCFString().get(), appId.get());
+    CFPreferencesSetAppValue(WebKitLocalCacheDefaultsKey, WebCore::pathByAppendingComponent(libraryPath, &quot;LocalCache&quot;).createCFString().get(), appId.get());
+
+    // Create separate cache for each DRT instance
+    setCacheFolder();
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportwinpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/win.py (207217 => 207218)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/win.py        2016-10-12 16:32:20 UTC (rev 207217)
+++ trunk/Tools/Scripts/webkitpy/port/win.py        2016-10-12 16:36:11 UTC (rev 207218)
</span><span class="lines">@@ -28,8 +28,9 @@
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> 
</span><span class="cx"> import atexit
</span><ins>+import glob
+import logging
</ins><span class="cx"> import os
</span><del>-import logging
</del><span class="cx"> import re
</span><span class="cx"> import sys
</span><span class="cx"> import time
</span><span class="lines">@@ -346,11 +347,21 @@
</span><span class="cx">     def delete_sem_locks(self):
</span><span class="cx">         os.system(&quot;rm -rf /dev/shm/sem.*&quot;)
</span><span class="cx"> 
</span><ins>+    def delete_preference_files(self):
+        try:
+            preferences_files = self._filesystem.join(os.environ['APPDATA'], &quot;Apple Computer/Preferences&quot;, &quot;com.apple.DumpRenderTree*&quot;)
+            filelist = glob.glob(preferences_files)
+            for file in filelist:
+                self._filesystem.remove(file)
+        except:
+            _log.warn(&quot;Failed to delete preference files.&quot;)
+
</ins><span class="cx">     def setup_test_run(self, device_class=None):
</span><span class="cx">         atexit.register(self.restore_crash_log_saving)
</span><span class="cx">         self.setup_crash_log_saving()
</span><span class="cx">         self.prevent_error_dialogs()
</span><span class="cx">         self.delete_sem_locks()
</span><ins>+        self.delete_preference_files()
</ins><span class="cx">         super(WinPort, self).setup_test_run(device_class)
</span><span class="cx"> 
</span><span class="cx">     def clean_up_test_run(self):
</span></span></pre>
</div>
</div>

</body>
</html>