Diff
Modified: trunk/Source/WebCore/ChangeLog (199842 => 199843)
--- trunk/Source/WebCore/ChangeLog 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/ChangeLog 2016-04-21 23:25:10 UTC (rev 199843)
@@ -1,3 +1,45 @@
+2016-04-21 Brady Eidson <beid...@apple.com>
+
+ Modern IDB (Workers): Move IDBConnectionProxy into IDBRequest and IDBDatabase.
+ https://bugs.webkit.org/show_bug.cgi?id=156868
+
+ Reviewed by Tim Horton.
+
+ No new tests (No behavior change).
+
+ * Modules/indexeddb/IDBDatabase.cpp:
+ (WebCore::IDBDatabase::create):
+ (WebCore::IDBDatabase::IDBDatabase):
+ (WebCore::IDBDatabase::~IDBDatabase):
+ (WebCore::IDBDatabase::transaction):
+ (WebCore::IDBDatabase::maybeCloseInServer):
+ * Modules/indexeddb/IDBDatabase.h:
+ (WebCore::IDBDatabase::connectionProxy):
+ (WebCore::IDBDatabase::serverConnection):
+
+ * Modules/indexeddb/IDBOpenDBRequest.cpp:
+ (WebCore::IDBOpenDBRequest::createDeleteRequest):
+ (WebCore::IDBOpenDBRequest::createOpenRequest):
+ (WebCore::IDBOpenDBRequest::IDBOpenDBRequest):
+ (WebCore::IDBOpenDBRequest::onSuccess):
+ (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+ (WebCore::IDBOpenDBRequest::requestCompleted):
+ (WebCore::IDBOpenDBRequest::maybeCreateDeleteRequest): Deleted.
+ (WebCore::IDBOpenDBRequest::maybeCreateOpenRequest): Deleted.
+ * Modules/indexeddb/IDBOpenDBRequest.h:
+
+ * Modules/indexeddb/IDBRequest.cpp:
+ (WebCore::IDBRequest::IDBRequest):
+ (WebCore::IDBRequest::connectionToServer): Deleted.
+ * Modules/indexeddb/IDBRequest.h:
+ (WebCore::IDBRequest::connectionProxy):
+
+ * Modules/indexeddb/IDBTransaction.h:
+
+ * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+ (WebCore::IDBClient::IDBConnectionProxy::openDatabase):
+ (WebCore::IDBClient::IDBConnectionProxy::deleteDatabase):
+
2016-04-21 Jiewen Tan <jiewen_...@apple.com>
[iOS] DumpRenderTree crashed in com.apple.WebCore: WebCore::ResourceLoadNotifier::didFailToLoad
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2016-04-21 23:25:10 UTC (rev 199843)
@@ -30,6 +30,7 @@
#include "DOMStringList.h"
#include "EventQueue.h"
+#include "IDBConnectionProxy.h"
#include "IDBConnectionToServer.h"
#include "IDBDatabaseException.h"
#include "IDBObjectStore.h"
@@ -42,26 +43,26 @@
namespace WebCore {
-Ref<IDBDatabase> IDBDatabase::create(ScriptExecutionContext& context, IDBClient::IDBConnectionToServer& connection, const IDBResultData& resultData)
+Ref<IDBDatabase> IDBDatabase::create(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBResultData& resultData)
{
- return adoptRef(*new IDBDatabase(context, connection, resultData));
+ return adoptRef(*new IDBDatabase(context, connectionProxy, resultData));
}
-IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBClient::IDBConnectionToServer& connection, const IDBResultData& resultData)
+IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBResultData& resultData)
: WebCore::ActiveDOMObject(&context)
- , m_serverConnection(connection)
+ , m_connectionProxy(connectionProxy)
, m_info(resultData.databaseInfo())
, m_databaseConnectionIdentifier(resultData.databaseConnectionIdentifier())
{
LOG(IndexedDB, "IDBDatabase::IDBDatabase - Creating database %s with version %" PRIu64 " connection %" PRIu64, m_info.name().utf8().data(), m_info.version(), m_databaseConnectionIdentifier);
suspendIfNeeded();
relaxAdoptionRequirement();
- m_serverConnection->registerDatabaseConnection(*this);
+ m_connectionProxy->connectionToServer().registerDatabaseConnection(*this);
}
IDBDatabase::~IDBDatabase()
{
- m_serverConnection->unregisterDatabaseConnection(*this);
+ m_connectionProxy->connectionToServer().unregisterDatabaseConnection(*this);
}
bool IDBDatabase::hasPendingActivity() const
@@ -180,7 +181,7 @@
return nullptr;
}
- auto info = IDBTransactionInfo::clientTransaction(m_serverConnection.get(), objectStores, mode);
+ auto info = IDBTransactionInfo::clientTransaction(m_connectionProxy->connectionToServer(), objectStores, mode);
auto transaction = IDBTransaction::create(*this, info);
LOG(IndexedDB, "IDBDatabase::transaction - Added active transaction %s", info.identifier().loggingString().utf8().data());
@@ -244,7 +245,7 @@
return;
m_closedInServer = true;
- m_serverConnection->databaseConnectionClosed(*this);
+ m_connectionProxy->connectionToServer().databaseConnectionClosed(*this);
}
const char* IDBDatabase::activeDOMObjectName() const
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h 2016-04-21 23:25:10 UTC (rev 199843)
@@ -30,6 +30,7 @@
#include "Dictionary.h"
#include "EventTarget.h"
#include "ExceptionCode.h"
+#include "IDBConnectionProxy.h"
#include "IDBConnectionToServer.h"
#include "IDBDatabaseInfo.h"
@@ -44,7 +45,7 @@
class IDBDatabase : public RefCounted<IDBDatabase>, public EventTargetWithInlineData, public ActiveDOMObject {
public:
- static Ref<IDBDatabase> create(ScriptExecutionContext&, IDBClient::IDBConnectionToServer&, const IDBResultData&);
+ static Ref<IDBDatabase> create(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBResultData&);
virtual ~IDBDatabase();
@@ -86,8 +87,11 @@
void fireVersionChangeEvent(const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
- IDBClient::IDBConnectionToServer& serverConnection() { return m_serverConnection.get(); }
+ IDBClient::IDBConnectionProxy& connectionProxy() { return m_connectionProxy.get(); }
+ // FIXME: Remove the need for this accessor.
+ IDBClient::IDBConnectionToServer& serverConnection() { return m_connectionProxy->connectionToServer(); }
+
void didCreateIndexInfo(const IDBIndexInfo&);
void didDeleteIndexInfo(const IDBIndexInfo&);
@@ -98,13 +102,13 @@
bool hasPendingActivity() const final;
private:
- IDBDatabase(ScriptExecutionContext&, IDBClient::IDBConnectionToServer&, const IDBResultData&);
+ IDBDatabase(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBResultData&);
void didCommitOrAbortTransaction(IDBTransaction&);
void maybeCloseInServer();
- Ref<IDBClient::IDBConnectionToServer> m_serverConnection;
+ Ref<IDBClient::IDBConnectionProxy> m_connectionProxy;
IDBDatabaseInfo m_info;
uint64_t m_databaseConnectionIdentifier { 0 };
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp 2016-04-21 23:25:10 UTC (rev 199843)
@@ -42,28 +42,18 @@
namespace WebCore {
-RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::maybeCreateDeleteRequest(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)
+Ref<IDBOpenDBRequest> IDBOpenDBRequest::createDeleteRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier)
{
- ASSERT(databaseIdentifier.isValid());
- auto* proxy = context.idbConnectionProxy();
- if (!proxy)
- return nullptr;
-
- return adoptRef(new IDBOpenDBRequest(context, proxy->serverConnectionIdentifier(), databaseIdentifier, 0, IndexedDB::RequestType::Delete));
+ return adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, 0, IndexedDB::RequestType::Delete));
}
-RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::maybeCreateOpenRequest(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
+Ref<IDBOpenDBRequest> IDBOpenDBRequest::createOpenRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
{
- ASSERT(databaseIdentifier.isValid());
- auto* proxy = context.idbConnectionProxy();
- if (!proxy)
- return nullptr;
-
- return adoptRef(new IDBOpenDBRequest(context, proxy->serverConnectionIdentifier(), databaseIdentifier, version, IndexedDB::RequestType::Open));
+ return adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, version, IndexedDB::RequestType::Open));
}
-IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, uint64_t serverConnectionIdentifier, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)
- : IDBRequest(context, serverConnectionIdentifier)
+IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)
+ : IDBRequest(context, connectionProxy)
, m_databaseIdentifier(databaseIdentifier)
, m_version(version)
{
@@ -128,11 +118,7 @@
{
LOG(IndexedDB, "IDBOpenDBRequest::onSuccess()");
- auto* connection = connectionToServer();
- if (!connection)
- return;
-
- setResult(IDBDatabase::create(*scriptExecutionContext(), *connection, resultData));
+ setResult(IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData));
m_isDone = true;
enqueueEvent(IDBRequestCompletionEvent::create(eventNames().successEvent, false, false, *this));
@@ -140,11 +126,7 @@
void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
{
- auto* connection = connectionToServer();
- if (!connection)
- return;
-
- Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), *connection, resultData);
+ Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData);
Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this);
ASSERT(transaction->info().mode() == IndexedDB::TransactionMode::VersionChange);
@@ -179,20 +161,16 @@
{
LOG(IndexedDB, "IDBOpenDBRequest::requestCompleted");
- auto* connection = connectionToServer();
- if (!connection)
- return;
-
// If an Open request was completed after the page has navigated, leaving this request
// with a stopped script execution context, we need to message back to the server so it
// doesn't hang waiting on a database connection or transaction that will never exist.
if (m_contextStopped) {
switch (data.type()) {
case IDBResultType::OpenDatabaseSuccess:
- connection->abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue());
+ connectionProxy().connectionToServer().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue());
break;
case IDBResultType::OpenDatabaseUpgradeNeeded:
- connection->abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());
+ connectionProxy().connectionToServer().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());
break;
default:
break;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h 2016-04-21 23:25:10 UTC (rev 199843)
@@ -36,8 +36,8 @@
class IDBOpenDBRequest final : public IDBRequest {
public:
- static RefPtr<IDBOpenDBRequest> maybeCreateDeleteRequest(ScriptExecutionContext&, const IDBDatabaseIdentifier&);
- static RefPtr<IDBOpenDBRequest> maybeCreateOpenRequest(ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);
+ static Ref<IDBOpenDBRequest> createDeleteRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBDatabaseIdentifier&);
+ static Ref<IDBOpenDBRequest> createOpenRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBDatabaseIdentifier&, uint64_t version);
virtual ~IDBOpenDBRequest();
@@ -52,7 +52,7 @@
void fireErrorAfterVersionChangeCompletion();
private:
- IDBOpenDBRequest(ScriptExecutionContext&, uint64_t serverConnectionIdentifier, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType);
+ IDBOpenDBRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType);
bool dispatchEvent(Event&) final;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2016-04-21 23:25:10 UTC (rev 199843)
@@ -69,9 +69,10 @@
return adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction));
}
-IDBRequest::IDBRequest(ScriptExecutionContext& context, uint64_t connectionIdentifier)
+IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy)
: ActiveDOMObject(&context)
- , m_resourceIdentifier(connectionIdentifier)
+ , m_resourceIdentifier(connectionProxy.serverConnectionIdentifier())
+ , m_connectionProxy(connectionProxy)
{
suspendIfNeeded();
}
@@ -81,6 +82,7 @@
, m_transaction(&transaction)
, m_resourceIdentifier(transaction.serverConnection())
, m_objectStoreSource(&objectStore)
+ , m_connectionProxy(transaction.database().connectionProxy())
{
suspendIfNeeded();
}
@@ -92,6 +94,7 @@
, m_objectStoreSource(cursor.objectStore())
, m_indexSource(cursor.index())
, m_pendingCursor(&cursor)
+ , m_connectionProxy(transaction.database().connectionProxy())
{
suspendIfNeeded();
@@ -103,6 +106,7 @@
, m_transaction(&transaction)
, m_resourceIdentifier(transaction.serverConnection())
, m_indexSource(&index)
+ , m_connectionProxy(transaction.database().connectionProxy())
{
suspendIfNeeded();
}
@@ -407,17 +411,6 @@
m_databaseResult = WTFMove(database);
}
-// FIXME: Temporarily required during bringup of IDB-in-Workers.
-// Once all IDB object reliance on the IDBConnectionToServer has been shifted to reliance on
-// IDBConnectionProxy, remove this.
-IDBClient::IDBConnectionToServer* IDBRequest::connectionToServer()
-{
- ASSERT(isMainThread());
- auto* context = scriptExecutionContext();
- auto* proxy = context ? context->idbConnectionProxy() : nullptr;
- return proxy ? &proxy->connectionToServer() : nullptr;
-}
-
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h 2016-04-21 23:25:10 UTC (rev 199843)
@@ -48,6 +48,7 @@
class ThreadSafeDataBuffer;
namespace IDBClient {
+class IDBConnectionProxy;
class IDBConnectionToServer;
}
@@ -104,17 +105,14 @@
bool hasPendingActivity() const final;
protected:
- IDBRequest(ScriptExecutionContext&, uint64_t connectionIdentifier);
+ IDBRequest(ScriptExecutionContext&, IDBClient::IDBConnectionProxy&);
void enqueueEvent(Ref<Event>&&);
bool dispatchEvent(Event&) override;
void setResult(Ref<IDBDatabase>&&);
- // FIXME: Temporarily required during bringup of IDB-in-Workers.
- // Once all IDB object reliance on the IDBConnectionToServer has been shifted to reliance on
- // IDBConnectionProxy, remove this.
- IDBClient::IDBConnectionToServer* connectionToServer();
+ IDBClient::IDBConnectionProxy& connectionProxy() { return m_connectionProxy.get(); }
// FIXME: Protected data members aren't great for maintainability.
// Consider adding protected helper functions and making these private.
@@ -170,6 +168,8 @@
RefPtr<IDBCursor> m_pendingCursor;
std::unique_ptr<ScopeGuard> m_cursorRequestNotifier;
+
+ Ref<IDBClient::IDBConnectionProxy> m_connectionProxy;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.h 2016-04-21 23:25:10 UTC (rev 199843)
@@ -30,6 +30,7 @@
#include "ActiveDOMObject.h"
#include "EventTarget.h"
#include "IDBError.h"
+#include "IDBOpenDBRequest.h"
#include "IDBTransactionInfo.h"
#include "IndexedDB.h"
#include "Timer.h"
@@ -48,7 +49,6 @@
class IDBKeyData;
class IDBObjectStore;
class IDBObjectStoreInfo;
-class IDBOpenDBRequest;
class IDBResultData;
class SerializedScriptValue;
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (199842 => 199843)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-04-21 23:06:41 UTC (rev 199842)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-04-21 23:25:10 UTC (rev 199843)
@@ -57,32 +57,24 @@
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.
+ // FIXME: Handle Workers
if (!isMainThread())
return nullptr;
- auto request = IDBOpenDBRequest::maybeCreateOpenRequest(context, databaseIdentifier, version);
- if (!request)
- return nullptr;
-
- m_connectionToServer->openDatabase(*request);
- return request;
+ auto request = IDBOpenDBRequest::createOpenRequest(context, *this, databaseIdentifier, version);
+ m_connectionToServer->openDatabase(request.get());
+ return WTFMove(request);
}
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.
+ // FIXME: Handle Workers
if (!isMainThread())
return nullptr;
- auto request = IDBOpenDBRequest::maybeCreateDeleteRequest(context, databaseIdentifier);
- if (!request)
- return nullptr;
-
- m_connectionToServer->deleteDatabase(*request);
- return request;
+ auto request = IDBOpenDBRequest::createDeleteRequest(context, *this, databaseIdentifier);
+ m_connectionToServer->deleteDatabase(request.get());
+ return WTFMove(request);
}
} // namesapce IDBClient