Changeset 88358 in webkit


Ignore:
Timestamp:
Jun 8, 2011 10:50:29 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-08 Greg Simon <gregsimon@chromium.org>

Reviewed by Dimitri Glazkov.

Test migration from sqlite to leveldb for IndexedDB
backend.
https://bugs.webkit.org/show_bug.cgi?id=61000

  • storage/indexeddb/migrate-basics-expected.txt: Added.
  • storage/indexeddb/migrate-basics.html: Added.

2011-06-08 Greg Simon <gregsimon@chromium.org>

Reviewed by Dimitri Glazkov.

Control Indexeddb backends from LayoutTestController
https://bugs.webkit.org/show_bug.cgi?id=61000

Test: storage/indexeddb/migrate-basics.html

  • storage/IDBBackingStore.h:
  • storage/IDBFactoryBackendImpl.cpp: (WebCore::IDBFactoryBackendImpl::open): (WebCore::IDBFactoryBackendImpl::migrate):
  • storage/IDBFactoryBackendImpl.h:
  • storage/IDBFactoryBackendInterface.h:
  • storage/IDBLevelDBBackingStore.cpp: (WebCore::IDBLevelDBBackingStore::backingStoreExists):
  • storage/IDBLevelDBBackingStore.h: (WebCore::IDBLevelDBBackingStore::backingStoreType):
  • storage/IDBSQLiteBackingStore.cpp: (WebCore::IDBSQLiteBackingStore::backingStoreExists):
  • storage/IDBSQLiteBackingStore.h: (WebCore::IDBSQLiteBackingStore::backingStoreType):

2011-06-08 Greg Simon <gregsimon@chromium.org>

Reviewed by Dimitri Glazkov.

Control Indexeddb backends from LayoutTestController
https://bugs.webkit.org/show_bug.cgi?id=61000

  • public/WebIDBFactory.h:
  • src/AssertMatchingEnums.cpp:
  • src/WebIDBFactoryImpl.cpp: (WebKit::WebIDBFactory::setOverrideBackingStoreType): (WebKit::WebIDBFactory::setTemporaryDatabaseFolder): (WebKit::WebIDBFactoryImpl::open):

2011-06-08 Greg Simon <gregsimon@chromium.org>

Reviewed by Dimitri Glazkov.

Control Indexeddb backends from LayoutTestController
https://bugs.webkit.org/show_bug.cgi?id=61000

  • DumpRenderTree/chromium/LayoutTestController.cpp: (LayoutTestController::LayoutTestController): (LayoutTestController::setOverrideIndexedDBBackingStore): (LayoutTestController::clearAllDatabases):
  • DumpRenderTree/chromium/LayoutTestController.h:
Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r88356 r88358  
     12011-06-08  Greg Simon  <gregsimon@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Test migration from sqlite to leveldb for IndexedDB
     6        backend.
     7        https://bugs.webkit.org/show_bug.cgi?id=61000
     8
     9        * storage/indexeddb/migrate-basics-expected.txt: Added.
     10        * storage/indexeddb/migrate-basics.html: Added.
     11
    1122011-06-08  James Simonsen  <simonjam@chromium.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r88357 r88358  
     12011-06-08  Greg Simon  <gregsimon@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Control Indexeddb backends from LayoutTestController
     6        https://bugs.webkit.org/show_bug.cgi?id=61000
     7
     8        Test: storage/indexeddb/migrate-basics.html
     9
     10        * storage/IDBBackingStore.h:
     11        * storage/IDBFactoryBackendImpl.cpp:
     12        (WebCore::IDBFactoryBackendImpl::open):
     13        (WebCore::IDBFactoryBackendImpl::migrate):
     14        * storage/IDBFactoryBackendImpl.h:
     15        * storage/IDBFactoryBackendInterface.h:
     16        * storage/IDBLevelDBBackingStore.cpp:
     17        (WebCore::IDBLevelDBBackingStore::backingStoreExists):
     18        * storage/IDBLevelDBBackingStore.h:
     19        (WebCore::IDBLevelDBBackingStore::backingStoreType):
     20        * storage/IDBSQLiteBackingStore.cpp:
     21        (WebCore::IDBSQLiteBackingStore::backingStoreExists):
     22        * storage/IDBSQLiteBackingStore.h:
     23        (WebCore::IDBSQLiteBackingStore::backingStoreType):
     24
    1252011-06-08  Dmitry Lomov  <dslomov@google.com>
    226
  • trunk/Source/WebCore/storage/IDBBackingStore.h

    r88103 r88358  
    3030
    3131#include "IDBCursor.h"
     32#include "IDBFactoryBackendInterface.h"
    3233#include "SQLiteDatabase.h"
    3334#include <wtf/PassRefPtr.h>
     
    3839namespace WebCore {
    3940
    40 class IDBFactoryBackendImpl;
    4141class IDBKey;
    4242class IDBKeyRange;
     
    108108    };
    109109    virtual PassRefPtr<Transaction> createTransaction() = 0;
     110    virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() const = 0;
    110111};
    111112
  • trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp

    r87313 r88358  
    7373void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType backingStoreType)
    7474{
    75     String fileIdentifier = securityOrigin->databaseIdentifier();
    76     String uniqueIdentifier = fileIdentifier + "@" + name;
     75    String uniqueIdentifier = securityOrigin->databaseIdentifier() + "@" + name + String::format("@%d", (int)backingStoreType);
    7776    IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentifier);
    7877    if (it != m_databaseBackendMap.end()) {
     
    8483
    8584    RefPtr<IDBBackingStore> backingStore;
    86     IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier);
    87     if (it2 != m_backingStoreMap.end())
     85    IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(uniqueIdentifier);
     86    if (it2 != m_backingStoreMap.end() && (backingStoreType == it2->second->backingStoreType()))
    8887        backingStore = it2->second;
    8988    else {
    90         if (backingStoreType == DefaultBackingStore)
    91             backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this);
     89#if ENABLE(LEVELDB)
     90        // Should we migrate this backing store?
     91        bool hasSQLBackingStore = IDBSQLiteBackingStore::backingStoreExists(securityOrigin.get(), dataDir);
     92        bool hasLevelDBBackingStore = IDBLevelDBBackingStore::backingStoreExists(securityOrigin.get(), dataDir);
     93
     94        if (hasSQLBackingStore && hasLevelDBBackingStore)
     95            backingStoreType = LevelDBBackingStore;
     96
     97        // Migration: if the database exists and is SQLite we want to migrate it to LevelDB.
     98        if (hasSQLBackingStore && !hasLevelDBBackingStore) {
     99            if (migrate(name, securityOrigin.get(), dataDir, maximumSize))
     100                backingStoreType = LevelDBBackingStore;
     101        }
     102#endif
     103
     104        if (backingStoreType == DefaultBackingStore || backingStoreType == SQLiteBackingStore)
     105            backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, uniqueIdentifier, this);
    92106#if ENABLE(LEVELDB)
    93107        else if (backingStoreType == LevelDBBackingStore)
    94             backingStore = IDBLevelDBBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this);
     108            backingStore = IDBLevelDBBackingStore::open(securityOrigin.get(), dataDir, maximumSize, uniqueIdentifier, this);
    95109#endif
    96110        if (!backingStore) {
     
    105119}
    106120
     121bool IDBFactoryBackendImpl::migrate(const String& name, SecurityOrigin* securityOrigin, const String& dataDir, int64_t maximumSize)
     122{
     123    return false;
     124}
     125
    107126} // namespace WebCore
    108127
  • trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h

    r87313 r88358  
    6060private:
    6161    IDBFactoryBackendImpl();
     62    bool migrate(const String& name, SecurityOrigin*, const String& dataDir, int64_t maximumSize);
    6263
    6364    typedef HashMap<String, IDBDatabaseBackendImpl*> IDBDatabaseBackendMap;
  • trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h

    r87313 r88358  
    5454    enum BackingStoreType {
    5555        DefaultBackingStore,
    56         LevelDBBackingStore
     56        LevelDBBackingStore,
     57        SQLiteBackingStore
    5758    };
    5859
  • trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp

    r88146 r88358  
    13051305}
    13061306
     1307bool IDBLevelDBBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBaseArg)
     1308{
     1309    String pathBase = pathBaseArg;
     1310
     1311    if (pathBase.isEmpty())
     1312        return false;
     1313
     1314    // FIXME: We should eventually use the same LevelDB database for all origins.
     1315    String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb.leveldb");
     1316
     1317    // FIXME: It would be more thorough to open the database here but also more expensive.
     1318    if (fileExists(path+"/CURRENT"))
     1319        return true;
     1320
     1321    return false;
     1322}
     1323
    13071324// FIXME: deleteDatabase should be part of IDBBackingStore.
    13081325
  • trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h

    r87370 r88358  
    3838class LevelDBDatabase;
    3939class LevelDBTransaction;
     40class IDBFactoryBackendImpl;
    4041
    4142class IDBLevelDBBackingStore : public IDBBackingStore {
     
    7475
    7576    virtual PassRefPtr<Transaction> createTransaction();
     77    virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() const { return IDBFactoryBackendInterface::LevelDBBackingStore; }
     78
     79    static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
    7680
    7781private:
  • trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp

    r87313 r88358  
    992992}
    993993
     994bool IDBSQLiteBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBase)
     995{
     996    String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb");
     997
     998    SQLiteDatabase db;
     999    if (!db.open(path))
     1000        return false;
     1001
     1002    db.close();
     1003    return true;
     1004}
     1005
    9941006namespace {
    9951007
  • trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h

    r87313 r88358  
    3232
    3333namespace WebCore {
     34   
     35class IDBFactoryBackendImpl;
    3436
    3537class IDBSQLiteBackingStore : public IDBBackingStore {
     
    6870
    6971    virtual PassRefPtr<Transaction> createTransaction();
     72    virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() const { return IDBFactoryBackendInterface::SQLiteBackingStore; }
     73
     74    static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
    7075
    7176private:
  • trunk/Source/WebKit/chromium/ChangeLog

    r88351 r88358  
     12011-06-08  Greg Simon  <gregsimon@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Control Indexeddb backends from LayoutTestController
     6        https://bugs.webkit.org/show_bug.cgi?id=61000
     7
     8        * public/WebIDBFactory.h:
     9        * src/AssertMatchingEnums.cpp:
     10        * src/WebIDBFactoryImpl.cpp:
     11        (WebKit::WebIDBFactory::setOverrideBackingStoreType):
     12        (WebKit::WebIDBFactory::setTemporaryDatabaseFolder):
     13        (WebKit::WebIDBFactoryImpl::open):
     14
    1152011-06-08  Dominic Mazzoni  <dmazzoni@google.com>
    216
  • trunk/Source/WebKit/chromium/public/WebIDBFactory.h

    r87313 r88358  
    5454    enum BackingStoreType {
    5555        DefaultBackingStore,
    56         LevelDBBackingStore
     56        LevelDBBackingStore,
     57        SQLiteBackingStore
    5758    };
    5859
     
    6162
    6263    virtual void deleteDatabase(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir) { WEBKIT_ASSERT_NOT_REACHED(); }
     64
     65    // Used for DumpRenderTree tests.
     66    WEBKIT_API static void setOverrideBackingStoreType(BackingStoreType);
     67    WEBKIT_API static void setTemporaryDatabaseFolder(const WebString& path);
    6368};
    6469
  • trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp

    r88174 r88358  
    400400COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::DefaultBackingStore, IDBFactoryBackendInterface::DefaultBackingStore);
    401401COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::LevelDBBackingStore, IDBFactoryBackendInterface::LevelDBBackingStore);
     402COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::SQLiteBackingStore, IDBFactoryBackendInterface::SQLiteBackingStore);
    402403
    403404#if ENABLE(FILE_SYSTEM)
  • trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp

    r87313 r88358  
    4545namespace WebKit {
    4646
     47static WebIDBFactory::BackingStoreType overriddenBackingStoreType = WebIDBFactory::DefaultBackingStore;
     48static WebString tempDatabaseFolder;
     49
    4750WebIDBFactory* WebIDBFactory::create()
    4851{
    4952    return new WebIDBFactoryImpl();
     53}
     54
     55void WebIDBFactory::setOverrideBackingStoreType(BackingStoreType type)
     56{
     57    overriddenBackingStoreType = type;
     58}
     59
     60void WebIDBFactory::setTemporaryDatabaseFolder(const WebString& path)
     61{
     62    tempDatabaseFolder = path;
    5063}
    5164
     
    6174void WebIDBFactoryImpl::open(const WebString& name, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType backingStoreType)
    6275{
    63     m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, dataDir, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType));
     76    WebString path = dataDir;
     77    if (overriddenBackingStoreType != DefaultBackingStore) {
     78        backingStoreType = overriddenBackingStoreType;
     79
     80        // The dataDir is empty for two reasons: LevelDB in icognito mode or
     81        // LevelDB from DumpRenderTree. The first case is taken care of inside
     82        // IDBFactoryBackendImpl.cpp by forcing SQLITE backend for incognito.
     83        // For the DumpRenderTree case we need to keep track of the location
     84        // so we can wipe it out when we're done with the test.
     85        if (dataDir.isEmpty() && backingStoreType == LevelDBBackingStore)
     86            path = tempDatabaseFolder;
     87    }
     88    m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, path, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType));
    6489}
    6590
  • trunk/Tools/ChangeLog

    r88353 r88358  
     12011-06-08  Greg Simon  <gregsimon@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Control Indexeddb backends from LayoutTestController
     6        https://bugs.webkit.org/show_bug.cgi?id=61000
     7
     8        * DumpRenderTree/chromium/LayoutTestController.cpp:
     9        (LayoutTestController::LayoutTestController):
     10        (LayoutTestController::setOverrideIndexedDBBackingStore):
     11        (LayoutTestController::clearAllDatabases):
     12        * DumpRenderTree/chromium/LayoutTestController.h:
     13
    1142011-06-08  Andreas Kling  <kling@webkit.org>
    215
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp

    r88174 r88358  
    4545#include "WebFrame.h"
    4646#include "WebGeolocationClientMock.h"
     47#include "WebIDBFactory.h"
    4748#include "WebInputElement.h"
    4849#include "WebKit.h"
     
    8485    // by CppBoundClass, the parent to LayoutTestController).
    8586    bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
     87    bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
    8688    bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry);
    8789    bindMethod("addUserScript", &LayoutTestController::addUserScript);
     
    163165    bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError);
    164166    bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition);
    165     bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
     167    bindMethod("setOverrideIndexedDBBackingStore", &LayoutTestController::setOverrideIndexedDBBackingStore);
    166168    bindMethod("setPageVisibility", &LayoutTestController::setPageVisibility);
    167169    bindMethod("setPluginsEnabled", &LayoutTestController::setPluginsEnabled);
     
    11461148    // We don't use the WebKit icon database.
    11471149    result->setNull();
     1150}
     1151
     1152void LayoutTestController::setOverrideIndexedDBBackingStore(const CppArgumentList& arguments, CppVariant* result)
     1153{
     1154    result->setNull();
     1155#if ENABLE(INDEXED_DATABASE)
     1156    if (arguments.size() < 1 || !arguments[0].isString())
     1157        return;
     1158    string name = arguments[0].toString();
     1159    if (name == "default")
     1160        WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::DefaultBackingStore);
     1161    else if (name == "sqlite")
     1162        WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::SQLiteBackingStore);
     1163    else if (name == "leveldb") {
     1164        WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::LevelDBBackingStore);
     1165
     1166        m_tempFolder = adoptPtr(webkit_support::CreateScopedTempDirectory());
     1167        if (m_tempFolder) {
     1168            if (m_tempFolder->CreateUniqueTempDir())
     1169                WebIDBFactory::setTemporaryDatabaseFolder(WebString::fromUTF8(m_tempFolder->path().c_str()));
     1170        }
     1171    }
     1172#endif
    11481173}
    11491174
     
    15251550    result->setNull();
    15261551    webkit_support::ClearAllDatabases();
     1552    m_tempFolder.clear();
    15271553}
    15281554
  • trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h

    r88010 r88358  
    5757}
    5858
     59namespace webkit_support {
     60class ScopedTempDirectory;
     61}
     62
    5963class TestShell;
    6064
     
    307311    // Sets the default quota for all origins
    308312    void setDatabaseQuota(const CppArgumentList&, CppVariant*);
     313    // Overrides the backend for IndexedDB
     314    void setOverrideIndexedDBBackingStore(const CppArgumentList&, CppVariant*);
    309315
    310316    // Calls setlocale(LC_ALL, ...) for a specified locale.
     
    600606    CppVariant m_globalFlag;
    601607
     608    // Used to create and destroy temporary folders.
     609    OwnPtr<webkit_support::ScopedTempDirectory> m_tempFolder;
     610
    602611    // Bound variable counting the number of top URLs visited.
    603612    CppVariant m_webHistoryItemCount;
Note: See TracChangeset for help on using the changeset viewer.