[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
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.
OwnPtr<LocalFileSystem> localFileSystem = adoptPtr(new LocalFileSystem(basePath));
s_instance = localFileSystem.leakPtr();
}
+#endif
LocalFileSystem& LocalFileSystem::localFileSystem()
{
#if ENABLE(TIZEN_FILE_SYSTEM)
void LocalFileSystem::changeFileSystemBasePath(const String &path)
{
- m_basePath = SystemBasePath(path);
+ m_basePath.setValue(path);
}
#endif
} // namespace
#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
{
return m_value.isolatedCopy();
}
+
+#if ENABLE(TIZEN_FILE_SYSTEM)
+ void setValue(const String& path)
+ {
+ m_value = path;
+ }
+#endif
private:
String m_value;
};
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);
staticTracker = new DatabaseTracker(databasePath);
}
+#endif
DatabaseTracker& DatabaseTracker::tracker()
{
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:
// 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()
{
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&);
#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);
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()
{
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;
#endif
#if ENABLE(TIZEN_RESET_PATH)
+#include "WebDatabaseManager.h"
+#include "WebKeyValueStorageManager.h"
#include "WebPage.h"
#include <WebCore/ApplicationCacheStorage.h>
#include <WebCore/DatabaseTracker.h>
#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