Changeset 52631 in webkit


Ignore:
Timestamp:
Dec 29, 2009 12:51:32 PM (14 years ago)
Author:
dumi@chromium.org
Message:
  1. Changes the order in which some functions are called to match

the pre-r52536 order. Namely, when a new Database object is
created, DatabaseTracker::addOpenDatabase() is called in the
constructor, before doing anything else related to that database
(like trying to get a file handle to the database
file). Chromium's implementation depends on this ordering.

  1. Changes Database::performOpenAndVerify() to close the open

handle to the database file immediately if the database version
does not match the expected one. The current behavior is to add
the Database object to a DatabaseThread collection and let the
database thread close the handle when it's destroyed.

Reviewed by Maciej Stachowiak.

https://bugs.webkit.org/show_bug.cgi?id=33005

All LayoutTests/storage tests pass in clean WebKit and Chromium
clients.

  • storage/Database.cpp:

(WebCore::Database::openDatabase): Notify DatabaseTracker and
Document that a Database object is about to be destroyed (when a
database file cannot be opened, or its version doesn't match the
expected one).
(WebCore::Database::Database): Notify DatabaseTracker and Document
that a new Database object was created.
(WebCore::Database::performOpenAndVerify): If a database version
does not match the expected one, immediately close the open file
handle to the database file.

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52630 r52631  
     12009-12-28  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        1. Changes the order in which some functions are called to match
     6        the pre-r52536 order. Namely, when a new Database object is
     7        created, DatabaseTracker::addOpenDatabase() is called in the
     8        constructor, before doing anything else related to that database
     9        (like trying to get a file handle to the database
     10        file). Chromium's implementation depends on this ordering.
     11        2. Changes Database::performOpenAndVerify() to close the open
     12        handle to the database file immediately if the database version
     13        does not match the expected one. The current behavior is to add
     14        the Database object to a DatabaseThread collection and let the
     15        database thread close the handle when it's destroyed.
     16
     17        https://bugs.webkit.org/show_bug.cgi?id=33005
     18
     19        All LayoutTests/storage tests pass in clean WebKit and Chromium
     20        clients.
     21
     22        * storage/Database.cpp:
     23        (WebCore::Database::openDatabase): Notify DatabaseTracker and
     24        Document that a Database object is about to be destroyed (when a
     25        database file cannot be opened, or its version doesn't match the
     26        expected one).
     27        (WebCore::Database::Database): Notify DatabaseTracker and Document
     28        that a new Database object was created.
     29        (WebCore::Database::performOpenAndVerify): If a database version
     30        does not match the expected one, immediately close the open file
     31        handle to the database file.
     32
    1332009-12-29  Nikolas Zimmermann  <nzimmermann@rim.com>
    234
  • trunk/WebCore/storage/Database.cpp

    r52569 r52631  
    132132
    133133    if (!database->openAndVerifyVersion(e)) {
    134        LOG(StorageAPI, "Failed to open and verify version (expected %s) of database %s", expectedVersion.ascii().data(), database->databaseDebugName().ascii().data());
    135        return 0;
    136     }
    137 
    138     DatabaseTracker::tracker().addOpenDatabase(database.get());
    139     document->addOpenDatabase(database.get());
     134        LOG(StorageAPI, "Failed to open and verify version (expected %s) of database %s", expectedVersion.ascii().data(), database->databaseDebugName().ascii().data());
     135        document->removeOpenDatabase(database.get());
     136        DatabaseTracker::tracker().removeOpenDatabase(database.get());
     137        return 0;
     138    }
    140139
    141140    DatabaseTracker::tracker().setDatabaseDetails(document->securityOrigin(), name, displayName, estimatedSize);
     
    190189
    191190    m_filename = DatabaseTracker::tracker().fullPathForDatabase(m_mainThreadSecurityOrigin.get(), m_name);
     191
     192    DatabaseTracker::tracker().addOpenDatabase(this);
     193    m_document->addOpenDatabase(this);
    192194}
    193195
     
    481483                    LOG_ERROR("Unable to create table %s in database %s", databaseInfoTableName().ascii().data(), databaseDebugName().ascii().data());
    482484                    e = INVALID_STATE_ERR;
     485                    // Close the handle to the database file.
     486                    m_sqliteDatabase.close();
    483487                    return false;
    484488                }
     
    488492                LOG_ERROR("Failed to get current version from database %s", databaseDebugName().ascii().data());
    489493                e = INVALID_STATE_ERR;
     494                // Close the handle to the database file.
     495                m_sqliteDatabase.close();
    490496                return false;
    491497            }
     
    497503                    LOG_ERROR("Failed to set version %s in database %s", m_expectedVersion.ascii().data(), databaseDebugName().ascii().data());
    498504                    e = INVALID_STATE_ERR;
     505                    // Close the handle to the database file.
     506                    m_sqliteDatabase.close();
    499507                    return false;
    500508                }
     
    517525            databaseDebugName().ascii().data(), currentVersion.ascii().data());
    518526        e = INVALID_STATE_ERR;
     527        // Close the handle to the database file.
     528        m_sqliteDatabase.close();
    519529        return false;
    520530    }
    521531
     532    // All checks passed and we still have a handle to this database file.
     533    // Make sure DatabaseThread closes it when DatabaseThread goes away.
    522534    m_opened = true;
    523535    if (m_document->databaseThread())
Note: See TracChangeset for help on using the changeset viewer.