Diff
Modified: trunk/LayoutTests/ChangeLog (199796 => 199797)
--- trunk/LayoutTests/ChangeLog 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/ChangeLog 2016-04-20 23:43:34 UTC (rev 199797)
@@ -1,3 +1,20 @@
+2016-04-20 Brady Eidson <[email protected]>
+
+ Modern IDB (Workers): Introduce "IDBConnectionProxy" for future threading abstraction, and adopt it in IDBFactory.
+ https://bugs.webkit.org/show_bug.cgi?id=156810
+
+ Reviewed by Alex Christensen.
+
+ * storage/indexeddb/intversion-bad-parameters-expected.txt:
+ * storage/indexeddb/intversion-bad-parameters-private-expected.txt:
+ * storage/indexeddb/modern/opendatabase-request-event-expected.txt:
+ * storage/indexeddb/modern/opendatabase-request-event-private-expected.txt:
+ * storage/indexeddb/modern/opendatabase-request-expected.txt:
+ * storage/indexeddb/modern/opendatabase-request-private-expected.txt:
+ * storage/indexeddb/modern/workers-enable-expected.txt:
+ * storage/indexeddb/version-change-event-basic-expected.txt:
+ * storage/indexeddb/version-change-event-basic-private-expected.txt:
+
2016-04-20 Ryan Haddad <[email protected]>
Marking compositing/webgl/webgl-reflection.html as failing on ios-simulator
Modified: trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -13,7 +13,7 @@
PASS indexedDB.open(dbname, 'stringversion') threw TypeError: Value NaN is outside the range [0, 9007199254740991]
Expecting TypeError exception from indexedDB.open(dbname, 0)
PASS Exception was thrown.
-PASS indexedDB.open(dbname, 0) threw TypeError: Type error
+PASS indexedDB.open(dbname, 0) threw TypeError: IDBFactory.open() called with a version of 0
Expecting TypeError exception from indexedDB.open(dbname, -5)
PASS Exception was thrown.
PASS indexedDB.open(dbname, -5) threw TypeError: Value -5 is outside the range [0, 9007199254740991]
@@ -34,7 +34,7 @@
PASS indexedDB.open(dbname, 0x20000000000000) threw TypeError: Value 9007199254740992 is outside the range [0, 9007199254740991]
Expecting TypeError exception from indexedDB.open(dbname, null)
PASS Exception was thrown.
-PASS indexedDB.open(dbname, null) threw TypeError: Type error
+PASS indexedDB.open(dbname, null) threw TypeError: IDBFactory.open() called with a version of 0
Expecting TypeError exception from indexedDB.open(dbname, undefined)
PASS Exception was thrown.
PASS indexedDB.open(dbname, undefined) threw TypeError: Value NaN is outside the range [0, 9007199254740991]
Modified: trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-private-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-private-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/intversion-bad-parameters-private-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -13,7 +13,7 @@
PASS indexedDB.open(dbname, 'stringversion') threw TypeError: Value NaN is outside the range [0, 9007199254740991]
Expecting TypeError exception from indexedDB.open(dbname, 0)
PASS Exception was thrown.
-PASS indexedDB.open(dbname, 0) threw TypeError: Type error
+PASS indexedDB.open(dbname, 0) threw TypeError: IDBFactory.open() called with a version of 0
Expecting TypeError exception from indexedDB.open(dbname, -5)
PASS Exception was thrown.
PASS indexedDB.open(dbname, -5) threw TypeError: Value -5 is outside the range [0, 9007199254740991]
@@ -34,7 +34,7 @@
PASS indexedDB.open(dbname, 0x20000000000000) threw TypeError: Value 9007199254740992 is outside the range [0, 9007199254740991]
Expecting TypeError exception from indexedDB.open(dbname, null)
PASS Exception was thrown.
-PASS indexedDB.open(dbname, null) threw TypeError: Type error
+PASS indexedDB.open(dbname, null) threw TypeError: IDBFactory.open() called with a version of 0
Expecting TypeError exception from indexedDB.open(dbname, undefined)
PASS Exception was thrown.
PASS indexedDB.open(dbname, undefined) threw TypeError: Value NaN is outside the range [0, 9007199254740991]
Modified: trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-event-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-event-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-event-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -3,7 +3,7 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-Caught exception TypeError: Type error
+Caught exception TypeError: IDBFactory.open() called with a version of 0
Caught exception TypeError: Value -1 is outside the range [0, 9007199254740991]
[object IDBOpenDBRequest]
upgradeneeded: old version - 0 new version - 1
Modified: trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-event-private-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-event-private-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-event-private-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -3,7 +3,7 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-Caught exception TypeError: Type error
+Caught exception TypeError: IDBFactory.open() called with a version of 0
Caught exception TypeError: Value -1 is outside the range [0, 9007199254740991]
[object IDBOpenDBRequest]
upgradeneeded: old version - 0 new version - 1
Modified: trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -6,7 +6,7 @@
[object IDBOpenDBRequest]
[object IDBOpenDBRequest]
TypeError: Not enough arguments
-TypeError: Type error
+TypeError: IDBFactory.open() called with a version of 0
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-private-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-private-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/modern/opendatabase-request-private-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -6,7 +6,7 @@
[object IDBOpenDBRequest]
[object IDBOpenDBRequest]
TypeError: Not enough arguments
-TypeError: Type error
+TypeError: IDBFactory.open() called with a version of 0
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/modern/workers-enable-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/modern/workers-enable-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/modern/workers-enable-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -5,8 +5,8 @@
Starting worker: resources/workers-enable.js
PASS [Worker] self.indexedDB is defined.
-FAIL [Worker] self.indexedDB should be non-null. Was null
-FAIL [Worker] self.indexedDB instanceof IDBFactory should be true. Was false.
+PASS [Worker] self.indexedDB is non-null.
+PASS [Worker] self.indexedDB instanceof IDBFactory is true
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/version-change-event-basic-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/version-change-event-basic-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/version-change-event-basic-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -1,4 +1,4 @@
-0 version: TypeError: Type error
+0 version: TypeError: IDBFactory.open() called with a version of 0
Negative version: TypeError: Value -1 is outside the range [0, 9007199254740991]
String version: TypeError: Value NaN is outside the range [0, 9007199254740991]
First request: 0 1
Modified: trunk/LayoutTests/storage/indexeddb/version-change-event-basic-private-expected.txt (199796 => 199797)
--- trunk/LayoutTests/storage/indexeddb/version-change-event-basic-private-expected.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/LayoutTests/storage/indexeddb/version-change-event-basic-private-expected.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -1,4 +1,4 @@
-0 version: TypeError: Type error
+0 version: TypeError: IDBFactory.open() called with a version of 0
Negative version: TypeError: Value -1 is outside the range [0, 9007199254740991]
String version: TypeError: Value NaN is outside the range [0, 9007199254740991]
First request: 0 1
Modified: trunk/Source/WebCore/CMakeLists.txt (199796 => 199797)
--- trunk/Source/WebCore/CMakeLists.txt 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-04-20 23:43:34 UTC (rev 199797)
@@ -855,6 +855,7 @@
Modules/indexeddb/IDBVersionChangeEvent.cpp
Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp
+ Modules/indexeddb/client/IDBConnectionProxy.cpp
Modules/indexeddb/client/IDBConnectionToServer.cpp
Modules/indexeddb/client/TransactionOperation.cpp
Modified: trunk/Source/WebCore/ChangeLog (199796 => 199797)
--- trunk/Source/WebCore/ChangeLog 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/ChangeLog 2016-04-20 23:43:34 UTC (rev 199797)
@@ -1,3 +1,56 @@
+2016-04-20 Brady Eidson <[email protected]>
+
+ Modern IDB (Workers): Introduce "IDBConnectionProxy" for future threading abstraction, and adopt it in IDBFactory.
+ https://bugs.webkit.org/show_bug.cgi?id=156810
+
+ Reviewed by Alex Christensen.
+
+ No new tests (Covered by changes to existing tests).
+
+ Add the IDBConnectionProxy object, including the ability to replicate IDBFactory functionality:
+ * Modules/indexeddb/client/IDBConnectionProxy.cpp: Added.
+ (WebCore::IDBClient::IDBConnectionProxy::IDBConnectionProxy):
+ (WebCore::IDBClient::IDBConnectionProxy::openDatabase):
+ (WebCore::IDBClient::IDBConnectionProxy::deleteDatabase):
+ * Modules/indexeddb/client/IDBConnectionProxy.h:
+
+ Add pure virtual IDBConnectionProxy accessor:
+ * dom/ScriptExecutionContext.h:
+
+ Implement it:
+ * dom/Document.cpp:
+ (WebCore::Document::idbConnectionProxy):
+ * dom/Document.h:
+
+ Implement it:
+ * workers/WorkerGlobalScope.cpp:
+ (WebCore::WorkerGlobalScope::idbConnectionProxy):
+ * workers/WorkerGlobalScope.h:
+
+ * Modules/indexeddb/DOMWindowIndexedDatabase.cpp:
+ (WebCore::DOMWindowIndexedDatabase::indexedDB):
+
+
+ Don't keep a reference to IDBConnectionToServer, but rather get at the context's IDBConnectionProxy:
+ * Modules/indexeddb/IDBFactory.cpp:
+ (WebCore::IDBFactory::create):
+ (WebCore::IDBFactory::IDBFactory):
+ (WebCore::IDBFactory::open):
+ (WebCore::IDBFactory::openInternal):
+ (WebCore::IDBFactory::deleteDatabase):
+ * Modules/indexeddb/IDBFactory.h:
+ * Modules/indexeddb/IDBFactory.idl:
+
+ * Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp:
+ (WebCore::WorkerGlobalScopeIndexedDatabase::indexedDB):
+
+ * Modules/indexeddb/client/IDBConnectionToServer.h:
+
+ * inspector/InspectorIndexedDBAgent.cpp:
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+
2016-04-20 Chris Dumez <[email protected]>
Use Optional<size_t> for OrderIterator::m_orderIndex instead of int
Modified: trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp (199796 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.cpp 2016-04-20 23:43:34 UTC (rev 199797)
@@ -112,7 +112,7 @@
return nullptr;
if (!m_idbFactory)
- m_idbFactory = IDBFactory::create(page->idbConnection());
+ m_idbFactory = IDBFactory::create();
return m_idbFactory.get();
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (199796 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2016-04-20 23:43:34 UTC (rev 199797)
@@ -31,6 +31,7 @@
#include "Document.h"
#include "ExceptionCode.h"
#include "IDBBindingUtilities.h"
+#include "IDBConnectionProxy.h"
#include "IDBConnectionToServer.h"
#include "IDBDatabaseIdentifier.h"
#include "IDBKey.h"
@@ -62,13 +63,12 @@
return false;
}
-Ref<IDBFactory> IDBFactory::create(IDBClient::IDBConnectionToServer& connection)
+Ref<IDBFactory> IDBFactory::create()
{
- return adoptRef(*new IDBFactory(connection));
+ return adoptRef(*new IDBFactory);
}
-IDBFactory::IDBFactory(IDBClient::IDBConnectionToServer& connection)
- : m_connectionToServer(connection)
+IDBFactory::IDBFactory()
{
}
@@ -76,34 +76,37 @@
{
}
-RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, ExceptionCode& ec)
+RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, ExceptionCodeWithMessage& ec)
{
LOG(IndexedDB, "IDBFactory::open");
return openInternal(context, name, 0, ec);
}
-RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCode& ec)
+RefPtr<IDBOpenDBRequest> IDBFactory::open(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCodeWithMessage& ec)
{
LOG(IndexedDB, "IDBFactory::open");
if (!version) {
- ec = TypeError;
+ ec.code = TypeError;
+ ec.message = ASCIILiteral("IDBFactory.open() called with a version of 0");
return nullptr;
}
return openInternal(context, name, version, ec);
}
-RefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCode& ec)
+RefPtr<IDBOpenDBRequest> IDBFactory::openInternal(ScriptExecutionContext& context, const String& name, unsigned long long version, ExceptionCodeWithMessage& ec)
{
if (name.isNull()) {
- ec = TypeError;
+ ec.code = TypeError;
+ ec.message = ASCIILiteral("IDBFactory.open() called without a database name");
return nullptr;
}
if (shouldThrowSecurityException(context)) {
- ec = SECURITY_ERR;
+ ec.code = SECURITY_ERR;
+ ec.message = ASCIILiteral("IDBFactory.open() called in an invalid security context");
return nullptr;
}
@@ -111,27 +114,33 @@
ASSERT(context.topOrigin());
IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), *context.topOrigin());
if (!databaseIdentifier.isValid()) {
- ec = TypeError;
+ ec.code = TypeError;
+ ec.message = ASCIILiteral("IDBFactory.open() called with an invalid security origin");
return nullptr;
}
- auto request = IDBOpenDBRequest::createOpenRequest(m_connectionToServer.get(), context, databaseIdentifier, version);
- m_connectionToServer->openDatabase(request.get());
+ auto* connectionProxy = context.idbConnectionProxy();
+ if (!connectionProxy) {
+ ec.code = SECURITY_ERR;
+ ec.message = ASCIILiteral("IDBFactory.open() called at an invalid time");
+ return nullptr;
+ }
- return adoptRef(&request.leakRef());
+ return connectionProxy->openDatabase(context, databaseIdentifier, version);
}
-RefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext& context, const String& name, ExceptionCode& ec)
+RefPtr<IDBOpenDBRequest> IDBFactory::deleteDatabase(ScriptExecutionContext& context, const String& name, ExceptionCodeWithMessage& ec)
{
LOG(IndexedDB, "IDBFactory::deleteDatabase - %s", name.utf8().data());
if (name.isNull()) {
- ec = TypeError;
- return nullptr;
+ ec.code = TypeError;
+ ec.message = ASCIILiteral("IDBFactory.deleteDatabase() called without a database name");
}
if (shouldThrowSecurityException(context)) {
- ec = SECURITY_ERR;
+ ec.code = SECURITY_ERR;
+ ec.message = ASCIILiteral("IDBFactory.deleteDatabase() called in an invalid security context");
return nullptr;
}
@@ -139,14 +148,19 @@
ASSERT(context.topOrigin());
IDBDatabaseIdentifier databaseIdentifier(name, *context.securityOrigin(), *context.topOrigin());
if (!databaseIdentifier.isValid()) {
- ec = TypeError;
+ ec.code = TypeError;
+ ec.message = ASCIILiteral("IDBFactory.deleteDatabase() called with an invalid security origin");
return nullptr;
}
- auto request = IDBOpenDBRequest::createDeleteRequest(m_connectionToServer.get(), context, databaseIdentifier);
- m_connectionToServer->deleteDatabase(request.get());
+ auto* connectionProxy = context.idbConnectionProxy();
+ if (!connectionProxy) {
+ ec.code = SECURITY_ERR;
+ ec.message = ASCIILiteral("IDBFactory.deleteDatabase() called at an invalid time");
+ return nullptr;
+ }
- return adoptRef(&request.leakRef());
+ return connectionProxy->deleteDatabase(context, databaseIdentifier);
}
short IDBFactory::cmp(ScriptExecutionContext& context, JSValue firstValue, JSValue secondValue, ExceptionCodeWithMessage& ec)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h (199796 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h 2016-04-20 23:43:34 UTC (rev 199797)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,7 +29,7 @@
#include <wtf/Forward.h>
#include <wtf/Ref.h>
-#include <wtf/RefCounted.h>
+#include <wtf/ThreadSafeRefCounted.h>
namespace JSC {
class JSValue;
@@ -48,23 +48,21 @@
typedef int ExceptionCode;
-class IDBFactory : public RefCounted<IDBFactory> {
+class IDBFactory : public ThreadSafeRefCounted<IDBFactory> {
public:
- static Ref<IDBFactory> create(IDBClient::IDBConnectionToServer&);
+ static Ref<IDBFactory> create();
~IDBFactory();
- RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, ExceptionCode&);
- RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCode&);
- RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const String& name, ExceptionCode&);
+ RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, ExceptionCodeWithMessage&);
+ RefPtr<IDBOpenDBRequest> open(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCodeWithMessage&);
+ RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const String& name, ExceptionCodeWithMessage&);
short cmp(ScriptExecutionContext&, JSC::JSValue first, JSC::JSValue second, ExceptionCodeWithMessage&);
private:
- explicit IDBFactory(IDBClient::IDBConnectionToServer&);
+ explicit IDBFactory();
- RefPtr<IDBOpenDBRequest> openInternal(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCode&);
-
- Ref<IDBClient::IDBConnectionToServer> m_connectionToServer;
+ RefPtr<IDBOpenDBRequest> openInternal(ScriptExecutionContext&, const String& name, unsigned long long version, ExceptionCodeWithMessage&);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl (199796 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.idl 2016-04-20 23:43:34 UTC (rev 199797)
@@ -29,8 +29,8 @@
SkipVTableValidation,
Exposed=(Window,Worker),
] interface IDBFactory {
- [CallWith=ScriptExecutionContext, RaisesException] IDBOpenDBRequest open(DOMString name, [EnforceRange] optional unsigned long long version);
- [CallWith=ScriptExecutionContext, RaisesException] IDBOpenDBRequest deleteDatabase(DOMString name);
+ [CallWith=ScriptExecutionContext, RaisesExceptionWithMessage] IDBOpenDBRequest open(DOMString name, [EnforceRange] optional unsigned long long version);
+ [CallWith=ScriptExecutionContext, RaisesExceptionWithMessage] IDBOpenDBRequest deleteDatabase(DOMString name);
[CallWith=ScriptExecutionContext, RaisesExceptionWithMessage] short cmp(any first, any second);
};
Modified: trunk/Source/WebCore/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp (199796 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.cpp 2016-04-20 23:43:34 UTC (rev 199797)
@@ -69,7 +69,10 @@
IDBFactory* WorkerGlobalScopeIndexedDatabase::indexedDB()
{
- return nullptr;
+ if (!m_idbFactory)
+ m_idbFactory = IDBFactory::create();
+
+ return m_idbFactory.get();
}
} // namespace WebCore
Added: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (0 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-04-20 23:43:34 UTC (rev 199797)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IDBConnectionProxy.h"
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBOpenDBRequest.h"
+#include <wtf/MainThread.h>
+
+namespace WebCore {
+namespace IDBClient {
+
+IDBConnectionProxy::IDBConnectionProxy(IDBConnectionToServer& connection)
+ : m_connectionToServer(connection)
+{
+}
+
+RefPtr<IDBOpenDBRequest> IDBConnectionProxy::openDatabase(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
+{
+ // FIXME: Get rid of the need for IDB objects to hold a reference to the IDBConnectionToServer,
+ // which will enable them to operate on Worker threads.
+ if (!isMainThread())
+ return nullptr;
+
+ auto request = IDBOpenDBRequest::createOpenRequest(m_connectionToServer.get(), context, databaseIdentifier, version);
+ m_connectionToServer->openDatabase(request.get());
+
+ return adoptRef(&request.leakRef());
+}
+
+RefPtr<IDBOpenDBRequest> IDBConnectionProxy::deleteDatabase(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)
+{
+ // FIXME: Get rid of the need for IDB objects to hold a reference to the IDBConnectionToServer,
+ // which will enable them to operate on Worker threads.
+ if (!isMainThread())
+ return nullptr;
+
+ auto request = IDBOpenDBRequest::createDeleteRequest(m_connectionToServer.get(), context, databaseIdentifier);
+ m_connectionToServer->deleteDatabase(request.get());
+
+ return adoptRef(&request.leakRef());
+}
+
+} // namesapce IDBClient
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
Copied: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h (from rev 199796, trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h) (0 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h (rev 0)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h 2016-04-20 23:43:34 UTC (rev 199797)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(INDEXED_DATABASE)
+
+#include "IDBConnectionToServer.h"
+
+namespace WebCore {
+
+class IDBDatabaseIdentifier;
+class IDBOpenDBRequest;
+class ScriptExecutionContext;
+
+namespace IDBClient {
+
+class IDBConnectionProxy {
+public:
+ IDBConnectionProxy(IDBConnectionToServer&);
+
+ RefPtr<IDBOpenDBRequest> openDatabase(ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);
+ RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const IDBDatabaseIdentifier&);
+
+private:
+ Ref<IDBConnectionToServer> m_connectionToServer;
+};
+
+} // namespace IDBClient
+} // namespace WebCore
+
+#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (199796 => 199797)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2016-04-20 23:43:34 UTC (rev 199797)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,8 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef IDBConnectionToServer_h
-#define IDBConnectionToServer_h
+#pragma once
#if ENABLE(INDEXED_DATABASE)
@@ -34,7 +33,7 @@
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Ref.h>
-#include <wtf/RefCounted.h>
+#include <wtf/ThreadSafeRefCounted.h>
namespace WebCore {
@@ -51,7 +50,7 @@
class TransactionOperation;
-class IDBConnectionToServer : public RefCounted<IDBConnectionToServer> {
+class IDBConnectionToServer : public ThreadSafeRefCounted<IDBConnectionToServer> {
public:
WEBCORE_EXPORT static Ref<IDBConnectionToServer> create(IDBConnectionToServerDelegate&);
@@ -143,4 +142,3 @@
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBConnectionToServer_h
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (199796 => 199797)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-04-20 23:43:34 UTC (rev 199797)
@@ -2085,6 +2085,8 @@
517A63C41B74318B00E7DCDC /* KeyedEncoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */; };
517A63C51B74318F00E7DCDC /* KeyedDecoderCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */; settings = {ATTRIBUTES = (Private, ); }; };
517A63C61B74319200E7DCDC /* KeyedEncoderCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A63C21B74317E00E7DCDC /* KeyedEncoderCF.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 517B25A91CC82B2A0061C011 /* IDBConnectionProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517B25A71CC820320061C011 /* IDBConnectionProxy.cpp */; };
+ 517B25AA1CC82B2A0061C011 /* IDBConnectionProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 517B25A81CC820320061C011 /* IDBConnectionProxy.h */; };
517FBA1E151AB17C00B57959 /* DOMWindowExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517FBA17151AA71B00B57959 /* DOMWindowExtension.cpp */; };
5185FC741BB4C4E80012898F /* DOMWindowIndexedDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51D7196C181106DF0016DC51 /* DOMWindowIndexedDatabase.cpp */; };
5185FC751BB4C4E80012898F /* DOMWindowIndexedDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 51D7196D181106DF0016DC51 /* DOMWindowIndexedDatabase.h */; };
@@ -9672,6 +9674,8 @@
517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedDecoderCF.h; sourceTree = "<group>"; };
517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedEncoderCF.cpp; sourceTree = "<group>"; };
517A63C21B74317E00E7DCDC /* KeyedEncoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedEncoderCF.h; sourceTree = "<group>"; };
+ 517B25A71CC820320061C011 /* IDBConnectionProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBConnectionProxy.cpp; sourceTree = "<group>"; };
+ 517B25A81CC820320061C011 /* IDBConnectionProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBConnectionProxy.h; sourceTree = "<group>"; };
517FBA17151AA71B00B57959 /* DOMWindowExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtension.cpp; sourceTree = "<group>"; };
517FBA18151AA71B00B57959 /* DOMWindowExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWindowExtension.h; sourceTree = "<group>"; };
5185FCB61BB4C7610012898F /* DOMRequestState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMRequestState.h; sourceTree = "<group>"; };
@@ -17223,6 +17227,8 @@
510310421BA8C64C003329C0 /* client */ = {
isa = PBXGroup;
children = (
+ 517B25A71CC820320061C011 /* IDBConnectionProxy.cpp */,
+ 517B25A81CC820320061C011 /* IDBConnectionProxy.h */,
5185FCBC1BB5CB770012898F /* IDBConnectionToServer.cpp */,
510A58FD1BB07A9600C19282 /* IDBConnectionToServer.h */,
5185FCBD1BB5CB770012898F /* IDBConnectionToServerDelegate.h */,
@@ -28396,6 +28402,7 @@
2D232C001A326F02006BF2DB /* TUCallSPI.h in Headers */,
C375D7FE16639519006184AB /* TypeAhead.h in Headers */,
E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */,
+ 517B25AA1CC82B2A0061C011 /* IDBConnectionProxy.h in Headers */,
93309E1A099E64920056E581 /* TypingCommand.h in Headers */,
85031B4E0A44EFC700F992E0 /* UIEvent.h in Headers */,
85031B4F0A44EFC700F992E0 /* UIEventWithKeyState.h in Headers */,
@@ -30557,6 +30564,7 @@
4147E2B81C89912F00A7E715 /* FetchBodyOwner.cpp in Sources */,
5E2C436B1BCF071E0001E2BC /* JSRTCTrackEvent.cpp in Sources */,
BCEC01C20C274DDD009F4EC9 /* JSScreen.cpp in Sources */,
+ 517B25A91CC82B2A0061C011 /* IDBConnectionProxy.cpp in Sources */,
FDA15ECD12B03F61003A583A /* JSScriptProcessorNode.cpp in Sources */,
9FA37EFA1172FDA600C4CD55 /* JSScriptProfile.cpp in Sources */,
9FA37EFC1172FDA600C4CD55 /* JSScriptProfileNode.cpp in Sources */,
Modified: trunk/Source/WebCore/dom/Document.cpp (199796 => 199797)
--- trunk/Source/WebCore/dom/Document.cpp 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-04-20 23:43:34 UTC (rev 199797)
@@ -201,6 +201,11 @@
#include "RenderFullScreen.h"
#endif
+#if ENABLE(INDEXED_DATABASE)
+#include "IDBConnectionProxy.h"
+#include "IDBOpenDBRequest.h"
+#endif
+
#if PLATFORM(IOS)
#include "CSSFontSelector.h"
#include "DeviceMotionClientIOS.h"
@@ -3103,6 +3108,21 @@
frame()->script().disableEval(errorMessage);
}
+#if ENABLE(INDEXED_DATABASE)
+IDBClient::IDBConnectionProxy* Document::idbConnectionProxy()
+{
+ if (!m_idbConnectionProxy) {
+ Page* currentPage = page();
+ if (!currentPage)
+ return nullptr;
+
+ m_idbConnectionProxy = std::make_unique<IDBClient::IDBConnectionProxy>(currentPage->idbConnection());
+ }
+
+ return m_idbConnectionProxy.get();
+}
+#endif // ENABLE(INDEXED_DATABASE)
+
bool Document::canNavigate(Frame* targetFrame)
{
if (!m_frame)
Modified: trunk/Source/WebCore/dom/Document.h (199796 => 199797)
--- trunk/Source/WebCore/dom/Document.h 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/dom/Document.h 2016-04-20 23:43:34 UTC (rev 199797)
@@ -3,7 +3,7 @@
* (C) 1999 Antti Koivisto ([email protected])
* (C) 2001 Dirk Mueller ([email protected])
* (C) 2006 Alexey Proskuryakov ([email protected])
- * Copyright (C) 2004-2010, 2012-2013, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2010, 2012-2013, 2015, 2016 Apple Inc. All rights reserved.
* Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (C) 2011 Google Inc. All rights reserved.
@@ -25,8 +25,7 @@
*
*/
-#ifndef Document_h
-#define Document_h
+#pragma once
#include "CollectionType.h"
#include "Color.h"
@@ -661,6 +660,10 @@
void disableEval(const String& errorMessage) final;
+#if ENABLE(INDEXED_DATABASE)
+ IDBClient::IDBConnectionProxy* idbConnectionProxy() final;
+#endif
+
bool canNavigate(Frame* targetFrame);
Frame* findUnsafeParentScrollPropagationBoundary();
@@ -1776,6 +1779,10 @@
#if ENABLE(MEDIA_STREAM)
bool m_hasHadActiveMediaStreamTrack { false };
#endif
+
+#if ENABLE(INDEXED_DATABASE)
+ std::unique_ptr<IDBClient::IDBConnectionProxy> m_idbConnectionProxy;
+#endif
};
inline void Document::notifyRemovePendingSheetIfNeeded()
@@ -1818,5 +1825,3 @@
static bool isType(const WebCore::ScriptExecutionContext& context) { return context.isDocument(); }
static bool isType(const WebCore::Node& node) { return node.isDocumentNode(); }
SPECIALIZE_TYPE_TRAITS_END()
-
-#endif // Document_h
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (199796 => 199797)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.h 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h 2016-04-20 23:43:34 UTC (rev 199797)
@@ -55,6 +55,10 @@
class SecurityOrigin;
class URL;
+namespace IDBClient {
+class IDBConnectionProxy;
+}
+
class ScriptExecutionContext : public SecurityContext {
public:
ScriptExecutionContext();
@@ -73,6 +77,10 @@
virtual void disableEval(const String& errorMessage) = 0;
+#if ENABLE(INDEXED_DATABASE)
+ virtual IDBClient::IDBConnectionProxy* idbConnectionProxy() = 0;
+#endif
+
bool sanitizeScriptError(String& errorMessage, int& lineNumber, int& columnNumber, String& sourceURL, CachedScript* = nullptr);
void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, RefPtr<Inspector::ScriptCallStack>&&, CachedScript* = nullptr);
Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (199796 => 199797)
--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2016-04-20 23:43:34 UTC (rev 199797)
@@ -206,7 +206,7 @@
void ExecutableWithDatabase::start(IDBFactory* idbFactory, SecurityOrigin*, const String& databaseName)
{
Ref<OpenDatabaseCallback> callback = OpenDatabaseCallback::create(this);
- ExceptionCode ec = 0;
+ ExceptionCodeWithMessage ec;
if (!context()) {
requestCallback().sendFailure("Could not open database.");
@@ -214,7 +214,7 @@
}
RefPtr<IDBOpenDBRequest> idbOpenDBRequest = idbFactory->open(*context(), databaseName, ec);
- if (ec) {
+ if (ec.code) {
requestCallback().sendFailure("Could not open database.");
return;
}
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (199796 => 199797)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2016-04-20 23:43:34 UTC (rev 199797)
@@ -112,6 +112,15 @@
m_script->disableEval(errorMessage);
}
+#if ENABLE(INDEXED_DATABASE)
+IDBClient::IDBConnectionProxy* WorkerGlobalScope::idbConnectionProxy()
+{
+ // FIXME: Implement
+
+ return nullptr;
+}
+#endif // ENABLE(INDEXED_DATABASE)
+
WorkerLocation* WorkerGlobalScope::location() const
{
if (!m_location)
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (199796 => 199797)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.h 2016-04-20 23:28:29 UTC (rev 199796)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h 2016-04-20 23:43:34 UTC (rev 199797)
@@ -70,6 +70,10 @@
void disableEval(const String& errorMessage) override;
+#if ENABLE(INDEXED_DATABASE)
+ IDBClient::IDBConnectionProxy* idbConnectionProxy() final;
+#endif
+
bool shouldBypassMainWorldContentSecurityPolicy() const final { return m_shouldBypassMainWorldContentSecurityPolicy; }
WorkerScriptController* script() { return m_script.get(); }