WebProcess crash is occured during changing default directory path for file system
authorJiyeon Kim <jiyeon0402.kim@samsung.com>
Fri, 22 Mar 2013 06:47:51 +0000 (15:47 +0900)
committerJiyeon Kim <jiyeon0402.kim@samsung.com>
Tue, 26 Mar 2013 07:48:34 +0000 (16:48 +0900)
[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

Source/WebCore/Modules/filesystem/LocalFileSystem.cpp
Source/WebCore/Modules/filesystem/LocalFileSystem.h
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.h
Source/WebCore/storage/StorageTracker.cpp
Source/WebCore/storage/StorageTracker.h
Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h
Source/WebKit2/WebProcess/efl/WebProcessEfl.cpp

index 75722f2..1b8030f 100644 (file)
@@ -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> 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> 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
index 9275dd7..e77616b 100644 (file)
@@ -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;
     };
index 0e5793c..efaf6d6 100644 (file)
@@ -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()
 {
index 4ff7fa2..30f02cb 100644 (file)
@@ -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:
index 0bb34b0..fb7c28b 100644 (file)
@@ -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()
 {
index ea3a38f..4f7ae22 100644 (file)
@@ -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&);
index 40a0038..7b8b70f 100755 (executable)
@@ -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);
index b39a27a..4ce5628 100644 (file)
@@ -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()
 {
index c51d390..0d78f46 100644 (file)
@@ -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;
index 613aef1..a7570b2 100755 (executable)
@@ -67,6 +67,8 @@
 #endif
 
 #if ENABLE(TIZEN_RESET_PATH)
+#include "WebDatabaseManager.h"
+#include "WebKeyValueStorageManager.h"
 #include "WebPage.h"
 #include <WebCore/ApplicationCacheStorage.h>
 #include <WebCore/DatabaseTracker.h>
@@ -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<uint64_t, RefPtr<WebPage> >::iterator end = m_pageMap.end();
     for (HashMap<uint64_t, RefPtr<WebPage> >::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