Commit d01d91f8 authored by tkent@chromium.org's avatar tkent@chromium.org

Web SQL: Remove more worker-related code.

- Drop worker support from DatabaseClient.
- Remove WorkerGlobalScope support of DatabaseContext::allowDatabaseAccess.

BUG=397429
TEST=none; No behavior changes.

Review URL: https://codereview.chromium.org/564713002

git-svn-id: svn://svn.chromium.org/blink/trunk@181857 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f0f4a144
......@@ -29,12 +29,11 @@
*/
#include "config.h"
#include "DatabaseClient.h"
#include "modules/webdatabase/DatabaseClient.h"
#include "core/dom/Document.h"
#include "core/inspector/InspectorController.h"
#include "core/page/Page.h"
#include "core/workers/WorkerGlobalScope.h"
#include "modules/webdatabase/Database.h"
#include "modules/webdatabase/InspectorDatabaseAgent.h"
......@@ -46,11 +45,7 @@ DatabaseClient::DatabaseClient()
DatabaseClient* DatabaseClient::from(ExecutionContext* context)
{
if (context->isDocument()) {
return static_cast<DatabaseClient*>(WillBeHeapSupplement<Page>::from(toDocument(context)->page(), supplementName()));
}
ASSERT(context->isWorkerGlobalScope());
return static_cast<DatabaseClient*>(WillBeHeapSupplement<WorkerClients>::from(toWorkerGlobalScope(context)->clients(), supplementName()));
return static_cast<DatabaseClient*>(WillBeHeapSupplement<Page>::from(toDocument(context)->page(), supplementName()));
}
const char* DatabaseClient::supplementName()
......@@ -79,9 +74,4 @@ void provideDatabaseClientTo(Page& page, PassOwnPtrWillBeRawPtr<DatabaseClient>
clientPtr->createInspectorAgentFor(&page);
}
void provideDatabaseClientToWorker(WorkerClients* workerClients, PassOwnPtrWillBeRawPtr<DatabaseClient> client)
{
workerClients->provideSupplement(DatabaseClient::supplementName(), client);
}
} // namespace blink
......@@ -31,7 +31,7 @@
#ifndef DatabaseClient_h
#define DatabaseClient_h
#include "core/workers/WorkerClients.h"
#include "platform/Supplementable.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
......@@ -41,9 +41,8 @@ class Database;
class ExecutionContext;
class InspectorDatabaseAgent;
class Page;
class WorkerClients;
class DatabaseClient : public WillBeHeapSupplement<Page>, public WillBeHeapSupplement<WorkerClients> {
class DatabaseClient : public WillBeHeapSupplement<Page> {
WTF_MAKE_NONCOPYABLE(DatabaseClient);
public:
DatabaseClient();
......@@ -58,18 +57,11 @@ public:
void createInspectorAgentFor(Page*);
virtual void trace(Visitor* visitor) OVERRIDE
{
WillBeHeapSupplement<Page>::trace(visitor);
WillBeHeapSupplement<WorkerClients>::trace(visitor);
}
private:
InspectorDatabaseAgent* m_inspectorAgent;
};
void provideDatabaseClientTo(Page&, PassOwnPtrWillBeRawPtr<DatabaseClient>);
void provideDatabaseClientToWorker(WorkerClients*, PassOwnPtrWillBeRawPtr<DatabaseClient>);
} // namespace blink
......
......@@ -134,9 +134,9 @@ void DatabaseContext::contextDestroyed()
ActiveDOMObject::contextDestroyed();
}
// stop() is from stopActiveDOMObjects() which indicates that the owner LocalFrame
// or WorkerThread is shutting down. Initiate the orderly shutdown by stopping
// the associated databases.
// stop() is from stopActiveDOMObjects() which indicates that the owner
// LocalFrame is shutting down. Initiate the orderly shutdown by stopping the
// associated databases.
void DatabaseContext::stop()
{
stopDatabases();
......@@ -187,11 +187,7 @@ void DatabaseContext::stopDatabases()
bool DatabaseContext::allowDatabaseAccess() const
{
if (executionContext()->isDocument())
return toDocument(executionContext())->isActive();
ASSERT(executionContext()->isWorkerGlobalScope());
// allowDatabaseAccess is not yet implemented for workers.
return true;
return toDocument(executionContext())->isActive();
}
SecurityOrigin* DatabaseContext::securityOrigin() const
......
......@@ -29,7 +29,6 @@
#define DatabaseContext_h
#include "core/dom/ActiveDOMObject.h"
#include "core/workers/WorkerGlobalScope.h"
#include "platform/heap/Handle.h"
#include "wtf/PassRefPtr.h"
#include "wtf/ThreadSafeRefCounted.h"
......
......@@ -43,6 +43,7 @@
#include "modules/webdatabase/DatabaseServer.h"
#include "modules/webdatabase/DatabaseTask.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "wtf/MainThread.h"
namespace blink {
......
......@@ -33,10 +33,8 @@
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/workers/WorkerGlobalScope.h"
#include "public/web/WebPermissionClient.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WorkerPermissionClient.h"
namespace blink {
......@@ -52,18 +50,12 @@ DatabaseClientImpl::~DatabaseClientImpl()
bool DatabaseClientImpl::allowDatabase(ExecutionContext* executionContext, const String& name, const String& displayName, unsigned long estimatedSize)
{
ASSERT(executionContext->isContextThread());
ASSERT(executionContext->isDocument() || executionContext->isWorkerGlobalScope());
if (executionContext->isDocument()) {
Document* document = toDocument(executionContext);
WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame());
if (!webFrame)
return false;
if (webFrame->permissionClient())
return webFrame->permissionClient()->allowDatabase(name, displayName, estimatedSize);
} else {
WorkerGlobalScope& workerGlobalScope = *toWorkerGlobalScope(executionContext);
return WorkerPermissionClient::from(workerGlobalScope)->allowDatabase(name, displayName, estimatedSize);
}
Document* document = toDocument(executionContext);
WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame());
if (!webFrame)
return false;
if (webFrame->permissionClient())
return webFrame->permissionClient()->allowDatabase(name, displayName, estimatedSize);
return true;
}
......
......@@ -49,7 +49,6 @@
#include "core/workers/WorkerInspectorProxy.h"
#include "core/workers/WorkerScriptLoader.h"
#include "core/workers/WorkerThreadStartupData.h"
#include "modules/webdatabase/DatabaseTask.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/heap/Handle.h"
#include "platform/network/ContentSecurityPolicyParsers.h"
......@@ -66,7 +65,6 @@
#include "public/web/WebSettings.h"
#include "public/web/WebView.h"
#include "public/web/WebWorkerPermissionClientProxy.h"
#include "web/DatabaseClientImpl.h"
#include "web/LocalFileSystemClient.h"
#include "web/WebDataSourceImpl.h"
#include "web/WebLocalFrameImpl.h"
......@@ -398,7 +396,6 @@ void WebSharedWorkerImpl::onScriptLoaderFinished()
OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create();
provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::create());
provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::create());
WebSecurityOrigin webSecurityOrigin(m_loadingDocument->securityOrigin());
providePermissionClientToWorker(workerClients.get(), adoptPtr(client()->createWorkerPermissionClientProxy(webSecurityOrigin)));
OwnPtrWillBeRawPtr<WorkerThreadStartupData> startupData = WorkerThreadStartupData::create(m_url, m_loadingDocument->userAgent(m_url), m_mainScriptLoader->script(), startMode, m_contentSecurityPolicy, static_cast<ContentSecurityPolicyHeaderType>(m_policyType), workerClients.release());
......
......@@ -42,7 +42,6 @@
#include "public/web/WebFrameClient.h"
#include "public/web/WebPermissionClient.h"
#include "public/web/WebWorkerPermissionClientProxy.h"
#include "web/DatabaseClientImpl.h"
#include "web/LocalFileSystemClient.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
......@@ -57,7 +56,6 @@ WorkerGlobalScopeProxy* WorkerGlobalScopeProxyProviderImpl::createWorkerGlobalSc
WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame());
OwnPtrWillBeRawPtr<WorkerClients> workerClients = WorkerClients::create();
provideLocalFileSystemToWorker(workerClients.get(), LocalFileSystemClient::create());
provideDatabaseClientToWorker(workerClients.get(), DatabaseClientImpl::create());
providePermissionClientToWorker(workerClients.get(), adoptPtr(webFrame->client()->createWorkerPermissionClientProxy(webFrame)));
provideServiceWorkerContainerClientToWorker(workerClients.get(), adoptPtr(webFrame->client()->createServiceWorkerProvider(webFrame)));
return new WorkerMessagingProxy(worker, workerClients.release());
......
......@@ -48,13 +48,6 @@ WorkerPermissionClient::~WorkerPermissionClient()
{
}
bool WorkerPermissionClient::allowDatabase(const WebString& name, const WebString& displayName, unsigned long estimatedSize)
{
if (!m_proxy)
return true;
return m_proxy->allowDatabase(name, displayName, estimatedSize);
}
bool WorkerPermissionClient::requestFileSystemAccessSync()
{
if (!m_proxy)
......
......@@ -48,7 +48,6 @@ public:
static PassOwnPtrWillBeRawPtr<WorkerPermissionClient> create(PassOwnPtr<WebWorkerPermissionClientProxy>);
virtual ~WorkerPermissionClient();
bool allowDatabase(const WebString& name, const WebString& displayName, unsigned long estimatedSize);
bool requestFileSystemAccessSync();
bool allowIndexedDB(const WebString& name);
......
......@@ -46,6 +46,7 @@ class WebWorkerPermissionClientProxy {
public:
virtual ~WebWorkerPermissionClientProxy() { }
// Deprecated: This function should be removed.
virtual bool allowDatabase(const WebString& name, const WebString& displayName, unsigned long estimatedSize)
{
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment