<!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>[181984] 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/181984">181984</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2015-03-25 16:37:04 -0700 (Wed, 25 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add network and application cache directories to WebsiteDataStore
https://bugs.webkit.org/show_bug.cgi?id=143063

Reviewed by Sam Weinig.

Create a WebKit directory under ~/Library/Caches/&lt;Bundle ID&gt; for non-sandboxed applications,
and ~/Library/Caches for sandboxed applications. Create NetworkCache and OfflineWebApplicationCache
subdirectories. These directories will be used with the modern WebKit API.

* UIProcess/API/APIWebsiteDataStore.h:
* UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
(API::WebsiteDataStore::cacheDirectoryFileSystemRepresentation):
(API::WebsiteDataStore::defaultDataStoreConfiguration):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::WebsiteDataStore):
* UIProcess/WebsiteData/WebsiteDataStore.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIWebsiteDataStoreh">trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaAPIWebsiteDataStoreCocoamm">trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm</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="#trunkToolsMiniBrowserMiniBrowserxcodeprojprojectpbxproj">trunk/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsMiniBrowserMiniBrowserentitlements">trunk/Tools/MiniBrowser/MiniBrowser.entitlements</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (181983 => 181984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-03-25 23:33:53 UTC (rev 181983)
+++ trunk/Source/WebKit2/ChangeLog        2015-03-25 23:37:04 UTC (rev 181984)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-03-25  Anders Carlsson  &lt;andersca@apple.com&gt;
+
+        Add network and application cache directories to WebsiteDataStore
+        https://bugs.webkit.org/show_bug.cgi?id=143063
+
+        Reviewed by Sam Weinig.
+
+        Create a WebKit directory under ~/Library/Caches/&lt;Bundle ID&gt; for non-sandboxed applications,
+        and ~/Library/Caches for sandboxed applications. Create NetworkCache and OfflineWebApplicationCache
+        subdirectories. These directories will be used with the modern WebKit API.
+
+        * UIProcess/API/APIWebsiteDataStore.h:
+        * UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
+        (API::WebsiteDataStore::cacheDirectoryFileSystemRepresentation):
+        (API::WebsiteDataStore::defaultDataStoreConfiguration):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::WebsiteDataStore):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+
</ins><span class="cx"> 2015-03-25  Sam Weinig  &lt;sam@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Address additional review feedback from https://bugs.webkit.org/show_bug.cgi?id=143059.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h (181983 => 181984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h        2015-03-25 23:33:53 UTC (rev 181983)
+++ trunk/Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h        2015-03-25 23:37:04 UTC (rev 181984)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> 
</span><span class="cx">     WebKit::WebsiteDataStore&amp; websiteDataStore() { return *m_websiteDataStore; }
</span><span class="cx"> 
</span><ins>+    static String cacheDirectoryFileSystemRepresentation(const String&amp; directoryName);
</ins><span class="cx">     static String websiteDataDirectoryFileSystemRepresentation(const String&amp; directoryName);
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaAPIWebsiteDataStoreCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm (181983 => 181984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm        2015-03-25 23:33:53 UTC (rev 181983)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm        2015-03-25 23:37:04 UTC (rev 181984)
</span><span class="lines">@@ -30,6 +30,33 @@
</span><span class="cx"> 
</span><span class="cx"> namespace API {
</span><span class="cx"> 
</span><ins>+String WebsiteDataStore::cacheDirectoryFileSystemRepresentation(const String&amp; directoryName)
+{
+    static dispatch_once_t onceToken;
+    static NSURL *cacheURL;
+
+    dispatch_once(&amp;onceToken, ^{
+        NSURL *url = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nullptr create:NO error:nullptr];
+        if (!url)
+            RELEASE_ASSERT_NOT_REACHED();
+
+        if (!WebKit::processHasContainer()) {
+            NSString *bundleIdentifier = [NSBundle mainBundle].bundleIdentifier;
+            if (!bundleIdentifier)
+                bundleIdentifier = [NSProcessInfo processInfo].processName;
+            url = [url URLByAppendingPathComponent:bundleIdentifier isDirectory:YES];
+        }
+
+        cacheURL = [[url URLByAppendingPathComponent:@&quot;WebKit&quot; isDirectory:YES] retain];
+    });
+
+    NSURL *url = [cacheURL URLByAppendingPathComponent:directoryName isDirectory:YES];
+    if (![[NSFileManager defaultManager] createDirectoryAtURL:url withIntermediateDirectories:YES attributes:nil error:nullptr])
+        LOG_ERROR(&quot;Failed to create directory %@&quot;, url);
+
+    return url.absoluteURL.path.fileSystemRepresentation;
+}
+
</ins><span class="cx"> String WebsiteDataStore::websiteDataDirectoryFileSystemRepresentation(const String&amp; directoryName)
</span><span class="cx"> {
</span><span class="cx">     static dispatch_once_t onceToken;
</span><span class="lines">@@ -61,11 +88,13 @@
</span><span class="cx"> 
</span><span class="cx"> WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration()
</span><span class="cx"> {
</span><del>-    // FIXME: Fill everything in.
</del><span class="cx">     WebKit::WebsiteDataStore::Configuration configuration;
</span><span class="cx"> 
</span><ins>+    configuration.networkCacheDirectory = cacheDirectoryFileSystemRepresentation(&quot;NetworkCache&quot;);
+    configuration.applicationCacheDirectory = cacheDirectoryFileSystemRepresentation(&quot;OfflineWebApplicationCache&quot;);
+
+    configuration.webSQLDatabaseDirectory = websiteDataDirectoryFileSystemRepresentation(&quot;WebSQL&quot;);
</ins><span class="cx">     configuration.localStorageDirectory = websiteDataDirectoryFileSystemRepresentation(&quot;LocalStorage&quot;);
</span><del>-    configuration.webSQLDatabaseDirectory = websiteDataDirectoryFileSystemRepresentation(&quot;WebSQL&quot;);
</del><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 (181983 => 181984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2015-03-25 23:33:53 UTC (rev 181983)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp        2015-03-25 23:37:04 UTC (rev 181984)
</span><span class="lines">@@ -64,6 +64,8 @@
</span><span class="cx"> WebsiteDataStore::WebsiteDataStore(Configuration configuration)
</span><span class="cx">     : m_identifier(generateIdentifier())
</span><span class="cx">     , m_sessionID(WebCore::SessionID::defaultSessionID())
</span><ins>+    , m_networkCacheDirectory(WTF::move(configuration.networkCacheDirectory))
+    , m_applicationCacheDirectory(WTF::move(configuration.applicationCacheDirectory))
</ins><span class="cx">     , m_webSQLDatabaseDirectory(WTF::move(configuration.webSQLDatabaseDirectory))
</span><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></pre></div>
<a id="trunkSourceWebKit2UIProcessWebsiteDataWebsiteDataStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h (181983 => 181984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2015-03-25 23:33:53 UTC (rev 181983)
+++ trunk/Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.h        2015-03-25 23:37:04 UTC (rev 181984)
</span><span class="lines">@@ -45,6 +45,9 @@
</span><span class="cx"> class WebsiteDataStore : public RefCounted&lt;WebsiteDataStore&gt;, public WebProcessLifetimeObserver {
</span><span class="cx"> public:
</span><span class="cx">     struct Configuration {
</span><ins>+        String networkCacheDirectory;
+        String applicationCacheDirectory;
+
</ins><span class="cx">         String webSQLDatabaseDirectory;
</span><span class="cx">         String localStorageDirectory;
</span><span class="cx">     };
</span><span class="lines">@@ -83,6 +86,9 @@
</span><span class="cx">     const uint64_t m_identifier;
</span><span class="cx">     const WebCore::SessionID m_sessionID;
</span><span class="cx"> 
</span><ins>+    const String m_networkCacheDirectory;
+    const String m_applicationCacheDirectory;
+
</ins><span class="cx">     const String m_webSQLDatabaseDirectory;
</span><span class="cx">     const RefPtr&lt;StorageManager&gt; m_storageManager;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsMiniBrowserMiniBrowserentitlements"></a>
<div class="addfile"><h4>Added: trunk/Tools/MiniBrowser/MiniBrowser.entitlements (0 => 181984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/MiniBrowser.entitlements                                (rev 0)
+++ trunk/Tools/MiniBrowser/MiniBrowser.entitlements        2015-03-25 23:37:04 UTC (rev 181984)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
+&lt;plist version=&quot;1.0&quot;&gt;
+&lt;dict&gt;
+        &lt;key&gt;com.apple.security.app-sandbox&lt;/key&gt;
+        &lt;true/&gt;
+        &lt;key&gt;com.apple.security.network.client&lt;/key&gt;
+        &lt;true/&gt;
+&lt;/dict&gt;
+&lt;/plist&gt;
</ins></span></pre></div>
<a id="trunkToolsMiniBrowserMiniBrowserxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj (181983 => 181984)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj        2015-03-25 23:33:53 UTC (rev 181983)
+++ trunk/Tools/MiniBrowser/MiniBrowser.xcodeproj/project.pbxproj        2015-03-25 23:37:04 UTC (rev 181984)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx">                 0FE643A2161FAC660059E3FF /* WK1BrowserWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WK1BrowserWindowController.h; path = mac/WK1BrowserWindowController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 0FE643A3161FAC660059E3FF /* WK1BrowserWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = WK1BrowserWindowController.m; path = mac/WK1BrowserWindowController.m; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = &quot;&lt;absolute&gt;&quot;; };
</span><ins>+                1AFF1A6C1AC35D45007AB10C /* MiniBrowser.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = MiniBrowser.entitlements; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1AFFEF751860EE6700DA465E /* MiniBrowser.wkbundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MiniBrowser.wkbundle; sourceTree = BUILT_PRODUCTS_DIR; };
</span><span class="cx">                 1AFFEF761860EE6800DA465E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
</span><span class="cx">                 1AFFEF781860EE6800DA465E /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
</span><span class="lines">@@ -108,6 +109,7 @@
</span><span class="cx">                 080E96DDFE201D6D7F000001 /* MiniBrowser */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                1AFF1A6C1AC35D45007AB10C /* MiniBrowser.entitlements */,
</ins><span class="cx">                                 256AC3D80F4B6AC300CF3369 /* AppDelegate.h */,
</span><span class="cx">                                 256AC3D90F4B6AC300CF3369 /* AppDelegate.m */,
</span><span class="cx">                                 0FE6439F161FA8940059E3FF /* BrowserWindowController.h */,
</span><span class="lines">@@ -257,6 +259,15 @@
</span><span class="cx">                         isa = PBXProject;
</span><span class="cx">                         attributes = {
</span><span class="cx">                                 LastUpgradeCheck = 0600;
</span><ins>+                                TargetAttributes = {
+                                        8D1107260486CEB800E47090 = {
+                                                SystemCapabilities = {
+                                                        com.apple.Sandbox = {
+                                                                enabled = 1;
+                                                        };
+                                                };
+                                        };
+                                };
</ins><span class="cx">                         };
</span><span class="cx">                         buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject &quot;MiniBrowser&quot; */;
</span><span class="cx">                         compatibilityVersion = &quot;Xcode 3.2&quot;;
</span><span class="lines">@@ -354,6 +365,8 @@
</span><span class="cx">                         isa = XCBuildConfiguration;
</span><span class="cx">                         baseConfigurationReference = BCA8CBDF11E578A000812FB7 /* MiniBrowser.xcconfig */;
</span><span class="cx">                         buildSettings = {
</span><ins>+                                CODE_SIGN_ENTITLEMENTS = MiniBrowser.entitlements;
+                                CODE_SIGN_IDENTITY = &quot;&quot;;
</ins><span class="cx">                         };
</span><span class="cx">                         name = Debug;
</span><span class="cx">                 };
</span><span class="lines">@@ -361,6 +374,8 @@
</span><span class="cx">                         isa = XCBuildConfiguration;
</span><span class="cx">                         baseConfigurationReference = BCA8CBDF11E578A000812FB7 /* MiniBrowser.xcconfig */;
</span><span class="cx">                         buildSettings = {
</span><ins>+                                CODE_SIGN_ENTITLEMENTS = MiniBrowser.entitlements;
+                                CODE_SIGN_IDENTITY = &quot;&quot;;
</ins><span class="cx">                         };
</span><span class="cx">                         name = Release;
</span><span class="cx">                 };
</span></span></pre>
</div>
</div>

</body>
</html>