Diff
Modified: trunk/LayoutTests/ChangeLog (122514 => 122515)
--- trunk/LayoutTests/ChangeLog 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/LayoutTests/ChangeLog 2012-07-12 22:19:10 UTC (rev 122515)
@@ -1,3 +1,18 @@
+2012-07-12 Joshua Bell <[email protected]>
+
+ IndexedDB: Enable IDBFactory.deleteDatabase() and webkitGetDatabaseNames() in Workers
+ https://bugs.webkit.org/show_bug.cgi?id=90310
+
+ Reviewed by Tony Chang.
+
+ * storage/indexeddb/factory-basics-workers-expected.txt: Added.
+ * storage/indexeddb/factory-basics-workers.html: Added.
+ * storage/indexeddb/resources/factory-basics.js: Allow use by Worker as well as Window.
+ (getDatabaseNamesSuccess1):
+ (openSuccess):
+ (getDatabaseNamesSuccess2):
+ (getDatabaseNamesSuccess3):
+
2012-07-12 Dirk Pranke <[email protected]>
rebaseline fast/harness/results.html after r122505.
Added: trunk/LayoutTests/storage/indexeddb/factory-basics-workers-expected.txt (0 => 122515)
--- trunk/LayoutTests/storage/indexeddb/factory-basics-workers-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/factory-basics-workers-expected.txt 2012-07-12 22:19:10 UTC (rev 122515)
@@ -0,0 +1,33 @@
+[Worker] Test the basics of IndexedDB's IDBFactory.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Starting worker: resources/factory-basics.js
+[Worker] indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+[Worker]
+PASS [Worker] typeof indexedDB.open is "function"
+PASS [Worker] typeof indexedDB.cmp is "function"
+PASS [Worker] typeof indexedDB.deleteDatabase is "function"
+PASS [Worker] typeof indexedDB.webkitGetDatabaseNames is "function"
+PASS [Worker] typeof indexedDB.getDatabaseNames is "undefined"
+[Worker] indexedDB.webkitGetDatabaseNames()
+[Worker] databaseNames = event.target.result
+PASS [Worker] databaseNames.contains('storage/indexeddb/factory-basics') is false
+PASS [Worker] databaseNames.contains('DATABASE THAT DOES NOT EXIST') is false
+[Worker] indexedDB.open(name)
+[Worker] event.target.result.close()
+[Worker] indexedDB.webkitGetDatabaseNames()
+[Worker] databaseNames = event.target.result
+PASS [Worker] databaseNames.contains('storage/indexeddb/factory-basics') is true
+PASS [Worker] databaseNames.contains('DATABASE THAT DOES NOT EXIST') is false
+[Worker] indexedDB.deleteDatabase('storage/indexeddb/factory-basics')
+[Worker] indexedDB.webkitGetDatabaseNames()
+[Worker] databaseNames = event.target.result
+PASS [Worker] databaseNames.contains('storage/indexeddb/factory-basics') is false
+PASS [Worker] databaseNames.contains('DATABASE THAT DOES NOT EXIST') is false
+[Worker] indexedDB.deleteDatabase('DATABASE THAT DOES NOT EXIST')
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/indexeddb/factory-basics-workers.html (0 => 122515)
--- trunk/LayoutTests/storage/indexeddb/factory-basics-workers.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/factory-basics-workers.html 2012-07-12 22:19:10 UTC (rev 122515)
@@ -0,0 +1,10 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script>startWorker('resources/factory-basics.js');</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/storage/indexeddb/resources/factory-basics.js (122514 => 122515)
--- trunk/LayoutTests/storage/indexeddb/resources/factory-basics.js 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/LayoutTests/storage/indexeddb/resources/factory-basics.js 2012-07-12 22:19:10 UTC (rev 122515)
@@ -25,8 +25,9 @@
request._onerror_ = unexpectedErrorCallback;
}
-function getDatabaseNamesSuccess1()
+function getDatabaseNamesSuccess1(evt)
{
+ event = evt;
var databaseNames;
evalAndLog("databaseNames = event.target.result");
shouldBeFalse("databaseNames.contains('" + name + "')");
@@ -37,16 +38,18 @@
request._onerror_ = unexpectedErrorCallback;
}
-function openSuccess()
+function openSuccess(evt)
{
+ event = evt;
evalAndLog("event.target.result.close()");
request = evalAndLog("indexedDB.webkitGetDatabaseNames()");
request._onsuccess_ = getDatabaseNamesSuccess2;
request._onerror_ = unexpectedErrorCallback;
}
-function getDatabaseNamesSuccess2()
+function getDatabaseNamesSuccess2(evt)
{
+ event = evt;
var databaseNames;
evalAndLog("databaseNames = event.target.result");
shouldBeTrue("databaseNames.contains('" + name + "')");
@@ -64,8 +67,9 @@
request._onerror_ = unexpectedErrorCallback;
}
-function getDatabaseNamesSuccess3()
+function getDatabaseNamesSuccess3(evt)
{
+ event = evt;
var databaseNames;
evalAndLog("databaseNames = event.target.result");
shouldBeFalse("databaseNames.contains('" + name + "')");
Modified: trunk/Source/WebCore/ChangeLog (122514 => 122515)
--- trunk/Source/WebCore/ChangeLog 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebCore/ChangeLog 2012-07-12 22:19:10 UTC (rev 122515)
@@ -1,3 +1,38 @@
+2012-07-12 Joshua Bell <[email protected]>
+
+ IndexedDB: Enable IDBFactory.deleteDatabase() and webkitGetDatabaseNames() in Workers
+ https://bugs.webkit.org/show_bug.cgi?id=90310
+
+ Reviewed by Tony Chang.
+
+ Simplify Document vs. Worker logic for IDBFactory::open() and hook up the
+ other two IDBFactory methods for use by workers as well.
+
+ Test: storage/indexeddb/factory-basics-workers.html
+
+ * Modules/indexeddb/IDBFactory.cpp:
+ (isContextValid): Helper function consolidating checks that context is usable.
+ (getIndexedDBDatabasePath): Helper function for accessing group settings.
+ (WebCore::IDBFactory::getDatabaseNames): Simplify - just pass context through to back end.
+ (WebCore::IDBFactory::open): Ditto.
+ (WebCore::IDBFactory::deleteDatabase): Ditto.
+ (WebCore::IDBFactory::cmp): Whitespace.
+ * Modules/indexeddb/IDBFactoryBackendImpl.cpp: Obsolete openFromWorker() removed.
+ (WebCore::IDBFactoryBackendImpl::getDatabaseNames): Signature updated.
+ (WebCore::IDBFactoryBackendImpl::deleteDatabase): Signature updated.
+ (WebCore::IDBFactoryBackendImpl::open): Signature updated.
+ * Modules/indexeddb/IDBFactoryBackendImpl.h:
+ (IDBFactoryBackendImpl):
+ * Modules/indexeddb/IDBFactoryBackendInterface.h: Interface methods now take both SecurityOrigin
+ and ScriptExecutionContext, but not Frame. In the proxy, SecurityOrigin is redundant (can be
+ accessed from context) but on the real back end the context is null (as Frame was previously).
+ (IDBFactoryBackendInterface):
+ * inspector/InspectorIndexedDBAgent.cpp:
+ (WebCore):
+ (WebCore::InspectorIndexedDBAgent::requestDatabaseNamesForFrame):
+ (WebCore::InspectorIndexedDBAgent::requestDatabase):
+ (WebCore::InspectorIndexedDBAgent::requestData):
+
2012-07-12 Dana Jansens <[email protected]>
[chromium] The root layer should not try create a second RenderSurface for itself
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (122514 => 122515)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2012-07-12 22:19:10 UTC (rev 122515)
@@ -63,70 +63,73 @@
{
}
-PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* context)
+namespace {
+static bool isContextValid(ScriptExecutionContext* context)
{
- if (!context->isDocument()) {
- // FIXME: make this work with workers.
- return 0;
+ ASSERT(context->isDocument() || context->isWorkerContext());
+ if (context->isDocument()) {
+ Document* document = static_cast<Document*>(context);
+ return document->frame() && document->page();
}
+#if !ENABLE(WORKERS)
+ if (context->isWorkerContext())
+ return false;
+#endif
+ return true;
+}
- Document* document = static_cast<Document*>(context);
- if (!document->frame() || !document->page())
+static String getIndexedDBDatabasePath(ScriptExecutionContext* context)
+{
+ ASSERT(isContextValid(context));
+ if (context->isDocument()) {
+ Document* document = static_cast<Document*>(context);
+ return document->page()->group().groupSettings()->indexedDBDatabasePath();
+ }
+#if ENABLE(WORKERS)
+ WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+ const GroupSettings* groupSettings = workerContext->groupSettings();
+ if (groupSettings)
+ return groupSettings->indexedDBDatabasePath();
+#endif
+ return String();
+}
+}
+
+PassRefPtr<IDBRequest> IDBFactory::getDatabaseNames(ScriptExecutionContext* context)
+{
+ if (!isContextValid(context))
return 0;
- RefPtr<IDBRequest> request = IDBRequest::create(document, IDBAny::create(this), 0);
- GroupSettings* groupSettings = document->page()->group().groupSettings();
- m_backend->getDatabaseNames(request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+ RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
+ m_backend->getDatabaseNames(request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
return request;
}
PassRefPtr<IDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
{
- ASSERT(context->isDocument() || context->isWorkerContext());
-
if (name.isNull()) {
ec = IDBDatabaseException::IDB_TYPE_ERR;
return 0;
}
- if (context->isDocument()) {
- Document* document = static_cast<Document*>(context);
- if (!document->frame() || !document->page())
- 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, document->page()->group().groupSettings()->indexedDBDatabasePath());
- return request;
- }
-#if ENABLE(WORKERS)
+ if (!isContextValid(context))
+ return 0;
+
RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
- WorkerContext* workerContext = static_cast<WorkerContext*>(context);
- const GroupSettings* groupSettings = workerContext->groupSettings();
- m_backend->openFromWorker(name, request.get(), context->securityOrigin(), workerContext, groupSettings ? groupSettings->indexedDBDatabasePath() : String());
+ m_backend->open(name, request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
return request;
-#else
- return 0;
-#endif
}
PassRefPtr<IDBVersionChangeRequest> IDBFactory::deleteDatabase(ScriptExecutionContext* context, const String& name, ExceptionCode& ec)
{
- if (!context->isDocument()) {
- // FIXME: make this work with workers.
- return 0;
- }
-
- Document* document = static_cast<Document*>(context);
- if (!document->frame() || !document->page())
- return 0;
-
if (name.isNull()) {
ec = IDBDatabaseException::IDB_TYPE_ERR;
return 0;
}
+ if (!isContextValid(context))
+ return 0;
- RefPtr<IDBVersionChangeRequest> request = IDBVersionChangeRequest::create(document, IDBAny::createNull(), "");
- GroupSettings* groupSettings = document->page()->group().groupSettings();
- m_backend->deleteDatabase(name, request, document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+ RefPtr<IDBVersionChangeRequest> request = IDBVersionChangeRequest::create(context, IDBAny::createNull(), "");
+ m_backend->deleteDatabase(name, request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
return request;
}
@@ -138,8 +141,8 @@
if (!first->isValid() || !second->isValid()) {
ec = IDBDatabaseException::DATA_ERR;
return 0;
- }
-
+ }
+
return static_cast<short>(first->compare(second.get()));
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.cpp (122514 => 122515)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.cpp 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.cpp 2012-07-12 22:19:10 UTC (rev 122515)
@@ -35,7 +35,6 @@
#include "IDBDatabaseException.h"
#include "IDBLevelDBBackingStore.h"
#include "IDBTransactionCoordinator.h"
-#include "SecurityOrigin.h"
#include <wtf/Threading.h>
#include <wtf/UnusedParam.h>
@@ -81,7 +80,7 @@
m_backingStoreMap.remove(fileIdentifier);
}
-void IDBFactoryBackendImpl::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDirectory)
+void IDBFactoryBackendImpl::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext*, const String& dataDirectory)
{
RefPtr<IDBBackingStore> backingStore = openBackingStore(securityOrigin, dataDirectory);
if (!backingStore) {
@@ -99,18 +98,8 @@
callbacks->onSuccess(databaseNames.release());
}
-void IDBFactoryBackendImpl::open(const String& name, IDBCallbacks* callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDirectory)
+void IDBFactoryBackendImpl::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext*, const String& dataDirectory)
{
- openInternal(name, callbacks, securityOrigin, dataDirectory);
-}
-
-void IDBFactoryBackendImpl::openFromWorker(const String& name, IDBCallbacks* callbacks, PassRefPtr<SecurityOrigin> securityOrigin, WorkerContext*, const String& dataDirectory)
-{
- openInternal(name, callbacks, securityOrigin, dataDirectory);
-}
-
-void IDBFactoryBackendImpl::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDirectory)
-{
const String uniqueIdentifier = computeUniqueIdentifier(name, securityOrigin.get());
IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentifier);
@@ -160,7 +149,7 @@
return 0;
}
-void IDBFactoryBackendImpl::openInternal(const String& name, IDBCallbacks* callbacks, PassRefPtr<SecurityOrigin> prpSecurityOrigin, const String& dataDirectory)
+void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> prpSecurityOrigin, ScriptExecutionContext*, const String& dataDirectory)
{
RefPtr<SecurityOrigin> securityOrigin = prpSecurityOrigin;
const String uniqueIdentifier = computeUniqueIdentifier(name, securityOrigin.get());
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.h (122514 => 122515)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.h 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendImpl.h 2012-07-12 22:19:10 UTC (rev 122515)
@@ -29,6 +29,7 @@
#define IDBFactoryBackendImpl_h
#include "IDBFactoryBackendInterface.h"
+#include "SecurityOrigin.h"
#include <wtf/HashMap.h>
#include <wtf/text/StringHash.h>
@@ -55,19 +56,15 @@
void addIDBBackingStore(const String& fileIdentifier, IDBBackingStore*);
virtual void removeIDBBackingStore(const String& fileIdentifier);
- virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir);
+ virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir);
+ virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir);
+ virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir);
- virtual void open(const String& name, IDBCallbacks*, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir);
- virtual void openFromWorker(const String& name, IDBCallbacks*, PassRefPtr<SecurityOrigin>, WorkerContext*, const String& dataDir);
- virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir);
-
protected:
IDBFactoryBackendImpl();
virtual PassRefPtr<IDBBackingStore> openBackingStore(PassRefPtr<SecurityOrigin>, const String& dataDir);
private:
- void openInternal(const String& name, IDBCallbacks*, PassRefPtr<SecurityOrigin>, const String& dataDir);
-
typedef HashMap<String, RefPtr<IDBDatabaseBackendImpl> > IDBDatabaseBackendMap;
IDBDatabaseBackendMap m_databaseBackendMap;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h (122514 => 122515)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h 2012-07-12 22:19:10 UTC (rev 122515)
@@ -53,11 +53,9 @@
static PassRefPtr<IDBFactoryBackendInterface> create();
virtual ~IDBFactoryBackendInterface() { }
- virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir) = 0;
-
- virtual void open(const String& name, IDBCallbacks*, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir) = 0;
- virtual void openFromWorker(const String& name, IDBCallbacks*, PassRefPtr<SecurityOrigin>, WorkerContext*, const String& dataDir) = 0;
- virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir) = 0;
+ virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
+ virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
+ virtual void deleteDatabase(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (122514 => 122515)
--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2012-07-12 22:19:10 UTC (rev 122515)
@@ -186,7 +186,7 @@
class ExecutableWithDatabase : public RefCounted<ExecutableWithDatabase> {
public:
virtual ~ExecutableWithDatabase() { };
- void start(IDBFactoryBackendInterface*, SecurityOrigin*, Frame*, const String& databaseName);
+ void start(IDBFactoryBackendInterface*, SecurityOrigin*, ScriptExecutionContext*, const String& databaseName);
virtual void execute(PassRefPtr<IDBDatabaseBackendInterface>) = 0;
};
@@ -233,10 +233,10 @@
RefPtr<ExecutableWithDatabase> m_executableWithDatabase;
};
-void ExecutableWithDatabase::start(IDBFactoryBackendInterface* idbFactory, SecurityOrigin* securityOrigin, Frame* frame, const String& databaseName)
+void ExecutableWithDatabase::start(IDBFactoryBackendInterface* idbFactory, SecurityOrigin* securityOrigin, ScriptExecutionContext* context, const String& databaseName)
{
RefPtr<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this);
- idbFactory->open(databaseName, callback.get(), securityOrigin, frame, String());
+ idbFactory->open(databaseName, callback.get(), securityOrigin, context, String());
}
static PassRefPtr<IDBTransactionBackendInterface> transactionForDatabase(IDBDatabaseBackendInterface* idbDatabase, const String& objectStoreName)
@@ -732,7 +732,7 @@
RefPtr<GetDatabaseNamesCallback> callback = GetDatabaseNamesCallback::create(m_frontendProvider.get(), requestId, document->securityOrigin()->toString());
GroupSettings* groupSettings = document->page()->group().groupSettings();
- idbFactory->getDatabaseNames(callback.get(), document->securityOrigin(), document->frame(), groupSettings->indexedDBDatabasePath());
+ idbFactory->getDatabaseNames(callback.get(), document->securityOrigin(), document, groupSettings->indexedDBDatabasePath());
}
void InspectorIndexedDBAgent::requestDatabase(ErrorString* errorString, int requestId, const String& frameId, const String& databaseName)
@@ -745,7 +745,7 @@
return;
RefPtr<DatabaseLoaderCallback> databaseLoaderCallback = DatabaseLoaderCallback::create(m_frontendProvider.get(), requestId);
- databaseLoaderCallback->start(idbFactory, document->securityOrigin(), document->frame(), databaseName);
+ databaseLoaderCallback->start(idbFactory, document->securityOrigin(), document, databaseName);
}
void InspectorIndexedDBAgent::requestData(ErrorString* errorString, int requestId, const String& frameId, const String& databaseName, const String& objectStoreName, const String& indexName, int skipCount, int pageSize, const RefPtr<InspectorObject>* keyRange)
@@ -769,7 +769,7 @@
}
RefPtr<DataLoaderCallback> dataLoaderCallback = DataLoaderCallback::create(m_frontendProvider, requestId, injectedScript, objectStoreName, indexName, idbKeyRange, skipCount, pageSize);
- dataLoaderCallback->start(idbFactory, document->securityOrigin(), document->frame(), databaseName);
+ dataLoaderCallback->start(idbFactory, document->securityOrigin(), document, databaseName);
}
} // namespace WebCore
Modified: trunk/Source/WebKit/chromium/ChangeLog (122514 => 122515)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-07-12 22:19:10 UTC (rev 122515)
@@ -1,3 +1,21 @@
+2012-07-12 Joshua Bell <[email protected]>
+
+ IndexedDB: Enable IDBFactory.deleteDatabase() and webkitGetDatabaseNames() in Workers
+ https://bugs.webkit.org/show_bug.cgi?id=90310
+
+ Reviewed by Tony Chang.
+
+ * src/IDBFactoryBackendProxy.cpp:
+ (WebKit::IDBFactoryBackendProxy::allowIndexedDB): Consolidates user-prompting logic.
+ (WebKit::getWebFrame): Helper to dig out frame from Document, or null for Worker.
+ (WebKit::IDBFactoryBackendProxy::getDatabaseNames):
+ (WebKit):
+ (WebKit::IDBFactoryBackendProxy::open):
+ (WebKit::IDBFactoryBackendProxy::deleteDatabase):
+ * src/IDBFactoryBackendProxy.h: Update method signatures to match interface.
+ (WebCore):
+ (IDBFactoryBackendProxy):
+
2012-07-12 Dana Jansens <[email protected]>
[chromium] The root layer should not try create a second RenderSurface for itself
Modified: trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp (122514 => 122515)
--- trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp 2012-07-12 22:19:10 UTC (rev 122515)
@@ -35,6 +35,7 @@
#include "DOMStringList.h"
#include "IDBDatabaseBackendProxy.h"
#include "IDBDatabaseError.h"
+#include "ScriptExecutionContext.h"
#include "SecurityOrigin.h"
#include "WebFrameImpl.h"
#include "WebIDBCallbacksImpl.h"
@@ -72,20 +73,6 @@
{
}
-void IDBFactoryBackendProxy::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> prpOrigin, Frame* frame, const String& dataDir)
-{
- WebSecurityOrigin origin(prpOrigin);
- WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
- WebViewImpl* webView = webFrame->viewImpl();
-
- if (webView->permissionClient() && !webView->permissionClient()->allowIndexedDB(webFrame, "Database Listing", origin)) {
- callbacks->onError(WebIDBDatabaseError(0, "The user denied permission to access the database."));
- return;
- }
-
- m_webIDBFactory->getDatabaseNames(new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir);
-}
-
static const char allowIndexedDBMode[] = "allowIndexedDBMode";
class AllowIndexedDBMainThreadBridge : public ThreadSafeRefCounted<AllowIndexedDBMainThreadBridge> {
@@ -161,60 +148,79 @@
WebWorkerBase* m_webWorkerBase;
};
-bool IDBFactoryBackendProxy::allowIDBFromWorkerThread(WorkerContext* workerContext, const String& name, const WebSecurityOrigin&)
+bool IDBFactoryBackendProxy::allowIndexedDB(ScriptExecutionContext* context, const String& name, const WebSecurityOrigin& origin, PassRefPtr<IDBCallbacks> callbacks)
{
+ bool allowed;
+ ASSERT(context->isDocument() || context->isWorkerContext());
+ if (context->isDocument()) {
+ Document* document = static_cast<Document*>(context);
+ WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame());
+ WebViewImpl* webView = webFrame->viewImpl();
+ allowed = webView->permissionClient() && webView->permissionClient()->allowIndexedDB(webFrame, name, origin);
+ } else {
+ WorkerContext* workerContext = static_cast<WorkerContext*>(context);
+ WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(&workerContext->thread()->workerLoaderProxy());
+ WorkerRunLoop& runLoop = workerContext->thread()->runLoop();
- WebWorkerBase* webWorkerBase = static_cast<WebWorkerBase*>(&workerContext->thread()->workerLoaderProxy());
- WorkerRunLoop& runLoop = workerContext->thread()->runLoop();
+ String mode = allowIndexedDBMode;
+ mode.append(String::number(runLoop.createUniqueId()));
+ RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThreadBridge::create(webWorkerBase, mode, name);
- String mode = allowIndexedDBMode;
- mode.append(String::number(runLoop.createUniqueId()));
- RefPtr<AllowIndexedDBMainThreadBridge> bridge = AllowIndexedDBMainThreadBridge::create(webWorkerBase, mode, name);
-
- // Either the bridge returns, or the queue gets terminated.
- if (runLoop.runInMode(workerContext, mode) == MessageQueueTerminated) {
- bridge->cancel();
- return false;
+ // Either the bridge returns, or the queue gets terminated.
+ if (runLoop.runInMode(workerContext, mode) == MessageQueueTerminated) {
+ bridge->cancel();
+ allowed = false;
+ } else
+ allowed = bridge->result();
}
- return bridge->result();
+ if (!allowed)
+ callbacks->onError(WebIDBDatabaseError(IDBDatabaseException::UNKNOWN_ERR, "The user denied permission to access the database."));
+
+ return allowed;
}
-void IDBFactoryBackendProxy::openFromWorker(const String& name, IDBCallbacks* callbacks, PassRefPtr<SecurityOrigin> prpOrigin, WorkerContext* context, const String& dataDir)
+static WebFrameImpl* getWebFrame(ScriptExecutionContext* context)
{
-#if ENABLE(WORKERS)
- WebSecurityOrigin origin(prpOrigin);
- if (!allowIDBFromWorkerThread(context, name, origin)) {
- callbacks->onError(WebIDBDatabaseError(0, "The user denied permission to access the database."));
- return;
+ ASSERT(context->isDocument() || context->isWorkerContext());
+ if (context->isDocument()) {
+ Document* document = static_cast<Document*>(context);
+ return WebFrameImpl::fromFrame(document->frame());
}
- m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, /*webFrame*/0, dataDir);
-#endif
+ return 0;
}
-void IDBFactoryBackendProxy::open(const String& name, IDBCallbacks* callbacks, PassRefPtr<SecurityOrigin> prpOrigin, Frame* frame, const String& dataDir)
+void IDBFactoryBackendProxy::getDatabaseNames(PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext* context, const String& dataDir)
{
- WebSecurityOrigin origin(prpOrigin);
- WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
- WebViewImpl* webView = webFrame->viewImpl();
- if (webView->permissionClient() && !webView->permissionClient()->allowIndexedDB(webFrame, name, origin)) {
- callbacks->onError(WebIDBDatabaseError(0, "The user denied permission to access the database."));
+ RefPtr<IDBCallbacks> callbacks(prpCallbacks);
+ WebSecurityOrigin origin(securityOrigin);
+ if (!allowIndexedDB(context, "Database Listing", origin, callbacks))
return;
- }
+ WebFrameImpl* webFrame = getWebFrame(context);
+ m_webIDBFactory->getDatabaseNames(new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir);
+}
+
+
+void IDBFactoryBackendProxy::open(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext* context, const String& dataDir)
+{
+ RefPtr<IDBCallbacks> callbacks(prpCallbacks);
+ WebSecurityOrigin origin(securityOrigin);
+ if (!allowIndexedDB(context, name, origin, callbacks))
+ return;
+
+ WebFrameImpl* webFrame = getWebFrame(context);
m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir);
}
-void IDBFactoryBackendProxy::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> prpOrigin, Frame* frame, const String& dataDir)
+void IDBFactoryBackendProxy::deleteDatabase(const String& name, PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext* context, const String& dataDir)
{
- WebSecurityOrigin origin(prpOrigin);
- WebFrameImpl* webFrame = WebFrameImpl::fromFrame(frame);
- WebViewImpl* webView = webFrame->viewImpl();
- if (webView->permissionClient() && !webView->permissionClient()->allowIndexedDB(webFrame, name, origin)) {
- callbacks->onError(WebIDBDatabaseError(0, "The user denied permission to access the database."));
+ RefPtr<IDBCallbacks> callbacks(prpCallbacks);
+ WebSecurityOrigin origin(securityOrigin);
+ if (!allowIndexedDB(context, name, origin, callbacks))
return;
- }
+ WebFrameImpl* webFrame = getWebFrame(context);
m_webIDBFactory->deleteDatabase(name, new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir);
}
Modified: trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h (122514 => 122515)
--- trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h 2012-07-12 22:05:44 UTC (rev 122514)
+++ trunk/Source/WebKit/chromium/src/IDBFactoryBackendProxy.h 2012-07-12 22:19:10 UTC (rev 122515)
@@ -31,10 +31,11 @@
#if ENABLE(INDEXED_DATABASE)
+#include "IDBCallbacks.h"
#include "IDBFactoryBackendInterface.h"
namespace WebCore {
-class WorkerContext;
+class ScriptExecutionContext;
}
namespace WebKit {
@@ -47,16 +48,13 @@
static PassRefPtr<WebCore::IDBFactoryBackendInterface> create();
virtual ~IDBFactoryBackendProxy();
- virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::Frame*, const String& dataDir);
+ virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir);
+ virtual void open(const String& name, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir);
+ virtual void deleteDatabase(const String& name, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir);
- virtual void open(const String& name, WebCore::IDBCallbacks*, PassRefPtr<WebCore::SecurityOrigin>, WebCore::Frame*, const String& dataDir);
- virtual void openFromWorker(const String& name, WebCore::IDBCallbacks*, PassRefPtr<WebCore::SecurityOrigin>, WebCore::WorkerContext*, const String& dataDir);
-
- virtual void deleteDatabase(const String& name, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::Frame*, const String& dataDir);
-
private:
IDBFactoryBackendProxy();
- bool allowIDBFromWorkerThread(WebCore::WorkerContext*, const String& name, const WebSecurityOrigin&);
+ bool allowIndexedDB(WebCore::ScriptExecutionContext*, const String& name, const WebSecurityOrigin&, PassRefPtr<WebCore::IDBCallbacks>);
// We don't own this pointer (unlike all the other proxy classes which do).
WebIDBFactory* m_webIDBFactory;