<!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>[45594] trunk</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>2009-07-07  Ben Murdoch  &lt;benm@google.com&gt;

        Reviewed by Antti Koivisto.

        HTML5 Database becomes locked if a transaction is in progress when the page is refreshed.
        https://bugs.webkit.org/show_bug.cgi?id=25711

        Tests fix for https://bugs.webkit.org/show_bug.cgi?id=25711, where
        web storage databases could become locked until the browser is
        shut down if the page is refreshed whilst a transaction is in
        progress.

        * storage/database-lock-after-reload-expected.txt: Added.
        * storage/database-lock-after-reload.html: Added.
        * storage/resources/database-lock-after-reload-2.html: Added.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=25711 where web
        storage databases could become locked until the browser is shut
        down if the page is refreshed whilst a transaction is in progress.

        Test: storage/database-lock-after-reload.html

        * storage/Database.cpp:
        (WebCore::Database::Database):
        (WebCore::Database::close): add code to inform the database thread we've closed the database.
        (WebCore::Database::performOpenAndVerify): add code to inform the database thread we've opened a database.
        * storage/Database.h:
        (WebCore::Database::opened): return true iff the underlying sqlite database has been opened but not closed.
        * storage/DatabaseThread.cpp:
        (WebCore::DatabaseThread::databaseThread): Before the database thread terminates, close any databases that ran transactions in this thread.
        (WebCore::DatabaseThread::recordDatabaseOpen): Records a database that executed a transaction in this thread.
        (WebCore::DatabaseThread::recordDatabaseClosed): Removes a database from the set of open databases.
        * storage/DatabaseThread.h:
        (WebCore::DatabaseThread::getThreadID): return the thread id for the database thread.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCorestorageDatabasecpp">trunk/WebCore/storage/Database.cpp</a></li>
<li><a href="#trunkWebCorestorageDatabaseh">trunk/WebCore/storage/Database.h</a></li>
<li><a href="#trunkWebCorestorageDatabaseThreadcpp">trunk/WebCore/storage/DatabaseThread.cpp</a></li>
<li><a href="#trunkWebCorestorageDatabaseThreadh">trunk/WebCore/storage/DatabaseThread.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsstoragedatabaselockafterreloadexpectedtxt">trunk/LayoutTests/storage/database-lock-after-reload-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstoragedatabaselockafterreloadhtml">trunk/LayoutTests/storage/database-lock-after-reload.html</a></li>
<li><a href="#trunkLayoutTestsstorageresourcesdatabaselockafterreload2html">trunk/LayoutTests/storage/resources/database-lock-after-reload-2.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (45593 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2009-07-07 14:04:02 UTC (rev 45593)
+++ trunk/LayoutTests/ChangeLog        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2009-07-07  Ben Murdoch  &lt;benm@google.com&gt;
+
+        Reviewed by Antti Koivisto.
+
+        HTML5 Database becomes locked if a transaction is in progress when the page is refreshed.
+        https://bugs.webkit.org/show_bug.cgi?id=25711
+
+        Tests fix for https://bugs.webkit.org/show_bug.cgi?id=25711, where
+        web storage databases could become locked until the browser is
+        shut down if the page is refreshed whilst a transaction is in
+        progress.
+
+        * storage/database-lock-after-reload-expected.txt: Added.
+        * storage/database-lock-after-reload.html: Added.
+        * storage/resources/database-lock-after-reload-2.html: Added.
+
</ins><span class="cx"> 2009-07-07  Simon Hausmann  &lt;hausmann@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Holger Freyther.
</span></span></pre></div>
<a id="trunkLayoutTestsstoragedatabaselockafterreloadexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/database-lock-after-reload-expected.txt (0 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/database-lock-after-reload-expected.txt                                (rev 0)
+++ trunk/LayoutTests/storage/database-lock-after-reload-expected.txt        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+Inserting some data
+Test part 2 Complete
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstoragedatabaselockafterreloadhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/database-lock-after-reload.html (0 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/database-lock-after-reload.html                                (rev 0)
+++ trunk/LayoutTests/storage/database-lock-after-reload.html        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+var database;
+
+function log(message)
+{
+    document.getElementById(&quot;console&quot;).innerHTML += message + &quot;&lt;br&gt;&quot;;
+}
+
+function finishTest()
+{
+    log(&quot;Test part 1 Complete&quot;);
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function errorFunction(tx, error)
+{
+    log(&quot;Test failed - &quot; + error.message);
+    finishTest();
+}
+
+function addData(db)
+{
+    db.transaction(function(tx) { 
+        log(&quot;Inserting some data&quot;);
+        // Insert a large amount of data that will take a little while to run. Schedule a timout to run that will load a new page
+        // whilst the transaction is still in progress, interrupting the transaction. This should not leave the database locked and on
+        // the next page we should be able to insert some more data.
+        tx.executeSql(&quot;INSERT INTO DataTest (testData) VALUES (randomBlob(524200 ))&quot;, [], function(tx, result) { }, errorFunction);
+        location.href = &quot;./resources/database-lock-after-reload-2.html&quot;;
+    }, errorFunction, function() { 
+        finishTest();
+    });
+}
+
+function runTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.clearAllDatabases();
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    try {
+        database = openDatabase(&quot;DatabaseLockTest&quot;, &quot;1.0&quot;, &quot;Test for database locking&quot;, 5242880);
+    } catch (e) {
+        log(&quot;Error - could not open database&quot;);
+        finishTest();
+    }
+    
+    database.transaction(function(tx) {
+        log(&quot;Adding a table&quot;);
+        tx.executeSql(&quot;CREATE TABLE DataTest (testData)&quot;, [], function(tx, result) { }, errorFunction); 
+    }, errorFunction, function() { 
+        addData(database); 
+    });
+}
+
+&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;pre id=&quot;console&quot;&gt;
+&lt;/pre&gt;
+&lt;/body&gt;
+
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsstorageresourcesdatabaselockafterreload2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/storage/resources/database-lock-after-reload-2.html (0 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/storage/resources/database-lock-after-reload-2.html                                (rev 0)
+++ trunk/LayoutTests/storage/resources/database-lock-after-reload-2.html        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+var database;
+
+function log(message)
+{
+    document.getElementById(&quot;console&quot;).innerHTML += message + &quot;&lt;br&gt;&quot;;
+}
+
+function finishTest()
+{
+    log(&quot;Test part 2 Complete&quot;);
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function errorFunction(tx, error)
+{
+    log(&quot;Test failed - &quot; + error.message);
+    finishTest();
+}
+
+function addData(db)
+{
+    db.transaction(function(tx) { 
+        log(&quot;Inserting some data&quot;);
+
+        tx.executeSql(&quot;INSERT INTO DataTest (testData) VALUES (?)&quot;, [&quot;A&quot;], function(tx, result) { }, errorFunction);
+    }, function(){}, function() { 
+        finishTest();
+    });
+}
+
+function runTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.dumpAsText();
+        layoutTestController.waitUntilDone();
+    }
+    
+    try {
+        database = openDatabase(&quot;DatabaseLockTest&quot;, &quot;1.0&quot;, &quot;Test for database locking&quot;, 5242880);
+        addData(database);
+    } catch(e) {
+        log(&quot;Error - could not open database&quot;);
+        finishTest();
+    }
+}
+
+&lt;/script&gt;
+&lt;/head&gt;
+
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;pre id=&quot;console&quot;&gt;
+&lt;/pre&gt;
+&lt;/body&gt;
+
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (45593 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2009-07-07 14:04:02 UTC (rev 45593)
+++ trunk/WebCore/ChangeLog        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2009-07-07  Ben Murdoch  &lt;benm@google.com&gt;
+
+        Reviewed by Antti Koivisto.
+
+        HTML5 Database becomes locked if a transaction is in progress when the page is refreshed.
+        https://bugs.webkit.org/show_bug.cgi?id=25711
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=25711 where web
+        storage databases could become locked until the browser is shut
+        down if the page is refreshed whilst a transaction is in progress.
+
+        Test: storage/database-lock-after-reload.html
+
+        * storage/Database.cpp:
+        (WebCore::Database::Database):
+        (WebCore::Database::close): add code to inform the database thread we've closed the database.
+        (WebCore::Database::performOpenAndVerify): add code to inform the database thread we've opened a database.
+        * storage/Database.h:
+        (WebCore::Database::opened): return true iff the underlying sqlite database has been opened but not closed.
+        * storage/DatabaseThread.cpp:
+        (WebCore::DatabaseThread::databaseThread): Before the database thread terminates, close any databases that ran transactions in this thread.
+        (WebCore::DatabaseThread::recordDatabaseOpen): Records a database that executed a transaction in this thread.
+        (WebCore::DatabaseThread::recordDatabaseClosed): Removes a database from the set of open databases.
+        * storage/DatabaseThread.h:
+        (WebCore::DatabaseThread::getThreadID): return the thread id for the database thread.
+
</ins><span class="cx"> 2009-07-07  Jiahua Huang  &lt;jhuangjiahua@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Jan Alonzo.
</span></span></pre></div>
<a id="trunkWebCorestorageDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/storage/Database.cpp (45593 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/storage/Database.cpp        2009-07-07 14:04:02 UTC (rev 45593)
+++ trunk/WebCore/storage/Database.cpp        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -60,6 +60,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+// If we sleep for more the 30 seconds while blocked on SQLITE_BUSY, give up.
+static const int maxSqliteBusyWaitTime = 30000;
+
</ins><span class="cx"> const String&amp; Database::databaseInfoTableName()
</span><span class="cx"> {
</span><span class="cx">     DEFINE_STATIC_LOCAL(String, name, (&quot;__WebKitDatabaseInfoTable__&quot;));
</span><span class="lines">@@ -132,6 +135,7 @@
</span><span class="cx">     , m_expectedVersion(expectedVersion)
</span><span class="cx">     , m_deleted(false)
</span><span class="cx">     , m_stopped(false)
</span><ins>+    , m_opened(false)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(document);
</span><span class="cx">     m_securityOrigin = document-&gt;securityOrigin();
</span><span class="lines">@@ -316,7 +320,13 @@
</span><span class="cx"> 
</span><span class="cx"> void Database::close()
</span><span class="cx"> {
</span><del>-    m_sqliteDatabase.close();
</del><ins>+    if (m_opened) {
+        ASSERT(m_document-&gt;databaseThread());
+        ASSERT(currentThread() == document()-&gt;databaseThread()-&gt;getThreadID());
+        m_sqliteDatabase.close();
+        m_document-&gt;databaseThread()-&gt;recordDatabaseClosed(this);
+        m_opened = false;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Database::stop()
</span><span class="lines">@@ -423,8 +433,13 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    m_opened = true;
+    if (m_document-&gt;databaseThread())
+        m_document-&gt;databaseThread()-&gt;recordDatabaseOpen(this);
+
</ins><span class="cx">     ASSERT(m_databaseAuthorizer);
</span><span class="cx">     m_sqliteDatabase.setAuthorizer(m_databaseAuthorizer);
</span><ins>+    m_sqliteDatabase.setBusyTimeout(maxSqliteBusyWaitTime);
</ins><span class="cx"> 
</span><span class="cx">     if (!m_sqliteDatabase.tableExists(databaseInfoTableName())) {
</span><span class="cx">         if (!m_sqliteDatabase.executeCommand(&quot;CREATE TABLE &quot; + databaseInfoTableName() + &quot; (key TEXT NOT NULL ON CONFLICT FAIL UNIQUE ON CONFLICT REPLACE,value TEXT NOT NULL ON CONFLICT FAIL);&quot;)) {
</span></span></pre></div>
<a id="trunkWebCorestorageDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/storage/Database.h (45593 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/storage/Database.h        2009-07-07 14:04:02 UTC (rev 45593)
+++ trunk/WebCore/storage/Database.h        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -100,6 +100,7 @@
</span><span class="cx">     bool deleted() const { return m_deleted; }
</span><span class="cx"> 
</span><span class="cx">     void close();
</span><ins>+    bool opened() const { return m_opened; }
</ins><span class="cx">     
</span><span class="cx">     void stop();
</span><span class="cx">     bool stopped() const { return m_stopped; }
</span><span class="lines">@@ -141,6 +142,8 @@
</span><span class="cx">     
</span><span class="cx">     bool m_stopped;
</span><span class="cx"> 
</span><ins>+    bool m_opened;
+
</ins><span class="cx">     SQLiteDatabase m_sqliteDatabase;
</span><span class="cx">     RefPtr&lt;DatabaseAuthorizer&gt; m_databaseAuthorizer;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCorestorageDatabaseThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/storage/DatabaseThread.cpp (45593 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/storage/DatabaseThread.cpp        2009-07-07 14:04:02 UTC (rev 45593)
+++ trunk/WebCore/storage/DatabaseThread.cpp        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -99,6 +99,17 @@
</span><span class="cx"> 
</span><span class="cx">     LOG(StorageAPI, &quot;About to detach thread %i and clear the ref to DatabaseThread %p, which currently has %i ref(s)&quot;, m_threadID, this, refCount());
</span><span class="cx"> 
</span><ins>+    // Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the database in an
+    // inconsistent or locked state.
+    if (m_openDatabaseSet.size() &gt; 0) {
+        // As the call to close will modify the original set, we must take a copy to iterate over.
+        DatabaseSet openSetCopy;
+        openSetCopy.swap(m_openDatabaseSet);
+        DatabaseSet::iterator end = openSetCopy.end();
+        for (DatabaseSet::iterator it = openSetCopy.begin(); it != end; ++it)
+           (*it)-&gt;close();
+    }
+
</ins><span class="cx">     // Detach the thread so its resources are no longer of any concern to anyone else
</span><span class="cx">     detachThread(m_threadID);
</span><span class="cx"> 
</span><span class="lines">@@ -108,6 +119,22 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void DatabaseThread::recordDatabaseOpen(Database* database) 
+{
+    ASSERT(currentThread() == m_threadID);
+    ASSERT(database);
+    ASSERT(!m_openDatabaseSet.contains(database));
+    m_openDatabaseSet.add(database);
+}
+
+void DatabaseThread::recordDatabaseClosed(Database* database) 
+{
+    ASSERT(currentThread() == m_threadID);
+    ASSERT(database);
+    ASSERT(m_queue.killed() || m_openDatabaseSet.contains(database));
+    m_openDatabaseSet.remove(database);
+}
+
</ins><span class="cx"> void DatabaseThread::scheduleTask(PassRefPtr&lt;DatabaseTask&gt; task)
</span><span class="cx"> {
</span><span class="cx">     m_queue.append(task);
</span></span></pre></div>
<a id="trunkWebCorestorageDatabaseThreadh"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/storage/DatabaseThread.h (45593 => 45594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/storage/DatabaseThread.h        2009-07-07 14:04:02 UTC (rev 45593)
+++ trunk/WebCore/storage/DatabaseThread.h        2009-07-07 14:29:15 UTC (rev 45594)
</span><span class="lines">@@ -56,6 +56,10 @@
</span><span class="cx">     void scheduleImmediateTask(PassRefPtr&lt;DatabaseTask&gt;); // This just adds the task to the front of the queue - the caller needs to be extremely careful not to create deadlocks when waiting for completion.
</span><span class="cx">     void unscheduleDatabaseTasks(Database*);
</span><span class="cx"> 
</span><ins>+    void recordDatabaseOpen(Database*);
+    void recordDatabaseClosed(Database*);
+    ThreadIdentifier getThreadID() { return m_threadID; }
+
</ins><span class="cx"> private:
</span><span class="cx">     DatabaseThread();
</span><span class="cx"> 
</span><span class="lines">@@ -67,6 +71,10 @@
</span><span class="cx">     RefPtr&lt;DatabaseThread&gt; m_selfRef;
</span><span class="cx"> 
</span><span class="cx">     MessageQueue&lt;RefPtr&lt;DatabaseTask&gt; &gt; m_queue;
</span><ins>+
+    // This set keeps track of the open databases that have been used on this thread.
+    typedef HashSet&lt;RefPtr&lt;Database&gt; &gt; DatabaseSet;
+    DatabaseSet m_openDatabaseSet;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>