<!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>[162569] 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/162569">162569</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2014-01-22 16:30:14 -0800 (Wed, 22 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Source/WebCore: The IDB backing store get() method shouldn't call IDB callbacks directly
https://bugs.webkit.org/show_bug.cgi?id=127453

Reviewed by Beth Dakin.

* Modules/indexeddb/IDBServerConnection.h:
(WebCore::IDBGetResult::IDBGetResult): Add a new structure to hold all of the
  possible results of a get() call.

* Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
(WebCore::IDBServerConnectionLevelDB::get): Don't call IDBCallbacks directly.
  Instead, return the GetResult to the GetOperation which will make IDBCallbacks.
* Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h:

* Modules/indexeddb/IDBTransactionBackendOperations.cpp:
(WebCore::GetOperation::perform): Get all of the IDBGetResults in the completion callback
  make the appropriate IDBCallback.
* Modules/indexeddb/IDBTransactionBackendOperations.h:

Source/WebKit2: The IDB backing store get() method shouldn't call IDB callbacks directly
https://bugs.webkit.org/show_bug.cgi?id=127453

Reviewed by Beth Dakin.

* WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp:
(WebKit::WebIDBServerConnection::get):
* WebProcess/Databases/IndexedDB/WebIDBServerConnection.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBServerConnectionh">trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBTransactionBackendOperationscpp">trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbIDBTransactionBackendOperationsh">trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.h</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbleveldbIDBServerConnectionLevelDBcpp">trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesindexeddbleveldbIDBServerConnectionLevelDBh">trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBServerConnectioncpp">trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBServerConnectionh">trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebCore/ChangeLog        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-01-22  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        The IDB backing store get() method shouldn't call IDB callbacks directly
+        https://bugs.webkit.org/show_bug.cgi?id=127453
+
+        Reviewed by Beth Dakin.
+
+        * Modules/indexeddb/IDBServerConnection.h:
+        (WebCore::IDBGetResult::IDBGetResult): Add a new structure to hold all of the
+          possible results of a get() call.
+
+        * Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp:
+        (WebCore::IDBServerConnectionLevelDB::get): Don't call IDBCallbacks directly.
+          Instead, return the GetResult to the GetOperation which will make IDBCallbacks.
+        * Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h:
+
+        * Modules/indexeddb/IDBTransactionBackendOperations.cpp:
+        (WebCore::GetOperation::perform): Get all of the IDBGetResults in the completion callback
+          make the appropriate IDBCallback.
+        * Modules/indexeddb/IDBTransactionBackendOperations.h:
+
</ins><span class="cx"> 2014-01-22  Dean Jackson  &lt;dino@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed attempt to fix 32-bit builds.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBServerConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBServerConnection.h        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -46,6 +46,33 @@
</span><span class="cx"> struct IDBIndexMetadata;
</span><span class="cx"> struct IDBObjectStoreMetadata;
</span><span class="cx"> 
</span><ins>+struct IDBGetResult {
+    IDBGetResult()
+    {
+    }
+
+    IDBGetResult(PassRefPtr&lt;SharedBuffer&gt; buffer)
+        : valueBuffer(buffer)
+    {
+    }
+
+    IDBGetResult(PassRefPtr&lt;IDBKey&gt; idbKey)
+        : key(idbKey)
+    {
+    }
+
+    IDBGetResult(PassRefPtr&lt;SharedBuffer&gt; buffer, PassRefPtr&lt;IDBKey&gt; idbKey, const IDBKeyPath&amp; path)
+        : valueBuffer(buffer)
+        , key(idbKey)
+        , keyPath(path)
+    {
+    }
+
+    RefPtr&lt;SharedBuffer&gt; valueBuffer;
+    RefPtr&lt;IDBKey&gt; key;
+    IDBKeyPath keyPath;
+};
+
</ins><span class="cx"> // This interface provides a single asynchronous layer between the web-facing frontend
</span><span class="cx"> // and the I/O performing backend of IndexedDatabase.
</span><span class="cx"> // If an operation's completion needs to be confirmed that must be done through use of a callback function.
</span><span class="lines">@@ -77,7 +104,7 @@
</span><span class="cx">     virtual void createObjectStore(IDBTransactionBackend&amp;, const CreateObjectStoreOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</span><span class="cx">     virtual void createIndex(IDBTransactionBackend&amp;, const CreateIndexOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</span><span class="cx">     virtual void deleteIndex(IDBTransactionBackend&amp;, const DeleteIndexOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</span><del>-    virtual void get(IDBTransactionBackend&amp;, const GetOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</del><ins>+    virtual void get(IDBTransactionBackend&amp;, const GetOperation&amp;, std::function&lt;void(const IDBGetResult&amp;, PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</ins><span class="cx">     virtual void put(IDBTransactionBackend&amp;, const PutOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBKey&gt;, PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</span><span class="cx">     virtual void openCursor(IDBTransactionBackend&amp;, const OpenCursorOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</span><span class="cx">     virtual void count(IDBTransactionBackend&amp;, const CountOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBTransactionBackendOperationscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.cpp        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -94,7 +94,27 @@
</span><span class="cx">     RefPtr&lt;GetOperation&gt; operation(this);
</span><span class="cx">     STANDARD_DATABASE_ERROR_CALLBACK;
</span><span class="cx"> 
</span><del>-    m_transaction-&gt;database().serverConnection().get(*m_transaction, *this, operationCallback);
</del><ins>+    m_transaction-&gt;database().serverConnection().get(*m_transaction, *this, [this, operation, operationCallback](const IDBGetResult&amp; result, PassRefPtr&lt;IDBDatabaseError&gt; prpError) {
+        RefPtr&lt;IDBDatabaseError&gt; error = prpError;
+
+        if (error)
+            m_callbacks-&gt;onError(error);
+        else {
+            if (!result.valueBuffer) {
+                if (!result.key)
+                    m_callbacks-&gt;onSuccess();
+                else
+                    m_callbacks-&gt;onSuccess(result.key.get());
+            } else {
+                if (result.key)
+                    m_callbacks-&gt;onSuccess(result.valueBuffer, result.key, result.keyPath);
+                else
+                    m_callbacks-&gt;onSuccess(result.valueBuffer.get());
+            }
+        }
+
+        operationCallback(error.release());
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PutOperation::perform(std::function&lt;void()&gt; completionCallback)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbIDBTransactionBackendOperationsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.h (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.h        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransactionBackendOperations.h        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -263,7 +263,6 @@
</span><span class="cx">     int64_t indexID() const { return m_indexID; }
</span><span class="cx">     IndexedDB::CursorType cursorType() const { return m_cursorType; }
</span><span class="cx">     IDBKeyRange* keyRange() const { return m_keyRange.get(); }
</span><del>-    RefPtr&lt;IDBCallbacks&gt; callbacks() const { return m_callbacks.get(); }
</del><span class="cx">     bool autoIncrement() const { return m_autoIncrement; }
</span><span class="cx">     IDBKeyPath keyPath() const { return m_keyPath; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbleveldbIDBServerConnectionLevelDBcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.cpp        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -244,7 +244,7 @@
</span><span class="cx">     ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void IDBServerConnectionLevelDB::get(IDBTransactionBackend&amp; transaction, const GetOperation&amp; operation, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback)
</del><ins>+void IDBServerConnectionLevelDB::get(IDBTransactionBackend&amp; transaction, const GetOperation&amp; operation, std::function&lt;void(const IDBGetResult&amp;, PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback)
</ins><span class="cx"> {
</span><span class="cx">     IDBBackingStoreTransactionLevelDB* backingStoreTransaction = m_backingStoreTransactions.get(transaction.id());
</span><span class="cx">     ASSERT(backingStoreTransaction);
</span><span class="lines">@@ -272,8 +272,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (!backingStoreCursor) {
</span><del>-            operation.callbacks()-&gt;onSuccess();
-            ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+            ASYNC_COMPLETION_CALLBACK_WITH_TWO_ARGS(completionCallback, IDBGetResult(), nullptr);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -287,45 +286,44 @@
</span><span class="cx">         Vector&lt;char&gt; value;
</span><span class="cx">         ok = m_backingStore-&gt;getRecord(*backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), *key, value);
</span><span class="cx">         if (!ok) {
</span><del>-            operation.callbacks()-&gt;onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, &quot;Internal error in getRecord.&quot;));
-            ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+            ASYNC_COMPLETION_CALLBACK_WITH_TWO_ARGS(completionCallback, IDBGetResult(), IDBDatabaseError::create(IDBDatabaseException::UnknownError, &quot;Internal error in getRecord.&quot;));
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if (value.isEmpty()) {
</span><del>-            operation.callbacks()-&gt;onSuccess();
-            ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+            ASYNC_COMPLETION_CALLBACK_WITH_TWO_ARGS(completionCallback, IDBGetResult(), nullptr);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (operation.autoIncrement() &amp;&amp; !operation.keyPath().isNull()) {
-            operation.callbacks()-&gt;onSuccess(SharedBuffer::adoptVector(value), key, operation.keyPath());
-            ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
-            return;
-        }
</del><ins>+        IDBGetResult result;
</ins><span class="cx"> 
</span><del>-        operation.callbacks()-&gt;onSuccess(SharedBuffer::adoptVector(value));
-        ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+        if (operation.autoIncrement() &amp;&amp; !operation.keyPath().isNull())
+            result = IDBGetResult(SharedBuffer::adoptVector(value), key, operation.keyPath());
+        else
+            result = IDBGetResult(SharedBuffer::adoptVector(value));
+
+        callOnMainThread([completionCallback, result]() {
+            completionCallback(result, nullptr);
+        });
</ins><span class="cx">         return;
</span><del>-
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // From here we are dealing only with indexes.
</span><span class="cx">     ok = m_backingStore-&gt;getPrimaryKeyViaIndex(*backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), operation.indexID(), *key, primaryKey);
</span><span class="cx">     if (!ok) {
</span><del>-        operation.callbacks()-&gt;onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, &quot;Internal error in getPrimaryKeyViaIndex.&quot;));
-        ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+        ASYNC_COMPLETION_CALLBACK_WITH_TWO_ARGS(completionCallback, IDBGetResult(), IDBDatabaseError::create(IDBDatabaseException::UnknownError, &quot;Internal error in getPrimaryKeyViaIndex.&quot;));
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (!primaryKey) {
</span><del>-        operation.callbacks()-&gt;onSuccess();
-        ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+        ASYNC_COMPLETION_CALLBACK_WITH_TWO_ARGS(completionCallback, IDBGetResult(), nullptr);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (operation.cursorType() == IndexedDB::CursorType::KeyOnly) {
</span><span class="cx">         // Index Value Retrieval Operation
</span><del>-        operation.callbacks()-&gt;onSuccess(primaryKey.get());
-        ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+        IDBGetResult result(primaryKey.release());
+        callOnMainThread([completionCallback, result]() {
+            completionCallback(result, nullptr);
+        });
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -333,23 +331,27 @@
</span><span class="cx">     Vector&lt;char&gt; value;
</span><span class="cx">     ok = m_backingStore-&gt;getRecord(*backingStoreTransaction, transaction.database().id(), operation.objectStoreID(), *primaryKey, value);
</span><span class="cx">     if (!ok) {
</span><del>-        operation.callbacks()-&gt;onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, &quot;Internal error in getRecord.&quot;));
-        ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+        ASYNC_COMPLETION_CALLBACK_WITH_TWO_ARGS(completionCallback, IDBGetResult(), IDBDatabaseError::create(IDBDatabaseException::UnknownError, &quot;Internal error in getRecord.&quot;));
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (value.isEmpty()) {
</span><del>-        operation.callbacks()-&gt;onSuccess();
-        ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+        ASYNC_COMPLETION_CALLBACK_WITH_TWO_ARGS(completionCallback, IDBGetResult(), nullptr);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (operation.autoIncrement() &amp;&amp; !operation.keyPath().isNull()) {
</span><del>-        operation.callbacks()-&gt;onSuccess(SharedBuffer::adoptVector(value), primaryKey, operation.keyPath());
-        ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+        IDBGetResult result(SharedBuffer::adoptVector(value), key, operation.keyPath());
+        callOnMainThread([completionCallback, result]() {
+            completionCallback(result, nullptr);
+        });
+
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    operation.callbacks()-&gt;onSuccess(SharedBuffer::adoptVector(value));
-    ASYNC_COMPLETION_CALLBACK_WITH_NULL_ARG(completionCallback);
</del><ins>+
+    IDBGetResult result(SharedBuffer::adoptVector(value));
+    callOnMainThread([completionCallback, result]() {
+        completionCallback(result, nullptr);
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void IDBServerConnectionLevelDB::put(IDBTransactionBackend&amp; transaction, const PutOperation&amp; operation, std::function&lt;void(PassRefPtr&lt;IDBKey&gt;, PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesindexeddbleveldbIDBServerConnectionLevelDBh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBServerConnectionLevelDB.h        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx">     virtual void createObjectStore(IDBTransactionBackend&amp;, const CreateObjectStoreOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><span class="cx">     virtual void createIndex(IDBTransactionBackend&amp;, const CreateIndexOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><span class="cx">     virtual void deleteIndex(IDBTransactionBackend&amp;, const DeleteIndexOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><del>-    virtual void get(IDBTransactionBackend&amp;, const GetOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) override;
</del><ins>+    virtual void get(IDBTransactionBackend&amp;, const GetOperation&amp;, std::function&lt;void(const IDBGetResult&amp;, PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) override;
</ins><span class="cx">     virtual void put(IDBTransactionBackend&amp;, const PutOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBKey&gt;, PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback)  override;
</span><span class="cx">     virtual void openCursor(IDBTransactionBackend&amp;, const OpenCursorOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><span class="cx">     virtual void count(IDBTransactionBackend&amp;, const CountOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebKit2/ChangeLog        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2014-01-22  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        The IDB backing store get() method shouldn't call IDB callbacks directly
+        https://bugs.webkit.org/show_bug.cgi?id=127453
+        
+        Reviewed by Beth Dakin.
+
+        * WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp:
+        (WebKit::WebIDBServerConnection::get):
+        * WebProcess/Databases/IndexedDB/WebIDBServerConnection.h:
+
</ins><span class="cx"> 2014-01-22  Martin Hock  &lt;mhock@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Enable Session API.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBServerConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.cpp        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -297,7 +297,7 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebIDBServerConnection::get(IDBTransactionBackend&amp;, const GetOperation&amp;, std::function&lt;void(PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback)
</del><ins>+void WebIDBServerConnection::get(IDBTransactionBackend&amp;, const GetOperation&amp;, std::function&lt;void(const IDBGetResult&amp;, PassRefPtr&lt;IDBDatabaseError&gt;)&gt; completionCallback)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessDatabasesIndexedDBWebIDBServerConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.h (162568 => 162569)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.h        2014-01-23 00:28:20 UTC (rev 162568)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBServerConnection.h        2014-01-23 00:30:14 UTC (rev 162569)
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx">     virtual void createObjectStore(WebCore::IDBTransactionBackend&amp;, const WebCore::CreateObjectStoreOperation&amp;, std::function&lt;void(PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><span class="cx">     virtual void createIndex(WebCore::IDBTransactionBackend&amp;, const WebCore::CreateIndexOperation&amp;, std::function&lt;void(PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><span class="cx">     virtual void deleteIndex(WebCore::IDBTransactionBackend&amp;, const WebCore::DeleteIndexOperation&amp;, std::function&lt;void(PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><del>-    virtual void get(WebCore::IDBTransactionBackend&amp;, const WebCore::GetOperation&amp;, std::function&lt;void(PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</del><ins>+    virtual void get(WebCore::IDBTransactionBackend&amp;, const WebCore::GetOperation&amp;, std::function&lt;void(const WebCore::IDBGetResult&amp;, PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</ins><span class="cx">     virtual void put(WebCore::IDBTransactionBackend&amp;, const WebCore::PutOperation&amp;, std::function&lt;void(PassRefPtr&lt;WebCore::IDBKey&gt;, PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><span class="cx">     virtual void openCursor(WebCore::IDBTransactionBackend&amp;, const WebCore::OpenCursorOperation&amp;, std::function&lt;void(PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</span><span class="cx">     virtual void count(WebCore::IDBTransactionBackend&amp;, const WebCore::CountOperation&amp;, std::function&lt;void(PassRefPtr&lt;WebCore::IDBDatabaseError&gt;)&gt; completionCallback) override;
</span></span></pre>
</div>
</div>

</body>
</html>