From 2d5db9a9307af7066b2396b87ffb52c6af4e9ba7 Mon Sep 17 00:00:00 2001 From: Jiyeon Kim Date: Fri, 22 Mar 2013 15:47:51 +0900 Subject: [PATCH] WebProcess crash is occured during changing default directory path for file system [Title] WebProcess crash is occured during changing default directory path for file system [Problem] Webprocess crash is occured during changing default directory path of file system [Cause] There are two reasons for this problem. First, resetStoragePath() method is called before initializeWebProcess Second, type of m_basePath is class. So if m_basePath can change, it need set API [Solution] First, LocalFileSystem, web database, web storage initialize themselves in resetStoragePath method even if initializeWebProcess Add set api for changing m_basePath value Change-Id: I7a3f9da46f5fab58978623fc2767b633b4501ca0 --- .../WebCore/Modules/filesystem/LocalFileSystem.cpp | 17 ++++++++++++++++- .../WebCore/Modules/filesystem/LocalFileSystem.h | 11 +++++++++++ .../Modules/webdatabase/DatabaseTracker.cpp | 13 +++++++++++++ .../WebCore/Modules/webdatabase/DatabaseTracker.h | 4 ++++ Source/WebCore/storage/StorageTracker.cpp | 21 +++++++++++++++++++-- Source/WebCore/storage/StorageTracker.h | 4 ++++ Source/WebKit2/UIProcess/API/efl/ewk_context.cpp | 1 + .../WebCoreSupport/WebDatabaseManager.cpp | 7 +++++++ .../WebProcess/WebCoreSupport/WebDatabaseManager.h | 4 ++++ Source/WebKit2/WebProcess/efl/WebProcessEfl.cpp | 22 ++++++++++++++-------- 10 files changed, 93 insertions(+), 11 deletions(-) diff --git a/Source/WebCore/Modules/filesystem/LocalFileSystem.cpp b/Source/WebCore/Modules/filesystem/LocalFileSystem.cpp index 75722f2..1b8030f 100644 --- a/Source/WebCore/Modules/filesystem/LocalFileSystem.cpp +++ b/Source/WebCore/Modules/filesystem/LocalFileSystem.cpp @@ -53,6 +53,20 @@ namespace WebCore { LocalFileSystem* LocalFileSystem::s_instance = 0; +#if ENABLE(TIZEN_FILE_SYSTEM) +bool LocalFileSystem::initializeLocalFileSystem(const String& basePath) +{ + // FIXME: Should initialize the quota settings as well. + ASSERT(isMainThread()); + ASSERT(!s_instance); + if (s_instance) + return false; + + OwnPtr localFileSystem = adoptPtr(new LocalFileSystem(basePath)); + s_instance = localFileSystem.leakPtr(); + return true; +} +#else void LocalFileSystem::initializeLocalFileSystem(const String& basePath) { // FIXME: Should initialize the quota settings as well. @@ -64,6 +78,7 @@ void LocalFileSystem::initializeLocalFileSystem(const String& basePath) OwnPtr localFileSystem = adoptPtr(new LocalFileSystem(basePath)); s_instance = localFileSystem.leakPtr(); } +#endif LocalFileSystem& LocalFileSystem::localFileSystem() { @@ -114,7 +129,7 @@ void LocalFileSystem::deleteFileSystem(ScriptExecutionContext* context, FileSyst #if ENABLE(TIZEN_FILE_SYSTEM) void LocalFileSystem::changeFileSystemBasePath(const String &path) { - m_basePath = SystemBasePath(path); + m_basePath.setValue(path); } #endif } // namespace diff --git a/Source/WebCore/Modules/filesystem/LocalFileSystem.h b/Source/WebCore/Modules/filesystem/LocalFileSystem.h index 9275dd7..e77616b 100644 --- a/Source/WebCore/Modules/filesystem/LocalFileSystem.h +++ b/Source/WebCore/Modules/filesystem/LocalFileSystem.h @@ -63,7 +63,11 @@ public: #if !PLATFORM(CHROMIUM) // This call is not thread-safe; must be called before any worker threads are created. +#if ENABLE(TIZEN_FILE_SYSTEM) + static bool initializeLocalFileSystem(const String&); +#else static void initializeLocalFileSystem(const String&); +#endif String fileSystemBasePath() const; #endif @@ -88,6 +92,13 @@ private: { return m_value.isolatedCopy(); } + +#if ENABLE(TIZEN_FILE_SYSTEM) + void setValue(const String& path) + { + m_value = path; + } +#endif private: String m_value; }; diff --git a/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp b/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp index 0e5793c..efaf6d6 100644 --- a/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp +++ b/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp @@ -61,6 +61,18 @@ namespace WebCore { static DatabaseTracker* staticTracker = 0; +#if ENABLE(TIZEN_SQL_DATABASE) +bool DatabaseTracker::initializeTracker(const String& databasePath) +{ + ASSERT(!staticTracker); + if (staticTracker) + return false; + + staticTracker = new DatabaseTracker(databasePath); + + return true; +} +#else void DatabaseTracker::initializeTracker(const String& databasePath) { ASSERT(!staticTracker); @@ -69,6 +81,7 @@ void DatabaseTracker::initializeTracker(const String& databasePath) staticTracker = new DatabaseTracker(databasePath); } +#endif DatabaseTracker& DatabaseTracker::tracker() { diff --git a/Source/WebCore/Modules/webdatabase/DatabaseTracker.h b/Source/WebCore/Modules/webdatabase/DatabaseTracker.h index 4ff7fa2..30f02cb 100644 --- a/Source/WebCore/Modules/webdatabase/DatabaseTracker.h +++ b/Source/WebCore/Modules/webdatabase/DatabaseTracker.h @@ -59,7 +59,11 @@ struct SecurityOriginTraits; class DatabaseTracker { WTF_MAKE_NONCOPYABLE(DatabaseTracker); WTF_MAKE_FAST_ALLOCATED; public: +#if ENABLE(TIZEN_SQL_DATABASE) + static bool initializeTracker(const String& databasePath); +#else static void initializeTracker(const String& databasePath); +#endif static DatabaseTracker& tracker(); // This singleton will potentially be used from multiple worker threads and the page's context thread simultaneously. To keep this safe, it's // currently using 4 locks. In order to avoid deadlock when taking multiple locks, you must take them in the correct order: diff --git a/Source/WebCore/storage/StorageTracker.cpp b/Source/WebCore/storage/StorageTracker.cpp index 0bb34b0..fb7c28b 100644 --- a/Source/WebCore/storage/StorageTracker.cpp +++ b/Source/WebCore/storage/StorageTracker.cpp @@ -49,18 +49,35 @@ static StorageTracker* storageTracker = 0; // If there is no document referencing a storage database, close the underlying database // after it has been idle for m_StorageDatabaseIdleInterval seconds. static const double DefaultStorageDatabaseIdleInterval = 300; - + +#if ENABLE(TIZEN_WEB_STORAGE) +bool StorageTracker::initializeTracker(const String& storagePath, StorageTrackerClient* client) +{ + ASSERT(isMainThread()); + + if (storageTracker) + return false; + else + storageTracker = new StorageTracker(storagePath); + + storageTracker->m_client = client; + storageTracker->m_needsInitialization = true; + + return true; +} +#else void StorageTracker::initializeTracker(const String& storagePath, StorageTrackerClient* client) { ASSERT(isMainThread()); ASSERT(!storageTracker || !storageTracker->m_client); - + if (!storageTracker) storageTracker = new StorageTracker(storagePath); storageTracker->m_client = client; storageTracker->m_needsInitialization = true; } +#endif void StorageTracker::internalInitialize() { diff --git a/Source/WebCore/storage/StorageTracker.h b/Source/WebCore/storage/StorageTracker.h index ea3a38f..4f7ae22 100644 --- a/Source/WebCore/storage/StorageTracker.h +++ b/Source/WebCore/storage/StorageTracker.h @@ -44,7 +44,11 @@ class StorageTracker { WTF_MAKE_NONCOPYABLE(StorageTracker); WTF_MAKE_FAST_ALLOCATED; public: +#if ENABLE(TIZEN_WEB_STORAGE) + static bool initializeTracker(const String& storagePath, StorageTrackerClient*); +#else static void initializeTracker(const String& storagePath, StorageTrackerClient*); +#endif static StorageTracker& tracker(); void setDatabaseDirectoryPath(const String&); diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp index 40a0038..7b8b70f 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp @@ -1719,6 +1719,7 @@ void ewk_context_storage_path_reset(Ewk_Context* ewkContext) #if ENABLE(TIZEN_RESET_PATH) EINA_SAFETY_ON_NULL_RETURN(ewkContext); + TIZEN_LOGI("ewkContext (%p)", ewkContext); WKContextResetStoragePath(ewk_context_WKContext_get(ewkContext)); #else UNUSED_PARAM(ewkContext); diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp index b39a27a..4ce5628 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp @@ -48,10 +48,17 @@ WebDatabaseManager& WebDatabaseManager::shared() return shared; } +#if ENABLE(TIZEN_SQL_DATABASE) +bool WebDatabaseManager::initialize(const String& databaseDirectory) +{ + return DatabaseTracker::initializeTracker(databaseDirectory); +} +#else void WebDatabaseManager::initialize(const String& databaseDirectory) { DatabaseTracker::initializeTracker(databaseDirectory); } +#endif WebDatabaseManager::WebDatabaseManager() { diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h index c51d390..0d78f46 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h @@ -45,7 +45,11 @@ class WebDatabaseManager : public WebCore::DatabaseTrackerClient { WTF_MAKE_NONCOPYABLE(WebDatabaseManager); public: static WebDatabaseManager& shared(); +#if ENABLE(TIZEN_SQL_DATABASE) + static bool initialize(const String& databaseDirectory); +#else static void initialize(const String& databaseDirectory); +#endif void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*); void setQuotaForOrigin(const String& originIdentifier, unsigned long long quota) const; diff --git a/Source/WebKit2/WebProcess/efl/WebProcessEfl.cpp b/Source/WebKit2/WebProcess/efl/WebProcessEfl.cpp index 613aef1..a7570b2 100755 --- a/Source/WebKit2/WebProcess/efl/WebProcessEfl.cpp +++ b/Source/WebKit2/WebProcess/efl/WebProcessEfl.cpp @@ -67,6 +67,8 @@ #endif #if ENABLE(TIZEN_RESET_PATH) +#include "WebDatabaseManager.h" +#include "WebKeyValueStorageManager.h" #include "WebPage.h" #include #include @@ -394,18 +396,22 @@ void WebProcess::setTizenExtensibleAPI(int extensibleAPI, bool enable) #if ENABLE(TIZEN_RESET_PATH) void WebProcess::resetStoragePath() { - WebCore::cacheStorage().setCacheDirectory(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subAppcache")); - WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subDatabases")); - WebCore::LocalFileSystem::localFileSystem().changeFileSystemBasePath(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subLocalFileSystem")); - WebCore::StorageTracker::tracker().setDatabaseDirectoryPath(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subLocalStorage")); + WebCore::cacheStorage().setCacheDirectory(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/appcache")); + if (!WebCore::LocalFileSystem::initializeLocalFileSystem(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localFileSystem"))) + WebCore::LocalFileSystem::localFileSystem().changeFileSystemBasePath(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localFileSystem")); + if (!WebCore::StorageTracker::initializeTracker(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localStorage"), &WebKeyValueStorageManager::shared())) + WebCore::StorageTracker::tracker().setDatabaseDirectoryPath(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localStorage")); + if (!WebDatabaseManager::initialize(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/databases"))) + WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/databases")); + HashMap >::iterator end = m_pageMap.end(); for (HashMap >::iterator it = m_pageMap.begin(); it != end; ++it) { WebPage* page = (*it).second.get(); - page->setIndexedDatabaseDirectory(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subIndexedDatabases")); - page->setLocalStorageDirectory(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subLocalStorage")); + page->setIndexedDatabaseDirectory(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/indexedDatabases")); + page->setLocalStorageDirectory(WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localStorage")); } - m_indexedDatabaseDirectory = WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subIndexedDatabases"); - m_localStorageDirectory = WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/subLocalStorage"); + m_indexedDatabaseDirectory = WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/indexedDatabases"); + m_localStorageDirectory = WebCore::pathByAppendingComponent(WebCore::homeDirectoryPath(), ".webkit/localStorage"); } #endif } // namespace WebKit -- 2.7.4