+2012-07-03 Charles Wei <charles.wei@torchmobile.com.cn>
+
+ IndexedDB: should make the LevelDB persistant to the directory indicated in PageGroupSettings::indexedDBDataBasePath
+ https://bugs.webkit.org/show_bug.cgi?id=88338
+
+ Reviewed by David Levin.
+
+ If the indexedDB runs in main thread it can access the GroupSettings via the document;
+ otherwise, we need to pass the page GroupSettings to the worker thread so that accessible
+ to the indexedDB running in WorkerContext.
+
+ * Modules/indexeddb/IDBFactory.cpp:
+ (WebCore::IDBFactory::open):
+ * workers/DedicatedWorkerThread.cpp:
+ (WebCore::DedicatedWorkerThread::create):
+ (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
+ * workers/DedicatedWorkerThread.h:
+ (DedicatedWorkerThread):
+ * workers/DefaultSharedWorkerRepository.cpp:
+ (SharedWorkerProxy):
+ (WebCore::SharedWorkerProxy::groupSettings):
+ (WebCore):
+ (WebCore::DefaultSharedWorkerRepository::workerScriptLoaded):
+ * workers/SharedWorkerThread.cpp:
+ (WebCore::SharedWorkerThread::create):
+ (WebCore::SharedWorkerThread::SharedWorkerThread):
+ * workers/SharedWorkerThread.h:
+ (SharedWorkerThread):
+ * workers/WorkerMessagingProxy.cpp:
+ (WebCore::WorkerMessagingProxy::startWorkerContext):
+ * workers/WorkerThread.cpp:
+ (WebCore::WorkerThreadStartupData::create):
+ (WorkerThreadStartupData):
+ (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
+ (WebCore::WorkerThread::WorkerThread):
+ (WebCore::WorkerThread::groupSettings):
+ (WebCore):
+ * workers/WorkerThread.h:
+ (WorkerThread):
+
2012-07-03 Balazs Kelemen <kbalazs@webkit.org>
[Qt][WK2] fast/viewport/viewport-91.html still fails after r121555 and r121661
return 0;
Frame* frame = document->frame();
RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
- m_backend->open(name, request.get(), context->securityOrigin(), frame, String());
+ m_backend->open(name, request.get(), context->securityOrigin(), frame, document->page()->group().groupSettings()->indexedDBDatabasePath());
return request;
}
#if ENABLE(WORKERS)
RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
- m_backend->openFromWorker(name, request.get(), context->securityOrigin(), static_cast<WorkerContext*>(context), String());
+ WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+ GroupSettings* groupSettings = workerContext->thread()->groupSettings();
+ m_backend->openFromWorker(name, request.get(), context->securityOrigin(), workerContext, groupSettings ? groupSettings->indexedDBDatabasePath() : String());
return request;
#else
return 0;
namespace WebCore {
-PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
{
- return adoptRef(new DedicatedWorkerThread(scriptURL, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType));
+ return adoptRef(new DedicatedWorkerThread(scriptURL, userAgent, settings, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType));
}
-DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
- : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)
+DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+ : WorkerThread(url, userAgent, settings, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)
, m_workerObjectProxy(workerObjectProxy)
{
}
class DedicatedWorkerThread : public WorkerThread {
public:
- static PassRefPtr<DedicatedWorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
+ static PassRefPtr<DedicatedWorkerThread> create(const KURL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
~DedicatedWorkerThread();
virtual void runEventLoop();
private:
- DedicatedWorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
+ DedicatedWorkerThread(const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
WorkerObjectProxy& m_workerObjectProxy;
};
#include "MessageEvent.h"
#include "MessagePort.h"
#include "NotImplemented.h"
+#include "PageGroup.h"
#include "PlatformString.h"
#include "ScriptCallStack.h"
#include "SecurityOrigin.h"
// Removes a detached document from the list of worker's documents. May set the closing flag if this is the last document in the list.
void documentDetached(Document*);
+ GroupSettings* groupSettings() const; // Page GroupSettings used by worker thread.
+
private:
SharedWorkerProxy(const String& name, const KURL&, PassRefPtr<SecurityOrigin>);
void close();
return true;
}
+GroupSettings* SharedWorkerProxy::groupSettings() const
+{
+ if (isClosing())
+ return 0;
+ ASSERT(m_workerDocuments.size());
+ // Just pick the first active document, and use the groupsettings of that page.
+ Document* document = *(m_workerDocuments.begin());
+ if (document->page())
+ return document->page()->group().groupSettings();
+
+ return 0;
+}
+
static void postExceptionTask(ScriptExecutionContext* context, const String& errorMessage, int lineNumber, const String& sourceURL)
{
context->reportException(errorMessage, lineNumber, sourceURL, 0);
// Another loader may have already started up a thread for this proxy - if so, just send a connect to the pre-existing thread.
if (!proxy.thread()) {
- RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, workerScript, proxy, proxy, DontPauseWorkerContextOnStart, contentSecurityPolicy, contentSecurityPolicyType);
+ RefPtr<SharedWorkerThread> thread = SharedWorkerThread::create(proxy.name(), proxy.url(), userAgent, proxy.groupSettings(), workerScript, proxy, proxy, DontPauseWorkerContextOnStart, contentSecurityPolicy, contentSecurityPolicyType);
proxy.setThread(thread);
thread->start();
}
namespace WebCore {
-PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+PassRefPtr<SharedWorkerThread> SharedWorkerThread::create(const String& name, const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
{
- return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType));
+ return adoptRef(new SharedWorkerThread(name, scriptURL, userAgent, settings, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType));
}
-SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
- : WorkerThread(url, userAgent, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)
+SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+ : WorkerThread(url, userAgent, settings, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)
, m_name(name.isolatedCopy())
{
}
class SharedWorkerThread : public WorkerThread {
public:
- static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
+ static PassRefPtr<SharedWorkerThread> create(const String& name, const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
~SharedWorkerThread();
protected:
virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String&, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
private:
- SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
+ SharedWorkerThread(const String& name, const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
String m_name;
};
#include "InspectorInstrumentation.h"
#include "MessageEvent.h"
#include "NotImplemented.h"
+#include "PageGroup.h"
#include "ScriptCallStack.h"
#include "ScriptExecutionContext.h"
#include "Worker.h"
void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode)
{
- RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode,
+ // FIXME: This need to be revisited when we support nested worker one day
+ ASSERT(m_scriptExecutionContext->isDocument());
+ Document* document = static_cast<Document*>(m_scriptExecutionContext.get());
+ GroupSettings* settings = 0;
+ if (document->page())
+ settings = document->page()->group().groupSettings();
+ RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode,
m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeader(),
m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeaderType());
workerThreadCreated(thread);
struct WorkerThreadStartupData {
WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED;
public:
- static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+ static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
{
- return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType));
+ return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType));
}
KURL m_scriptURL;
String m_userAgent;
+ OwnPtr<GroupSettings> m_groupSettings;
String m_sourceCode;
WorkerThreadStartMode m_startMode;
String m_contentSecurityPolicy;
ContentSecurityPolicy::HeaderType m_contentSecurityPolicyType;
private:
- WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType);
+ WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType);
};
-WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
: m_scriptURL(scriptURL.copy())
, m_userAgent(userAgent.isolatedCopy())
, m_sourceCode(sourceCode.isolatedCopy())
, m_contentSecurityPolicy(contentSecurityPolicy.isolatedCopy())
, m_contentSecurityPolicyType(contentSecurityPolicyType)
{
+ if (!settings)
+ return;
+
+ m_groupSettings = GroupSettings::create();
+ m_groupSettings->setLocalStorageQuotaBytes(settings->localStorageQuotaBytes());
+ m_groupSettings->setIndexedDBQuotaBytes(settings->indexedDBQuotaBytes());
+ m_groupSettings->setIndexedDBDatabasePath(settings->indexedDBDatabasePath().isolatedCopy());
}
-WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
: m_threadID(0)
, m_workerLoaderProxy(workerLoaderProxy)
, m_workerReportingProxy(workerReportingProxy)
- , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType))
+ , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType))
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
, m_notificationClient(0)
#endif
m_runLoop.run(m_workerContext.get());
}
+GroupSettings* WorkerThread::groupSettings()
+{
+ return m_startupData->m_groupSettings.get();
+}
+
class WorkerThreadShutdownFinishTask : public ScriptExecutionContext::Task {
public:
static PassOwnPtr<WorkerThreadShutdownFinishTask> create()
#if ENABLE(WORKERS)
#include "ContentSecurityPolicy.h"
+#include "GroupSettings.h"
#include "WorkerRunLoop.h"
#include <wtf/Forward.h>
#include <wtf/OwnPtr.h>
// Number of active worker threads.
static unsigned workerThreadCount();
+ GroupSettings* groupSettings();
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
NotificationClient* getNotificationClient() { return m_notificationClient; }
#endif
protected:
- WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
+ WorkerThread(const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
// Factory method for creating a new worker context for the thread.
virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType) = 0;
+2012-07-03 Charles Wei <charles.wei@torchmobile.com.cn>
+
+ IndexedDB: should make the LevelDB persistant to the directory indicated in PageGroupSettings::indexedDBDataBasePath
+ https://bugs.webkit.org/show_bug.cgi?id=88338
+
+ Reviewed by David Levin.
+
+ * src/WebSharedWorkerImpl.cpp:
+ (WebKit::WebSharedWorkerImpl::startWorkerContext):
+ * src/WebWorkerClientImpl.cpp:
+ (WebKit::WebWorkerClientImpl::startWorkerContext):
+
2012-07-02 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed. Rolled DEPS.
#include "CrossThreadTask.h"
#include "DatabaseTask.h"
#include "Document.h"
+#include "GroupSettings.h"
#include "KURL.h"
#include "MessageEvent.h"
#include "MessagePortChannel.h"
+#include "Page.h"
+#include "PageGroup.h"
#include "PlatformMessagePortChannel.h"
#include "SecurityOrigin.h"
#include "ScriptExecutionContext.h"
{
initializeLoader(url);
WorkerThreadStartMode startMode = m_pauseWorkerContextOnStart ? PauseWorkerContextOnStart : DontPauseWorkerContextOnStart;
- setWorkerThread(SharedWorkerThread::create(name, url, userAgent, sourceCode, *this, *this, startMode, contentSecurityPolicy,
+ ASSERT(m_loadingDocument->isDocument());
+ Document* document = static_cast<Document*>(m_loadingDocument.get());
+ GroupSettings* settings = 0;
+ if (document->page())
+ settings = document->page()->group().groupSettings();
+ setWorkerThread(SharedWorkerThread::create(name, url, userAgent, settings,
+ sourceCode, *this, *this, startMode, contentSecurityPolicy,
static_cast<WebCore::ContentSecurityPolicy::HeaderType>(policyType)));
workerThread()->start();
#include "ErrorEvent.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
+#include "GroupSettings.h"
#include "InspectorInstrumentation.h"
#include "MessageEvent.h"
#include "MessagePort.h"
#include "MessagePortChannel.h"
+#include "Page.h"
+#include "PageGroup.h"
#include "ScriptCallStack.h"
#include "ScriptExecutionContext.h"
#include "Worker.h"
void WebWorkerClientImpl::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode startMode)
{
- RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, sourceCode, *this, *this, startMode,
+ ASSERT(m_scriptExecutionContext->isDocument());
+ Document* document = static_cast<Document*>(m_scriptExecutionContext.get());
+ GroupSettings* settings = 0;
+ if (document->page())
+ settings = document->page()->group().groupSettings();
+ RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode,
m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeader(),
m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeaderType());
m_proxy->workerThreadCreated(thread);