<!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>[199043] trunk/Source</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/199043">199043</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2016-04-04 22:47:32 -0700 (Mon, 04 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Modern IDB: Dump blobs to disk before storing them in an object store.
https://bugs.webkit.org/show_bug.cgi?id=156068
Source/WebCore:

Reviewed by Alex Christensen.

No new tests (Under development, no observable change in behavior yet).

* WebCore.xcodeproj/project.pbxproj:
* CMakeLists.txt:

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::putOrAddOnServer):

* Modules/indexeddb/IDBValue.cpp: Copied from Source/WebCore/platform/ScopeGuard.h.
(WebCore::IDBValue::IDBValue):
* Modules/indexeddb/IDBValue.h: Copied from Source/WebCore/platform/ScopeGuard.h.

* Modules/indexeddb/client/IDBConnectionToServer.cpp:
(WebCore::IDBClient::IDBConnectionToServer::putOrAdd):
* Modules/indexeddb/client/IDBConnectionToServer.h:

* Modules/indexeddb/client/TransactionOperation.h:

* bindings/js/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::SerializedScriptValue):
(WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB):
(WebCore::SerializedScriptValue::addBlobURL): Deleted.
* bindings/js/SerializedScriptValue.h:

* platform/FileSystem.cpp:
(WebCore::appendFileContentsToFileHandle):
* platform/FileSystem.h:

* platform/ScopeGuard.h:

* platform/network/BlobRegistry.h:
* platform/network/BlobRegistryImpl.cpp:
(WebCore::blobUtilityQueue):
(WebCore::BlobRegistryImpl::writeBlobsToTemporaryFiles):
* platform/network/BlobRegistryImpl.h:

Source/WebKit2:

Reviewed by Alex Christensen.

* NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
(WebKit::NetworkBlobRegistry::writeBlobsToTemporaryFiles):
* NetworkProcess/FileAPI/NetworkBlobRegistry.h:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:

* WebProcess/FileAPI/BlobRegistryProxy.cpp:
(WebKit::BlobRegistryProxy::writeBlobsToTemporaryFiles):
* WebProcess/FileAPI/BlobRegistryProxy.h:

* WebProcess/Network/NetworkProcessConnection.cpp:
(WebKit::NetworkProcessConnection::didClose):
(WebKit::NetworkProcessConnection::writeBlobsToTemporaryFiles):
(WebKit::NetworkProcessConnection::didWriteBlobsToTemporaryFiles):
* WebProcess/Network/NetworkProcessConnection.h:
* WebProcess/Network/NetworkProcessConnection.messages.in:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBTransactioncpp">trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServercpp">trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServerh">trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbclientTransactionOperationh">trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsSerializedScriptValuecpp">trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsSerializedScriptValueh">trunk/Source/WebCore/bindings/js/SerializedScriptValue.h</a></li>
<li><a href="#trunkSourceWebCoreplatformFileSystemcpp">trunk/Source/WebCore/platform/FileSystem.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformFileSystemh">trunk/Source/WebCore/platform/FileSystem.h</a></li>
<li><a href="#trunkSourceWebCoreplatformScopeGuardh">trunk/Source/WebCore/platform/ScopeGuard.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkBlobRegistryh">trunk/Source/WebCore/platform/network/BlobRegistry.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkBlobRegistryImplcpp">trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkBlobRegistryImplh">trunk/Source/WebCore/platform/network/BlobRegistryImpl.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessFileAPINetworkBlobRegistrycpp">trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessFileAPINetworkBlobRegistryh">trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessh">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessmessagesin">trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessFileAPIBlobRegistryProxycpp">trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessFileAPIBlobRegistryProxyh">trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectioncpp">trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectionh">trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectionmessagesin">trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.messages.in</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBValuecpp">trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBValueh">trunk/Source/WebCore/Modules/indexeddb/IDBValue.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -850,6 +850,7 @@
</span><span class="cx">     Modules/indexeddb/IDBRequest.cpp
</span><span class="cx">     Modules/indexeddb/IDBRequestCompletionEvent.cpp
</span><span class="cx">     Modules/indexeddb/IDBTransaction.cpp
</span><ins>+    Modules/indexeddb/IDBValue.cpp
</ins><span class="cx">     Modules/indexeddb/IDBVersionChangeEvent.cpp
</span><span class="cx">     Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/ChangeLog        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -1,3 +1,46 @@
</span><ins>+2016-04-04  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: Dump blobs to disk before storing them in an object store.
+        https://bugs.webkit.org/show_bug.cgi?id=156068
+        
+        Reviewed by Alex Christensen.
+
+        No new tests (Under development, no observable change in behavior yet).
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * CMakeLists.txt:
+
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::putOrAddOnServer):
+        
+        * Modules/indexeddb/IDBValue.cpp: Copied from Source/WebCore/platform/ScopeGuard.h.
+        (WebCore::IDBValue::IDBValue):
+        * Modules/indexeddb/IDBValue.h: Copied from Source/WebCore/platform/ScopeGuard.h.
+        
+        * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+        (WebCore::IDBClient::IDBConnectionToServer::putOrAdd):
+        * Modules/indexeddb/client/IDBConnectionToServer.h:
+        
+        * Modules/indexeddb/client/TransactionOperation.h:
+        
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::SerializedScriptValue::SerializedScriptValue):
+        (WebCore::SerializedScriptValue::writeBlobsToDiskForIndexedDB):
+        (WebCore::SerializedScriptValue::addBlobURL): Deleted.
+        * bindings/js/SerializedScriptValue.h:
+        
+        * platform/FileSystem.cpp:
+        (WebCore::appendFileContentsToFileHandle):
+        * platform/FileSystem.h:
+        
+        * platform/ScopeGuard.h:
+        
+        * platform/network/BlobRegistry.h:
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::blobUtilityQueue):
+        (WebCore::BlobRegistryImpl::writeBlobsToTemporaryFiles):
+        * platform/network/BlobRegistryImpl.h:
+
</ins><span class="cx"> 2016-04-04  Jer Noble  &lt;jer.noble@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Crash when playing &lt;video&gt; after playing Web Audio
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBTransactioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -867,8 +867,14 @@
</span><span class="cx">     LOG(IndexedDB, &quot;IDBTransaction::putOrAddOnServer&quot;);
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!isReadOnly());
</span><ins>+    ASSERT(value);
</ins><span class="cx"> 
</span><del>-    serverConnection().putOrAdd(operation, key, value, overwriteMode);
</del><ins>+    RefPtr&lt;IDBTransaction&gt; protector(this);
+    RefPtr&lt;IDBClient::TransactionOperation&gt; operationRef(&amp;operation);
+    value-&gt;writeBlobsToDiskForIndexedDB([protector, this, operationRef, key, value, overwriteMode](const IDBValue&amp;) {
+        // FIXME: Send the passed in IDBValue to the IDB server instead of the SerializedScriptValue.
+        serverConnection().putOrAdd(*operationRef, key.get(), *value, overwriteMode);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void IDBTransaction::didPutOrAddOnServer(IDBRequest&amp; request, const IDBResultData&amp; resultData)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBValuecppfromrev199042trunkSourceWebCoreplatformScopeGuardh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp (from rev 199042, trunk/Source/WebCore/platform/ScopeGuard.h) (0 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp                                (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBValue.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+/*
+ * Copyright (C) 2016 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 &quot;config.h&quot;
+#include &quot;IDBValue.h&quot;
+
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+IDBValue::IDBValue()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBValuehfromrev199042trunkSourceWebCoreplatformScopeGuardh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/indexeddb/IDBValue.h (from rev 199042, trunk/Source/WebCore/platform/ScopeGuard.h) (0 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBValue.h                                (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBValue.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+/*
+ * Copyright (C) 2016 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.
+ */
+
+#pragma once
+#if ENABLE(INDEXED_DATABASE)
+
+namespace WebCore {
+
+class IDBValue {
+public:
+    IDBValue();
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -171,12 +171,12 @@
</span><span class="cx">     completeOperation(resultData);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void IDBConnectionToServer::putOrAdd(TransactionOperation&amp; operation, RefPtr&lt;IDBKey&gt;&amp; key, RefPtr&lt;SerializedScriptValue&gt;&amp; value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)
</del><ins>+void IDBConnectionToServer::putOrAdd(TransactionOperation&amp; operation, IDBKey* key, SerializedScriptValue&amp; value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)
</ins><span class="cx"> {
</span><span class="cx">     LOG(IndexedDB, &quot;IDBConnectionToServer::putOrAdd&quot;);
</span><span class="cx"> 
</span><span class="cx">     saveOperation(operation);
</span><del>-    m_delegate-&gt;putOrAdd(IDBRequestData(operation), key.get(), *value, overwriteMode);
</del><ins>+    m_delegate-&gt;putOrAdd(IDBRequestData(operation), key, value, overwriteMode);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void IDBConnectionToServer::didPutOrAdd(const IDBResultData&amp; resultData)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientIDBConnectionToServerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx">     void deleteIndex(TransactionOperation&amp;, uint64_t objectStoreIdentifier, const String&amp; indexName);
</span><span class="cx">     WEBCORE_EXPORT void didDeleteIndex(const IDBResultData&amp;);
</span><span class="cx"> 
</span><del>-    void putOrAdd(TransactionOperation&amp;, RefPtr&lt;IDBKey&gt;&amp;, RefPtr&lt;SerializedScriptValue&gt;&amp;, const IndexedDB::ObjectStoreOverwriteMode);
</del><ins>+    void putOrAdd(TransactionOperation&amp;, IDBKey*, SerializedScriptValue&amp;, const IndexedDB::ObjectStoreOverwriteMode);
</ins><span class="cx">     WEBCORE_EXPORT void didPutOrAdd(const IDBResultData&amp;);
</span><span class="cx"> 
</span><span class="cx">     void getRecord(TransactionOperation&amp;, const IDBKeyRangeData&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbclientTransactionOperationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/Modules/indexeddb/client/TransactionOperation.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace IDBClient {
</span><span class="cx"> 
</span><del>-class TransactionOperation : public RefCounted&lt;TransactionOperation&gt; {
</del><ins>+class TransactionOperation : public ThreadSafeRefCounted&lt;TransactionOperation&gt; {
</ins><span class="cx"> public:
</span><span class="cx">     void perform()
</span><span class="cx">     {
</span><span class="lines">@@ -92,7 +92,6 @@
</span><span class="cx">     TransactionOperationImpl(IDBTransaction&amp; transaction, void (IDBTransaction::*completeMethod)(const IDBResultData&amp;), void (IDBTransaction::*performMethod)(TransactionOperation&amp;, Arguments...), Arguments&amp;&amp;... arguments)
</span><span class="cx">         : TransactionOperation(transaction)
</span><span class="cx">     {
</span><del>-        relaxAdoptionRequirement();
</del><span class="cx">         RefPtr&lt;TransactionOperation&gt; self(this);
</span><span class="cx"> 
</span><span class="cx">         ASSERT(performMethod);
</span><span class="lines">@@ -111,7 +110,6 @@
</span><span class="cx">     TransactionOperationImpl(IDBTransaction&amp; transaction, IDBRequest&amp; request, void (IDBTransaction::*completeMethod)(IDBRequest&amp;, const IDBResultData&amp;), void (IDBTransaction::*performMethod)(TransactionOperation&amp;, Arguments...), Arguments&amp;&amp;... arguments)
</span><span class="cx">         : TransactionOperation(transaction, request)
</span><span class="cx">     {
</span><del>-        relaxAdoptionRequirement();
</del><span class="cx">         RefPtr&lt;TransactionOperation&gt; self(this);
</span><span class="cx"> 
</span><span class="cx">         ASSERT(performMethod);
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -2045,6 +2045,8 @@
</span><span class="cx">                 5160712F1BD8307800DBC4F2 /* IDBObjectStoreInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160712D1BD8307200DBC4F2 /* IDBObjectStoreInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 516071321BD8308B00DBC4F2 /* TransactionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 5160712B1BD8305300DBC4F2 /* TransactionOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 5160F4980B0AA75F00C1D2AF /* HistoryItemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5160F4970B0AA75F00C1D2AF /* HistoryItemMac.mm */; };
</span><ins>+                516103AF1CADBA770016B4C7 /* IDBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 516103AE1CADB9A30016B4C7 /* IDBValue.h */; };
+                516103B01CADBA7A0016B4C7 /* IDBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516103AD1CADB9A30016B4C7 /* IDBValue.cpp */; };
</ins><span class="cx">                 5162C7F411F77EFB00612EFE /* SchemeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */; };
</span><span class="cx">                 5162C7F511F77EFB00612EFE /* SchemeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 516953971329A3C800B92D04 /* IconDatabaseBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 516953951329A3C800B92D04 /* IconDatabaseBase.cpp */; };
</span><span class="lines">@@ -9595,6 +9597,8 @@
</span><span class="cx">                 5160712C1BD8307200DBC4F2 /* IDBObjectStoreInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBObjectStoreInfo.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5160712D1BD8307200DBC4F2 /* IDBObjectStoreInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBObjectStoreInfo.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5160F4970B0AA75F00C1D2AF /* HistoryItemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HistoryItemMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                516103AD1CADB9A30016B4C7 /* IDBValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBValue.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                516103AE1CADB9A30016B4C7 /* IDBValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBValue.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5162C7F211F77EFA00612EFE /* SchemeRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SchemeRegistry.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5162C7F311F77EFB00612EFE /* SchemeRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SchemeRegistry.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51645B411B9F889B00F789CE /* IDBCursor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursor.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -19586,6 +19590,8 @@
</span><span class="cx">                                 51645B501B9F889B00F789CE /* IDBTransaction.cpp */,
</span><span class="cx">                                 51645B511B9F889B00F789CE /* IDBTransaction.h */,
</span><span class="cx">                                 51D719A6181106E00016DC51 /* IDBTransaction.idl */,
</span><ins>+                                516103AD1CADB9A30016B4C7 /* IDBValue.cpp */,
+                                516103AE1CADB9A30016B4C7 /* IDBValue.h */,
</ins><span class="cx">                                 51645B521B9F889B00F789CE /* IDBVersionChangeEvent.cpp */,
</span><span class="cx">                                 51645B531B9F889B00F789CE /* IDBVersionChangeEvent.h */,
</span><span class="cx">                                 51D719AD181106E00016DC51 /* IDBVersionChangeEvent.idl */,
</span><span class="lines">@@ -25992,6 +25998,7 @@
</span><span class="cx">                                 976D6C89122B8A3D001FD1F7 /* FileReader.h in Headers */,
</span><span class="cx">                                 2E75841E12779ADA0062628B /* FileReaderLoader.h in Headers */,
</span><span class="cx">                                 2E75841F12779ADA0062628B /* FileReaderLoaderClient.h in Headers */,
</span><ins>+                                516103AF1CADBA770016B4C7 /* IDBValue.h in Headers */,
</ins><span class="cx">                                 2EDF369D122C94B4002F7D4E /* FileReaderSync.h in Headers */,
</span><span class="cx">                                 2EF1BFEB121C9F4200C27627 /* FileStream.h in Headers */,
</span><span class="cx">                                 2EF1BFF9121CB0CE00C27627 /* FileStreamClient.h in Headers */,
</span><span class="lines">@@ -31786,6 +31793,7 @@
</span><span class="cx">                                 376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */,
</span><span class="cx">                                 B2C3DA4A0D006C1D00EF6F26 /* TextStream.cpp in Sources */,
</span><span class="cx">                                 9759E93F14EF1CF80026A2DD /* TextTrack.cpp in Sources */,
</span><ins>+                                516103B01CADBA7A0016B4C7 /* IDBValue.cpp in Sources */,
</ins><span class="cx">                                 9759E94214EF1CF80026A2DD /* TextTrackCue.cpp in Sources */,
</span><span class="cx">                                 071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */,
</span><span class="cx">                                 9759E94514EF1CF80026A2DD /* TextTrackCueList.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsSerializedScriptValuecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2013, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &quot;SerializedScriptValue.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Blob.h&quot;
</span><ins>+#include &quot;BlobRegistry.h&quot;
</ins><span class="cx"> #include &quot;CryptoKeyAES.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataOctetSequence.h&quot;
</span><span class="cx"> #include &quot;CryptoKeyDataRSAComponents.h&quot;
</span><span class="lines">@@ -36,6 +37,7 @@
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;File.h&quot;
</span><span class="cx"> #include &quot;FileList.h&quot;
</span><ins>+#include &quot;IDBValue.h&quot;
</ins><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="cx"> #include &quot;JSBlob.h&quot;
</span><span class="cx"> #include &quot;JSCryptoKey.h&quot;
</span><span class="lines">@@ -75,6 +77,7 @@
</span><span class="cx"> #include &lt;runtime/TypedArrayInlines.h&gt;
</span><span class="cx"> #include &lt;runtime/TypedArrays.h&gt;
</span><span class="cx"> #include &lt;wtf/HashTraits.h&gt;
</span><ins>+#include &lt;wtf/MainThread.h&gt;
</ins><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using namespace JSC;
</span><span class="lines">@@ -2582,15 +2585,6 @@
</span><span class="cx">     return std::make_pair(JSValue(), ValidationError);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SerializedScriptValue::addBlobURL(const String&amp; string)
-{
-    m_blobURLs.append(Vector&lt;uint16_t&gt;());
-    m_blobURLs.last().reserveCapacity(string.length());
-    for (size_t i = 0; i &lt; string.length(); i++)
-        m_blobURLs.last().append(string.characterAt(i));
-    m_blobURLs.last().resize(m_blobURLs.last().size());
-}
-
</del><span class="cx"> SerializedScriptValue::~SerializedScriptValue()
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -2600,19 +2594,15 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SerializedScriptValue::SerializedScriptValue(Vector&lt;uint8_t&gt;&amp;&amp; buffer, const Vector&lt;String&gt;&amp; blobURLs)
-    : m_data(WTFMove(buffer))
-{
-    for (auto&amp; string : blobURLs)
-        addBlobURL(string);
-}
-
</del><span class="cx"> SerializedScriptValue::SerializedScriptValue(Vector&lt;uint8_t&gt;&amp;&amp; buffer, const Vector&lt;String&gt;&amp; blobURLs, std::unique_ptr&lt;ArrayBufferContentsArray&gt;&amp;&amp; arrayBufferContentsArray)
</span><span class="cx">     : m_data(WTFMove(buffer))
</span><span class="cx">     , m_arrayBufferContentsArray(WTFMove(arrayBufferContentsArray))
</span><span class="cx"> {
</span><del>-    for (auto&amp; string : blobURLs)
-        addBlobURL(string);
</del><ins>+    // Since this SerializedScriptValue is meant to be passed between threads, its String data members
+    // need to be isolatedCopies so we don't run into thread safety issues for the StringImpls.
+    m_blobURLs.reserveInitialCapacity(blobURLs.size());
+    for (auto&amp; url : blobURLs)
+        m_blobURLs.append(url.isolatedCopy());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::unique_ptr&lt;SerializedScriptValue::ArrayBufferContentsArray&gt; SerializedScriptValue::transferArrayBuffers(
</span><span class="lines">@@ -2757,4 +2747,20 @@
</span><span class="cx">     return CurrentVersion;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SerializedScriptValue::writeBlobsToDiskForIndexedDB(std::function&lt;void (const IDBValue&amp;)&gt; completionHandler)
+{
+    ASSERT(isMainThread());
+
+    if (m_blobURLs.isEmpty()) {
+        completionHandler({ });
+        return;
+    }
+
+    RefPtr&lt;SerializedScriptValue&gt; protector(this);
+    blobRegistry().writeBlobsToTemporaryFiles(m_blobURLs, [completionHandler, this, protector](const Vector&lt;String&gt;&amp;) {
+        // FIXME: Return an IDBValue that contains both the SerializedScriptValue data and all blob file data.
+        completionHandler({ });
+    });
</ins><span class="cx"> }
</span><ins>+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsSerializedScriptValueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2013, 2016 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class IDBValue;
</ins><span class="cx"> class MessagePort;
</span><span class="cx"> typedef Vector&lt;RefPtr&lt;MessagePort&gt;, 1&gt; MessagePortArray;
</span><span class="cx"> typedef Vector&lt;RefPtr&lt;JSC::ArrayBuffer&gt;, 1&gt; ArrayBufferArray;
</span><span class="lines">@@ -83,7 +84,7 @@
</span><span class="cx"> 
</span><span class="cx">     const Vector&lt;uint8_t&gt;&amp; data() const { return m_data; }
</span><span class="cx">     bool hasBlobURLs() const { return !m_blobURLs.isEmpty(); }
</span><del>-    void blobURLs(Vector&lt;String&gt;&amp;) const;
</del><ins>+    void writeBlobsToDiskForIndexedDB(std::function&lt;void (const IDBValue&amp;)&gt; completionHandler);
</ins><span class="cx"> 
</span><span class="cx">     static Ref&lt;SerializedScriptValue&gt; createFromWireBytes(Vector&lt;uint8_t&gt;&amp;&amp; data)
</span><span class="cx">     {
</span><span class="lines">@@ -98,15 +99,14 @@
</span><span class="cx">     static void maybeThrowExceptionIfSerializationFailed(JSC::ExecState*, SerializationReturnCode);
</span><span class="cx">     static bool serializationDidCompleteSuccessfully(SerializationReturnCode);
</span><span class="cx">     static std::unique_ptr&lt;ArrayBufferContentsArray&gt; transferArrayBuffers(JSC::ExecState*, ArrayBufferArray&amp;, SerializationReturnCode&amp;);
</span><del>-    void addBlobURL(const String&amp;);
</del><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT SerializedScriptValue(Vector&lt;unsigned char&gt;&amp;&amp;);
</span><del>-    SerializedScriptValue(Vector&lt;unsigned char&gt;&amp;&amp;, const Vector&lt;String&gt;&amp; blobURLs);
</del><span class="cx">     SerializedScriptValue(Vector&lt;unsigned char&gt;&amp;&amp;, const Vector&lt;String&gt;&amp; blobURLs, std::unique_ptr&lt;ArrayBufferContentsArray&gt;&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;unsigned char&gt; m_data;
</span><span class="cx">     std::unique_ptr&lt;ArrayBufferContentsArray&gt; m_arrayBufferContentsArray;
</span><del>-    Vector&lt;Vector&lt;uint16_t&gt;&gt; m_blobURLs;
</del><ins>+
+    Vector&lt;String&gt; m_blobURLs;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformFileSystemcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/FileSystem.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/FileSystem.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/platform/FileSystem.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;FileSystem.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;ScopeGuard.h&quot;
</ins><span class="cx"> #include &lt;wtf/HexNumber.h&gt;
</span><span class="cx"> #include &lt;wtf/text/CString.h&gt;
</span><span class="cx"> #include &lt;wtf/text/StringBuilder.h&gt;
</span><span class="lines">@@ -129,6 +130,37 @@
</span><span class="cx">     return result.toString();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool appendFileContentsToFileHandle(const String&amp; path, PlatformFileHandle&amp; target)
+{
+    auto source = openFile(path, OpenForRead);
+
+    if (!isHandleValid(source))
+        return false;
+
+    static int bufferSize = 1 &lt;&lt; 19;
+    Vector&lt;char&gt; buffer(bufferSize);
+
+    ScopeGuard fileCloser([source]() {
+        PlatformFileHandle handle = source;
+        closeFile(handle);
+    });
+
+    do {
+        int readBytes = readFromFile(source, buffer.data(), bufferSize);
+        
+        if (readBytes &lt; 0)
+            return false;
+
+        if (writeToFile(target, buffer.data(), readBytes) != readBytes)
+            return false;
+
+        if (readBytes &lt; bufferSize)
+            return true;
+    } while (true);
+
+    ASSERT_NOT_REACHED();
+}
+
</ins><span class="cx"> #if !PLATFORM(MAC)
</span><span class="cx"> 
</span><span class="cx"> void setMetadataURL(String&amp;, const String&amp;, const String&amp;)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformFileSystemh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/FileSystem.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/FileSystem.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/platform/FileSystem.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -176,6 +176,11 @@
</span><span class="cx"> WEBCORE_EXPORT int writeToFile(PlatformFileHandle, const char* data, int length);
</span><span class="cx"> // Returns number of bytes actually written if successful, -1 otherwise.
</span><span class="cx"> int readFromFile(PlatformFileHandle, char* data, int length);
</span><ins>+
+// Appends the contents of the file found at 'path' to the open PlatformFileHandle.
+// Returns true if the write was successful, false if it was not.
+bool appendFileContentsToFileHandle(const String&amp; path, PlatformFileHandle&amp;);
+
</ins><span class="cx"> #if USE(FILE_LOCK)
</span><span class="cx"> bool lockFile(PlatformFileHandle, FileLockMode);
</span><span class="cx"> bool unlockFile(PlatformFileHandle);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScopeGuardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScopeGuard.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScopeGuard.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/platform/ScopeGuard.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -25,6 +25,8 @@
</span><span class="cx"> #ifndef ScopeGuard_h
</span><span class="cx"> #define ScopeGuard_h
</span><span class="cx"> 
</span><ins>+#include &lt;functional&gt;
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class ScopeGuard {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkBlobRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/BlobRegistry.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/BlobRegistry.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/platform/network/BlobRegistry.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #ifndef BlobRegistry_h
</span><span class="cx"> #define BlobRegistry_h
</span><span class="cx"> 
</span><ins>+#include &lt;functional&gt;
</ins><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -63,6 +64,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual unsigned long long blobSize(const URL&amp;) = 0;
</span><span class="cx"> 
</span><ins>+    virtual void writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void (const Vector&lt;String&gt;&amp; filePaths)&gt; completionHandler) = 0;
+
</ins><span class="cx">     virtual bool isBlobRegistryImpl() const { return false; }
</span><span class="cx"> 
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkBlobRegistryImplcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -41,8 +41,11 @@
</span><span class="cx"> #include &quot;ResourceHandle.h&quot;
</span><span class="cx"> #include &quot;ResourceRequest.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><ins>+#include &quot;ScopeGuard.h&quot;
</ins><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> #include &lt;wtf/StdLibExtras.h&gt;
</span><ins>+#include &lt;wtf/WorkQueue.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -228,4 +231,90 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static WorkQueue&amp; blobUtilityQueue()
+{
+    static NeverDestroyed&lt;Ref&lt;WorkQueue&gt;&gt; queue(WorkQueue::create(&quot;org.webkit.BlobUtility&quot;, WorkQueue::Type::Serial, WorkQueue::QOS::Background));
+    return queue.get();
+}
+
+struct BlobForFileWriting {
+    String blobURL;
+    Vector&lt;std::pair&lt;String, ThreadSafeDataBuffer&gt;&gt; filePathsOrDataBuffers;
+};
+
+void BlobRegistryImpl::writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void (const Vector&lt;String&gt;&amp; filePaths)&gt; completionHandler)
+{
+    Vector&lt;BlobForFileWriting&gt; blobsForWriting;
+    for (auto&amp; url : blobURLs) {
+        blobsForWriting.append({ });
+        blobsForWriting.last().blobURL = url.isolatedCopy();
+
+        auto* blobData = getBlobDataFromURL({ ParsedURLString, url });
+        if (!blobData) {
+            Vector&lt;String&gt; filePaths;
+            completionHandler(filePaths);
+        }
+
+        for (auto&amp; item : blobData-&gt;items()) {
+            switch (item.type()) {
+            case BlobDataItem::Type::Data:
+                blobsForWriting.last().filePathsOrDataBuffers.append({ { }, item.data() });
+                break;
+            case BlobDataItem::Type::File:
+                blobsForWriting.last().filePathsOrDataBuffers.append({ item.file()-&gt;path().isolatedCopy(), { } });
+
+            }
+        }
+    }
+
+    blobUtilityQueue().dispatch([blobsForWriting, completionHandler]() {
+        Vector&lt;String&gt; filePaths;
+
+        ScopeGuard completionCaller([completionHandler]() {
+            callOnMainThread([completionHandler]() {
+                Vector&lt;String&gt; filePaths;
+                completionHandler(filePaths);
+            });
+        });
+
+        for (auto&amp; blob : blobsForWriting) {
+            PlatformFileHandle file;
+            String tempFilePath = openTemporaryFile(ASCIILiteral(&quot;Blob&quot;), file);
+
+            ScopeGuard fileCloser([file, completionHandler]() {
+                PlatformFileHandle handle = file;
+                closeFile(handle);
+            });
+            
+            if (tempFilePath.isEmpty() || !isHandleValid(file)) {
+                LOG_ERROR(&quot;Failed to open temporary file for writing a Blob to IndexedDB&quot;);
+                return;
+            }
+
+            for (auto&amp; part : blob.filePathsOrDataBuffers) {
+                if (part.second.data()) {
+                    int length = part.second.data()-&gt;size();
+                    if (writeToFile(file, reinterpret_cast&lt;const char*&gt;(part.second.data()-&gt;data()), length) != length) {
+                        LOG_ERROR(&quot;Failed writing a Blob to temporary file for storage in IndexedDB&quot;);
+                        return;
+                    }
+                } else {
+                    ASSERT(!part.first.isEmpty());
+                    if (!appendFileContentsToFileHandle(part.first, file)) {
+                        LOG_ERROR(&quot;Failed copying File contents to a Blob temporary file for storage in IndexedDB&quot;);
+                        return;
+                    }
+                }
+            }
+
+            filePaths.append(tempFilePath.isolatedCopy());
+        }
+
+        completionCaller.disable();
+        callOnMainThread([completionHandler, filePaths]() {
+            completionHandler(filePaths);
+        });
+    });
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkBlobRegistryImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/BlobRegistryImpl.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/BlobRegistryImpl.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebCore/platform/network/BlobRegistryImpl.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -67,6 +67,8 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned long long blobSize(const URL&amp;) override;
</span><span class="cx"> 
</span><ins>+    void writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void (const Vector&lt;String&gt;&amp; filePaths)&gt; completionHandler) override;
+
</ins><span class="cx">     HashMap&lt;String, RefPtr&lt;BlobData&gt;&gt; m_blobs;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/ChangeLog        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-04-04  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Modern IDB: Dump blobs to disk before storing them in an object store.
+        https://bugs.webkit.org/show_bug.cgi?id=156068
+
+        Reviewed by Alex Christensen.
+
+        * NetworkProcess/FileAPI/NetworkBlobRegistry.cpp:
+        (WebKit::NetworkBlobRegistry::writeBlobsToTemporaryFiles):
+        * NetworkProcess/FileAPI/NetworkBlobRegistry.h:
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+
+        * WebProcess/FileAPI/BlobRegistryProxy.cpp:
+        (WebKit::BlobRegistryProxy::writeBlobsToTemporaryFiles):
+        * WebProcess/FileAPI/BlobRegistryProxy.h:
+
+        * WebProcess/Network/NetworkProcessConnection.cpp:
+        (WebKit::NetworkProcessConnection::didClose):
+        (WebKit::NetworkProcessConnection::writeBlobsToTemporaryFiles):
+        (WebKit::NetworkProcessConnection::didWriteBlobsToTemporaryFiles):
+        * WebProcess/Network/NetworkProcessConnection.h:
+        * WebProcess/Network/NetworkProcessConnection.messages.in:
+
</ins><span class="cx"> 2016-04-04  Chelsea Pugh  &lt;cpugh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Allow clients in the bundle to know whether a field was focused by user interaction        
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessFileAPINetworkBlobRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -117,6 +117,11 @@
</span><span class="cx">     return blobRegistry().blobSize(url);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkBlobRegistry::writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void(const Vector&lt;String&gt;&amp;)&gt; completionHandler)
+{
+    blobRegistry().writeBlobsToTemporaryFiles(blobURLs, completionHandler);
+}
+
</ins><span class="cx"> void NetworkBlobRegistry::connectionToWebProcessDidClose(NetworkConnectionToWebProcess* connection)
</span><span class="cx"> {
</span><span class="cx">     if (!m_blobsForConnection.contains(connection))
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessFileAPINetworkBlobRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/NetworkProcess/FileAPI/NetworkBlobRegistry.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define NetworkBlobRegistry_h
</span><span class="cx"> 
</span><span class="cx"> #include &lt;WebCore/URLHash.h&gt;
</span><ins>+#include &lt;functional&gt;
</ins><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -52,6 +53,7 @@
</span><span class="cx">     void registerBlobURLForSlice(NetworkConnectionToWebProcess*, const WebCore::URL&amp;, const WebCore::URL&amp; srcURL, int64_t start, int64_t end);
</span><span class="cx">     void unregisterBlobURL(NetworkConnectionToWebProcess*, const WebCore::URL&amp;);
</span><span class="cx">     uint64_t blobSize(NetworkConnectionToWebProcess*, const WebCore::URL&amp;);
</span><ins>+    void writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void(const Vector&lt;String&gt;&amp;)&gt; completionHandler);
</ins><span class="cx"> 
</span><span class="cx">     void connectionToWebProcessDidClose(NetworkConnectionToWebProcess*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -30,11 +30,13 @@
</span><span class="cx"> #include &quot;NetworkConnectionToWebProcessMessages.h&quot;
</span><span class="cx"> #include &quot;NetworkLoad.h&quot;
</span><span class="cx"> #include &quot;NetworkProcess.h&quot;
</span><ins>+#include &quot;NetworkProcessConnectionMessages.h&quot;
</ins><span class="cx"> #include &quot;NetworkResourceLoadParameters.h&quot;
</span><span class="cx"> #include &quot;NetworkResourceLoader.h&quot;
</span><span class="cx"> #include &quot;NetworkResourceLoaderMessages.h&quot;
</span><span class="cx"> #include &quot;RemoteNetworkingContext.h&quot;
</span><span class="cx"> #include &quot;SessionTracker.h&quot;
</span><ins>+#include &quot;WebCoreArgumentCoders.h&quot;
</ins><span class="cx"> #include &lt;WebCore/NotImplemented.h&gt;
</span><span class="cx"> #include &lt;WebCore/PingHandle.h&gt;
</span><span class="cx"> #include &lt;WebCore/PlatformCookieJar.h&gt;
</span><span class="lines">@@ -279,6 +281,28 @@
</span><span class="cx">     resultSize = NetworkBlobRegistry::singleton().blobSize(this, url);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, uint64_t requestIdentifier)
+{
+    RefPtr&lt;NetworkConnectionToWebProcess&gt; protector(this);
+
+    Vector&lt;RefPtr&lt;WebCore::BlobDataFileReference&gt;&gt; fileReferences;
+    for (auto&amp; url : blobURLs)
+        fileReferences.appendVector(NetworkBlobRegistry::singleton().filesInBlob(*this, { ParsedURLString, url }));
+
+    for (auto&amp; file : fileReferences)
+        file-&gt;prepareForFileAccess();
+
+    NetworkBlobRegistry::singleton().writeBlobsToTemporaryFiles(blobURLs, [this, protector, requestIdentifier, fileReferences](const Vector&lt;String&gt;&amp; fileNames) {
+        for (auto&amp; file : fileReferences)
+            file-&gt;revokeFileAccess();
+
+        if (!m_connection || !m_connection-&gt;isValid())
+            return;
+
+        m_connection-&gt;send(Messages::NetworkProcessConnection::DidWriteBlobsToTemporaryFiles(requestIdentifier, fileNames), 0);
+    });
+}
+
</ins><span class="cx"> void NetworkConnectionToWebProcess::ensureLegacyPrivateBrowsingSession()
</span><span class="cx"> {
</span><span class="cx">     NetworkProcess::singleton().ensurePrivateBrowsingSession(SessionID::legacyPrivateSessionID());
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -93,6 +93,8 @@
</span><span class="cx">     void registerBlobURLForSlice(const WebCore::URL&amp;, const WebCore::URL&amp; srcURL, int64_t start, int64_t end);
</span><span class="cx">     void blobSize(const WebCore::URL&amp;, uint64_t&amp; resultSize);
</span><span class="cx">     void unregisterBlobURL(const WebCore::URL&amp;);
</span><ins>+    void writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, uint64_t requestIdentifier);
+
</ins><span class="cx">     void ensureLegacyPrivateBrowsingSession();
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;IPC::Connection&gt; m_connection;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkConnectionToWebProcessmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -45,5 +45,7 @@
</span><span class="cx">     RegisterBlobURLForSlice(WebCore::URL url, WebCore::URL srcURL, int64_t start, int64_t end)
</span><span class="cx">     UnregisterBlobURL(WebCore::URL url)
</span><span class="cx">     BlobSize(WebCore::URL url) -&gt; (uint64_t resultSize)
</span><ins>+    WriteBlobsToTemporaryFiles(Vector&lt;String&gt; blobURLs, uint64_t requestIdentifier)
+
</ins><span class="cx">     EnsureLegacyPrivateBrowsingSession()
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessFileAPIBlobRegistryProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -75,4 +75,9 @@
</span><span class="cx">     return resultSize;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void BlobRegistryProxy::writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void (const Vector&lt;String&gt;&amp; filePaths)&gt; completionHandler)
+{
+    WebProcess::singleton().networkConnection()-&gt;writeBlobsToTemporaryFiles(blobURLs, completionHandler);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessFileAPIBlobRegistryProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/WebProcess/FileAPI/BlobRegistryProxy.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx">     void unregisterBlobURL(const WebCore::URL&amp;) override;
</span><span class="cx">     void registerBlobURLForSlice(const WebCore::URL&amp;, const WebCore::URL&amp; srcURL, long long start, long long end) override;
</span><span class="cx">     unsigned long long blobSize(const WebCore::URL&amp;) override;
</span><ins>+    void writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void (const Vector&lt;String&gt;&amp; filePaths)&gt; completionHandler) override;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.cpp        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -72,12 +72,35 @@
</span><span class="cx"> {
</span><span class="cx">     // The NetworkProcess probably crashed.
</span><span class="cx">     WebProcess::singleton().networkProcessConnectionClosed(this);
</span><ins>+
+    Vector&lt;String&gt; dummyFilenames;
+    for (auto handler : m_writeBlobToFileCompletionHandlers.values())
+        handler(dummyFilenames);
+
+    m_writeBlobToFileCompletionHandlers.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NetworkProcessConnection::didReceiveInvalidMessage(IPC::Connection&amp;, IPC::StringReference, IPC::StringReference)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void NetworkProcessConnection::writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void (const Vector&lt;String&gt;&amp; filePaths)&gt; completionHandler)
+{
+    static uint64_t writeBlobToFileIdentifier;
+    uint64_t requestIdentifier = ++writeBlobToFileIdentifier;
+
+    m_writeBlobToFileCompletionHandlers.set(requestIdentifier, completionHandler);
+
+    WebProcess::singleton().networkConnection()-&gt;connection()-&gt;send(Messages::NetworkConnectionToWebProcess::WriteBlobsToTemporaryFiles(blobURLs, requestIdentifier), 0);
+}
+
+void NetworkProcessConnection::didWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, const Vector&lt;String&gt;&amp; filenames)
+{
+    auto handler = m_writeBlobToFileCompletionHandlers.take(requestIdentifier);
+    if (handler)
+        handler(filenames);
+}
+
</ins><span class="cx"> #if ENABLE(SHAREABLE_RESOURCE)
</span><span class="cx"> void NetworkProcessConnection::didCacheResource(const ResourceRequest&amp; request, const ShareableResource::Handle&amp; handle, SessionID sessionID)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.h        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -58,6 +58,8 @@
</span><span class="cx"> 
</span><span class="cx">     void didReceiveNetworkProcessConnectionMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;);
</span><span class="cx"> 
</span><ins>+    void writeBlobsToTemporaryFiles(const Vector&lt;String&gt;&amp; blobURLs, std::function&lt;void (const Vector&lt;String&gt;&amp; filePaths)&gt; completionHandler);
+
</ins><span class="cx"> private:
</span><span class="cx">     NetworkProcessConnection(IPC::Connection::Identifier);
</span><span class="cx"> 
</span><span class="lines">@@ -69,6 +71,8 @@
</span><span class="cx">     IPC::ProcessType localProcessType() override { return IPC::ProcessType::Web; }
</span><span class="cx">     IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::Network; }
</span><span class="cx"> 
</span><ins>+    void didWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, const Vector&lt;String&gt;&amp; filenames);
+
</ins><span class="cx"> #if ENABLE(SHAREABLE_RESOURCE)
</span><span class="cx">     // Message handlers.
</span><span class="cx">     void didCacheResource(const WebCore::ResourceRequest&amp;, const ShareableResource::Handle&amp;, WebCore::SessionID);
</span><span class="lines">@@ -76,6 +80,8 @@
</span><span class="cx"> 
</span><span class="cx">     // The connection from the web process to the network process.
</span><span class="cx">     RefPtr&lt;IPC::Connection&gt; m_connection;
</span><ins>+
+    HashMap&lt;uint64_t, std::function&lt;void (const Vector&lt;String&gt;&amp;)&gt;&gt; m_writeBlobToFileCompletionHandlers;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkNetworkProcessConnectionmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.messages.in (199042 => 199043)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.messages.in        2016-04-05 05:39:18 UTC (rev 199042)
+++ trunk/Source/WebKit2/WebProcess/Network/NetworkProcessConnection.messages.in        2016-04-05 05:47:32 UTC (rev 199043)
</span><span class="lines">@@ -26,4 +26,5 @@
</span><span class="cx">     DidCacheResource(WebCore::ResourceRequest request, WebKit::ShareableResource::Handle resource, WebCore::SessionID sessionID)
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    DidWriteBlobsToTemporaryFiles(uint64_t requestIdentifier, Vector&lt;String&gt; filenames)
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>