Diff
Modified: trunk/Source/WebCore/ChangeLog (149457 => 149458)
--- trunk/Source/WebCore/ChangeLog 2013-05-01 22:01:10 UTC (rev 149457)
+++ trunk/Source/WebCore/ChangeLog 2013-05-01 22:38:45 UTC (rev 149458)
@@ -1,3 +1,15 @@
+2013-05-01 Anders Carlsson <[email protected]>
+
+ Begin work on loading items from the local storage database
+ https://bugs.webkit.org/show_bug.cgi?id=115489
+
+ Reviewed by Andreas Kling.
+
+ Export symbols and SQLite headers needed.
+
+ * WebCore.exp.in:
+ * WebCore.xcodeproj/project.pbxproj:
+
2013-05-01 Hans Muller <[email protected]>
[CSS Exclusions] Programmatic layout tests fail when subpixel layout is disabled
https://bugs.webkit.org/show_bug.cgi?id=115455
Modified: trunk/Source/WebCore/WebCore.exp.in (149457 => 149458)
--- trunk/Source/WebCore/WebCore.exp.in 2013-05-01 22:01:10 UTC (rev 149457)
+++ trunk/Source/WebCore/WebCore.exp.in 2013-05-01 22:38:45 UTC (rev 149458)
@@ -94,6 +94,7 @@
__ZN7WebCore10StorageMap6createEj
__ZN7WebCore10StorageMap7setItemERKN3WTF6StringES4_RS2_Rb
__ZN7WebCore10deleteFileERKN3WTF6StringE
+__ZN7WebCore10fileExistsERKN3WTF6StringE
__ZN7WebCore10setCookiesEPNS_8DocumentERKNS_4KURLERKN3WTF6StringE
__ZN7WebCore10toDocumentEN3JSC7JSValueE
__ZN7WebCore11BitmapImageC1EP7CGImagePNS_13ImageObserverE
@@ -355,6 +356,9 @@
__ZN7WebCore14ResourceHandle6createEPNS_17NetworkingContextERKNS_15ResourceRequestEPNS_20ResourceHandleClientEbb
__ZN7WebCore14ResourceLoader14cancelledErrorEv
__ZN7WebCore14ResourceLoader6cancelEv
+__ZN7WebCore14SQLiteDatabase11tableExistsERKN3WTF6StringE
+__ZN7WebCore14SQLiteDatabase14executeCommandERKN3WTF6StringE
+__ZN7WebCore14SQLiteDatabase4openERKN3WTF6StringEb
__ZN7WebCore14SchemeRegistry24registerURLSchemeAsLocalERKN3WTF6StringE
__ZN7WebCore14SchemeRegistry25registerURLSchemeAsSecureERKN3WTF6StringE
__ZN7WebCore14SchemeRegistry27registerURLSchemeAsNoAccessERKN3WTF6StringE
@@ -409,8 +413,6 @@
__ZN7WebCore14setMetadataURLERN3WTF6StringERKS1_S4_
__ZN7WebCore15AffineTransform5flipYEv
__ZN7WebCore15AffineTransform5scaleEd
-__ZNK7WebCore15AffineTransform6xScaleEv
-__ZNK7WebCore15AffineTransform6yScaleEv
__ZN7WebCore15AffineTransform8multiplyERKS0_
__ZN7WebCore15AffineTransform9translateEdd
__ZN7WebCore15AffineTransformC1Edddddd
@@ -472,6 +474,9 @@
__ZN7WebCore15ProtectionSpaceC1Ev
__ZN7WebCore15ResourceRequest21httpPipeliningEnabledEv
__ZN7WebCore15ResourceRequest24setHTTPPipeliningEnabledEb
+__ZN7WebCore15SQLiteStatement22isColumnDeclaredAsBlobEi
+__ZN7WebCore15SQLiteStatementC1ERNS_14SQLiteDatabaseERKN3WTF6StringE
+__ZN7WebCore15SQLiteStatementD1Ev
__ZN7WebCore15ScrollAlignment17alignCenterAlwaysE
__ZN7WebCore15ScrollAlignment19alignToEdgeIfNeededE
__ZN7WebCore15StorageStrategy21localStorageNamespaceEPNS_9PageGroupE
@@ -528,6 +533,11 @@
__ZN7WebCore16NavigationActionC1ERKNS_15ResourceRequestENS_14NavigationTypeE
__ZN7WebCore16NavigationActionC1Ev
__ZN7WebCore16ResourceResponse19setCertificateChainEPK9__CFArray
+__ZN7WebCore17SQLiteTransaction5beginEv
+__ZN7WebCore17SQLiteTransaction6commitEv
+__ZN7WebCore17SQLiteTransaction8rollbackEv
+__ZN7WebCore17SQLiteTransactionC1ERNS_14SQLiteDatabaseEb
+__ZN7WebCore17SQLiteTransactionD1Ev
__ZN7WebCore16ScriptController10initScriptEPNS_15DOMWrapperWorldE
__ZN7WebCore16ScriptController11createWorldEv
__ZN7WebCore16ScriptController13executeScriptERKN3WTF6StringEb
@@ -1361,6 +1371,8 @@
__ZNK7WebCore14ResourceBuffer7isEmptyEv
__ZNK7WebCore14ResourceHandle10connectionEv
__ZNK7WebCore14ResourceLoader11frameLoaderEv
+__ZN7WebCore14SQLiteDatabaseC1Ev
+__ZN7WebCore14SQLiteDatabaseD1Ev
__ZNK7WebCore14ScrollableArea14scrollAnimatorEv
__ZNK7WebCore14ScrollableArea20contentAreaWillPaintEv
__ZNK7WebCore14ScrollableArea22mouseExitedContentAreaEv
@@ -1375,6 +1387,8 @@
__ZNK7WebCore14SecurityOrigin16canAccessStorageEPKS0_
__ZNK7WebCore15AffineTransform10isIdentityEv
__ZNK7WebCore15AffineTransform12isInvertibleEv
+__ZNK7WebCore15AffineTransform6xScaleEv
+__ZNK7WebCore15AffineTransform6yScaleEv
__ZNK7WebCore15AffineTransform7inverseEv
__ZNK7WebCore15AffineTransform8mapPointERKNS_10FloatPointE
__ZNK7WebCore15AffineTransform8mapPointERKNS_8IntPointE
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (149457 => 149458)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-05-01 22:01:10 UTC (rev 149457)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-05-01 22:38:45 UTC (rev 149458)
@@ -400,7 +400,7 @@
1A2246490CC98DDB00C05240 /* SQLiteDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2246430CC98DDB00C05240 /* SQLiteDatabase.cpp */; };
1A22464A0CC98DDB00C05240 /* SQLiteDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2246440CC98DDB00C05240 /* SQLiteDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A22464B0CC98DDB00C05240 /* SQLiteStatement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2246450CC98DDB00C05240 /* SQLiteStatement.cpp */; };
- 1A22464C0CC98DDB00C05240 /* SQLiteStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2246460CC98DDB00C05240 /* SQLiteStatement.h */; };
+ 1A22464C0CC98DDB00C05240 /* SQLiteStatement.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2246460CC98DDB00C05240 /* SQLiteStatement.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A22464D0CC98DDB00C05240 /* SQLiteTransaction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2246470CC98DDB00C05240 /* SQLiteTransaction.cpp */; };
1A22464E0CC98DDB00C05240 /* SQLiteTransaction.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2246480CC98DDB00C05240 /* SQLiteTransaction.h */; settings = {ATTRIBUTES = (Private, ); }; };
1A2A68230B5BEDE70002A480 /* ProgressTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2A68210B5BEDE70002A480 /* ProgressTracker.cpp */; };
Modified: trunk/Source/WebKit2/ChangeLog (149457 => 149458)
--- trunk/Source/WebKit2/ChangeLog 2013-05-01 22:01:10 UTC (rev 149457)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-01 22:38:45 UTC (rev 149458)
@@ -1,3 +1,31 @@
+2013-05-01 Anders Carlsson <[email protected]>
+
+ Begin work on loading items from the local storage database
+ https://bugs.webkit.org/show_bug.cgi?id=115489
+
+ Reviewed by Andreas Kling.
+
+ Some of the LocalStorageDatabase code is originally from WebCore,
+ but has been simplified due to the fact that we don't need to load
+ database data asynchronously since we're already running on a non-main thread.
+
+ * UIProcess/Storage/LocalStorageDatabase.cpp:
+ (WebKit::LocalStorageDatabase::LocalStorageDatabase):
+ (WebKit::LocalStorageDatabase::openDatabase):
+ (WebKit::LocalStorageDatabase::tryToOpenDatabase):
+ (WebKit::LocalStorageDatabase::migrateItemTableIfNeeded):
+ (WebKit::LocalStorageDatabase::importItems):
+
+ * UIProcess/Storage/LocalStorageDatabase.h:
+ (WebKit::StorageManager::StorageArea::setItem):
+ (WebKit::StorageManager::StorageArea::removeItem):
+ (WebKit::StorageManager::StorageArea::clear):
+ (WebKit::StorageManager::StorageArea::items):
+ Call importItemsFromDatabase().
+
+ (WebKit::StorageManager::StorageArea::importItemsFromDatabase):
+ Ask the database to import the items.
+
2013-05-01 Ryuan Choi <[email protected]>
[EFL] Unreviewed buildfix after r149449.
Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp (149457 => 149458)
--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2013-05-01 22:01:10 UTC (rev 149457)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2013-05-01 22:38:45 UTC (rev 149458)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,9 +27,14 @@
#include "LocalStorageDatabase.h"
#include "WorkQueue.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/SQLiteStatement.h>
+#include <WebCore/SQLiteTransaction.h>
#include <wtf/PassRefPtr.h>
#include <wtf/text/WTFString.h>
+using namespace WebCore;
+
namespace WebKit {
PassRefPtr<LocalStorageDatabase> LocalStorageDatabase::create(const String& databaseFilename, PassRefPtr<WorkQueue> queue)
@@ -38,20 +43,107 @@
}
LocalStorageDatabase::LocalStorageDatabase(const String& databaseFilename, PassRefPtr<WorkQueue> queue)
- : m_queue(queue)
+ : m_databaseFilename(databaseFilename)
+ , m_queue(queue)
+ , m_failedToOpenDatabase(false)
{
- // FIXME: If it can't import, then the default WebKit behavior should be that of private browsing,
- // not silently ignoring it. https://bugs.webkit.org/show_bug.cgi?id=25894
- m_queue->dispatch(bind(&LocalStorageDatabase::performImport, this));
}
LocalStorageDatabase::~LocalStorageDatabase()
{
}
-void LocalStorageDatabase::performImport()
+void LocalStorageDatabase::openDatabase(DatabaseOpeningStrategy openingStrategy)
{
- // FIXME: Actually import.
+ ASSERT(!m_database.isOpen());
+ ASSERT(!m_failedToOpenDatabase);
+
+ if (!tryToOpenDatabase(openingStrategy))
+ m_failedToOpenDatabase = true;
}
+bool LocalStorageDatabase::tryToOpenDatabase(DatabaseOpeningStrategy openingStrategy)
+{
+ if (!fileExists(m_databaseFilename) && openingStrategy == SkipIfNonExistent)
+ return true;
+
+ if (m_databaseFilename.isEmpty()) {
+ LOG_ERROR("Filename for local storage database is empty - cannot open for persistent storage");
+ return false;
+ }
+
+ // FIXME:
+ // A StorageTracker thread may have been scheduled to delete the db we're
+ // reopening, so cancel possible deletion.
+
+ if (!m_database.open(m_databaseFilename)) {
+ LOG_ERROR("Failed to open database file %s for local storage", m_databaseFilename.utf8().data());
+ return false;
+ }
+
+ if (!migrateItemTableIfNeeded()) {
+ // We failed to migrate the item table. In order to avoid trying to migrate the table over and over,
+ // just delete it and start from scratch.
+ if (!m_database.executeCommand("DROP TABLE ItemTable"))
+ LOG_ERROR("Failed to delete table ItemTable for local storage");
+ }
+
+ if (!m_database.executeCommand("CREATE TABLE IF NOT EXISTS ItemTable (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL)")) {
+ LOG_ERROR("Failed to create table ItemTable for local storage");
+ return false;
+ }
+
+ return true;
+}
+
+bool LocalStorageDatabase::migrateItemTableIfNeeded()
+{
+ if (!m_database.tableExists("ItemTable"))
+ return true;
+
+ SQLiteStatement query(m_database, "SELECT value FROM ItemTable LIMIT 1");
+
+ // This query isn't ever executed, it's just used to check the column type.
+ if (query.isColumnDeclaredAsBlob(0))
+ return true;
+
+ // Create a new table with the right type, copy all the data over to it and then replace the new table with the old table.
+ static const char* commands[] = {
+ "DROP TABLE IF EXISTS ItemTable2",
+ "CREATE TABLE ItemTable2 (key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL)",
+ "INSERT INTO ItemTable2 SELECT * from ItemTable",
+ "DROP TABLE ItemTable",
+ "ALTER TABLE ItemTable2 RENAME TO ItemTable",
+ 0,
+ };
+
+ SQLiteTransaction transaction(m_database, false);
+ transaction.begin();
+
+ for (size_t i = 0; commands[i]; ++i) {
+ if (m_database.executeCommand(commands[i]))
+ continue;
+
+ LOG_ERROR("Failed to migrate table ItemTable for local storage when executing: %s", commands[i]);
+ transaction.rollback();
+
+ return false;
+ }
+
+ transaction.commit();
+ return true;
+}
+
+void LocalStorageDatabase::importItems(StorageMap&)
+{
+ // FIXME: If it can't import, then the default WebKit behavior should be that of private browsing,
+ // not silently ignoring it. https://bugs.webkit.org/show_bug.cgi?id=25894
+
+ openDatabase(SkipIfNonExistent);
+ if (!m_database.isOpen())
+ return;
+
+ // FIXME: Actually import the items.
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h (149457 => 149458)
--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h 2013-05-01 22:01:10 UTC (rev 149457)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h 2013-05-01 22:38:45 UTC (rev 149458)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,12 +26,17 @@
#ifndef LocalStorageDatabase_h
#define LocalStorageDatabase_h
+#include <WebCore/SQLiteDatabase.h>
#include <wtf/Forward.h>
#include <wtf/RefPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
class WorkQueue;
+namespace WebCore {
+class StorageMap;
+}
+
namespace WebKit {
class LocalStorageDatabase : public ThreadSafeRefCounted<LocalStorageDatabase> {
@@ -39,12 +44,28 @@
static PassRefPtr<LocalStorageDatabase> create(const String& databaseFilename, PassRefPtr<WorkQueue>);
~LocalStorageDatabase();
+ // Will block until the import is complete.
+ void importItems(WebCore::StorageMap&);
+
private:
LocalStorageDatabase(const String& databaseFilename, PassRefPtr<WorkQueue>);
+ enum DatabaseOpeningStrategy {
+ CreateIfNonExistent,
+ SkipIfNonExistent
+ };
+ bool tryToOpenDatabase(DatabaseOpeningStrategy);
+ void openDatabase(DatabaseOpeningStrategy);
+
+ bool migrateItemTableIfNeeded();
+
void performImport();
+ String m_databaseFilename;
RefPtr<WorkQueue> m_queue;
+
+ WebCore::SQLiteDatabase m_database;
+ bool m_failedToOpenDatabase;
};
Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (149457 => 149458)
--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-05-01 22:01:10 UTC (rev 149457)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp 2013-05-01 22:38:45 UTC (rev 149458)
@@ -56,11 +56,13 @@
void removeItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& urlString);
void clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString);
- const HashMap<String, String>& items() const { return m_storageMap->items(); }
+ const HashMap<String, String>& items();
private:
explicit StorageArea(LocalStorageNamespace*, PassRefPtr<SecurityOrigin>, unsigned quotaInBytes);
+ void importItemsFromDatabase();
+
void dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const;
// Will be null if the storage area belongs to a session storage namespace.
@@ -143,6 +145,8 @@
void StorageManager::StorageArea::setItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& value, const String& urlString, bool& quotaException)
{
+ importItemsFromDatabase();
+
String oldValue;
RefPtr<StorageMap> newStorageMap = m_storageMap->setItem(key, value, oldValue, quotaException);
@@ -155,6 +159,8 @@
void StorageManager::StorageArea::removeItem(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& urlString)
{
+ importItemsFromDatabase();
+
String oldValue;
RefPtr<StorageMap> newStorageMap = m_storageMap->removeItem(key, oldValue);
if (newStorageMap)
@@ -168,6 +174,8 @@
void StorageManager::StorageArea::clear(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& urlString)
{
+ importItemsFromDatabase();
+
if (!m_storageMap->length())
return;
@@ -176,6 +184,21 @@
dispatchEvents(sourceConnection, sourceStorageAreaID, String(), String(), String(), urlString);
}
+const HashMap<String, String>& StorageManager::StorageArea::items()
+{
+ importItemsFromDatabase();
+
+ return m_storageMap->items();
+}
+
+void StorageManager::StorageArea::importItemsFromDatabase()
+{
+ if (!m_localStorageDatabase)
+ return;
+
+ m_localStorageDatabase->importItems(*m_storageMap);
+}
+
void StorageManager::StorageArea::dispatchEvents(CoreIPC::Connection* sourceConnection, uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString) const
{
for (HashSet<std::pair<RefPtr<CoreIPC::Connection>, uint64_t> >::const_iterator it = m_eventListeners.begin(), end = m_eventListeners.end(); it != end; ++it) {