Diff
Modified: trunk/Source/WebCore/ChangeLog (199803 => 199804)
--- trunk/Source/WebCore/ChangeLog 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/ChangeLog 2016-04-21 04:42:17 UTC (rev 199804)
@@ -1,3 +1,44 @@
+2016-04-20 Brady Eidson <[email protected]>
+
+ Modern IDB (Workers): Remove IDBRequest/IDBOpenDBRequest's requirement to get an IDBServerConnection around.
+ https://bugs.webkit.org/show_bug.cgi?id=156826
+
+ Reviewed by Alex Christensen.
+
+ No new tests (No behavior change, existing tests pass).
+
+ This doesn't appear to do much but make things a little more complicated, but it's the first of a few
+ small pushes in the right direction.
+
+ * Modules/indexeddb/IDBOpenDBRequest.cpp:
+ (WebCore::IDBOpenDBRequest::maybeCreateDeleteRequest):
+ (WebCore::IDBOpenDBRequest::maybeCreateOpenRequest):
+ (WebCore::IDBOpenDBRequest::IDBOpenDBRequest):
+ (WebCore::IDBOpenDBRequest::onSuccess):
+ (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+ (WebCore::IDBOpenDBRequest::requestCompleted):
+ (WebCore::IDBOpenDBRequest::createDeleteRequest): Deleted.
+ (WebCore::IDBOpenDBRequest::createOpenRequest): Deleted.
+ * Modules/indexeddb/IDBOpenDBRequest.h:
+
+ * Modules/indexeddb/IDBRequest.cpp:
+ (WebCore::IDBRequest::IDBRequest):
+ (WebCore::IDBRequest::connectionToServer):
+ * Modules/indexeddb/IDBRequest.h:
+ (WebCore::IDBRequest::connection): Deleted.
+
+ * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+ (WebCore::IDBClient::IDBConnectionProxy::IDBConnectionProxy):
+ (WebCore::IDBClient::IDBConnectionProxy::connectionToServer):
+ (WebCore::IDBClient::IDBConnectionProxy::openDatabase):
+ (WebCore::IDBClient::IDBConnectionProxy::deleteDatabase):
+ * Modules/indexeddb/client/IDBConnectionProxy.h:
+ (WebCore::IDBClient::IDBConnectionProxy::serverConnectionIdentifier):
+
+ * Modules/indexeddb/shared/IDBResourceIdentifier.cpp:
+ (WebCore::IDBResourceIdentifier::IDBResourceIdentifier):
+ * Modules/indexeddb/shared/IDBResourceIdentifier.h:
+
2016-04-20 John Wilander <[email protected]>
Add Subresource Integrity as "Under consideration".
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp 2016-04-21 04:42:17 UTC (rev 199804)
@@ -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,6 +29,8 @@
#if ENABLE(INDEXED_DATABASE)
#include "DOMError.h"
+#include "IDBConnectionProxy.h"
+#include "IDBConnectionToServer.h"
#include "IDBDatabase.h"
#include "IDBError.h"
#include "IDBRequestCompletionEvent.h"
@@ -36,23 +38,32 @@
#include "IDBTransaction.h"
#include "IDBVersionChangeEvent.h"
#include "Logging.h"
+#include "ScriptExecutionContext.h"
namespace WebCore {
-Ref<IDBOpenDBRequest> IDBOpenDBRequest::createDeleteRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)
+RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::maybeCreateDeleteRequest(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)
{
ASSERT(databaseIdentifier.isValid());
- return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, 0, IndexedDB::RequestType::Delete));
+ auto* proxy = context.idbConnectionProxy();
+ if (!proxy)
+ return nullptr;
+
+ return adoptRef(new IDBOpenDBRequest(context, proxy->serverConnectionIdentifier(), databaseIdentifier, 0, IndexedDB::RequestType::Delete));
}
-Ref<IDBOpenDBRequest> IDBOpenDBRequest::createOpenRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
+RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::maybeCreateOpenRequest(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version)
{
ASSERT(databaseIdentifier.isValid());
- return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, version, IndexedDB::RequestType::Open));
+ auto* proxy = context.idbConnectionProxy();
+ if (!proxy)
+ return nullptr;
+
+ return adoptRef(new IDBOpenDBRequest(context, proxy->serverConnectionIdentifier(), databaseIdentifier, version, IndexedDB::RequestType::Open));
}
-IDBOpenDBRequest::IDBOpenDBRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)
- : IDBRequest(connection, context)
+IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, uint64_t serverConnectionIdentifier, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)
+ : IDBRequest(context, serverConnectionIdentifier)
, m_databaseIdentifier(databaseIdentifier)
, m_version(version)
{
@@ -117,10 +128,11 @@
{
LOG(IndexedDB, "IDBOpenDBRequest::onSuccess()");
- if (!scriptExecutionContext())
+ auto* connection = connectionToServer();
+ if (!connection)
return;
- setResult(IDBDatabase::create(*scriptExecutionContext(), connection(), resultData));
+ setResult(IDBDatabase::create(*scriptExecutionContext(), *connection, resultData));
m_isDone = true;
enqueueEvent(IDBRequestCompletionEvent::create(eventNames().successEvent, false, false, *this));
@@ -128,7 +140,11 @@
void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
{
- Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connection(), resultData);
+ auto* connection = connectionToServer();
+ if (!connection)
+ return;
+
+ Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), *connection, resultData);
Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this);
ASSERT(transaction->info().mode() == IndexedDB::TransactionMode::VersionChange);
@@ -163,16 +179,20 @@
{
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());
+ connection->abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue());
break;
case IDBResultType::OpenDatabaseUpgradeNeeded:
- connection().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());
+ connection->abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());
break;
default:
break;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h 2016-04-21 04:42:17 UTC (rev 199804)
@@ -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
@@ -36,8 +36,8 @@
class IDBOpenDBRequest final : public IDBRequest {
public:
- static Ref<IDBOpenDBRequest> createDeleteRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&);
- static Ref<IDBOpenDBRequest> createOpenRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);
+ static RefPtr<IDBOpenDBRequest> maybeCreateDeleteRequest(ScriptExecutionContext&, const IDBDatabaseIdentifier&);
+ static RefPtr<IDBOpenDBRequest> maybeCreateOpenRequest(ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);
virtual ~IDBOpenDBRequest();
@@ -52,7 +52,7 @@
void fireErrorAfterVersionChangeCompletion();
private:
- IDBOpenDBRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType);
+ IDBOpenDBRequest(ScriptExecutionContext&, uint64_t serverConnectionIdentifier, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType);
bool dispatchEvent(Event&) final;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp 2016-04-21 04:42:17 UTC (rev 199804)
@@ -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
@@ -32,6 +32,7 @@
#include "Event.h"
#include "EventQueue.h"
#include "IDBBindingUtilities.h"
+#include "IDBConnectionProxy.h"
#include "IDBCursor.h"
#include "IDBDatabase.h"
#include "IDBDatabaseException.h"
@@ -68,10 +69,9 @@
return adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction));
}
-IDBRequest::IDBRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context)
+IDBRequest::IDBRequest(ScriptExecutionContext& context, uint64_t connectionIdentifier)
: ActiveDOMObject(&context)
- , m_connection(connection)
- , m_resourceIdentifier(connection)
+ , m_resourceIdentifier(connectionIdentifier)
{
suspendIfNeeded();
}
@@ -79,7 +79,6 @@
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction)
: ActiveDOMObject(&context)
, m_transaction(&transaction)
- , m_connection(transaction.serverConnection())
, m_resourceIdentifier(transaction.serverConnection())
, m_objectStoreSource(&objectStore)
{
@@ -89,7 +88,6 @@
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
: ActiveDOMObject(&context)
, m_transaction(&transaction)
- , m_connection(transaction.serverConnection())
, m_resourceIdentifier(transaction.serverConnection())
, m_objectStoreSource(cursor.objectStore())
, m_indexSource(cursor.index())
@@ -103,7 +101,6 @@
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction)
: ActiveDOMObject(&context)
, m_transaction(&transaction)
- , m_connection(transaction.serverConnection())
, m_resourceIdentifier(transaction.serverConnection())
, m_indexSource(&index)
{
@@ -410,6 +407,17 @@
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 (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h 2016-04-21 04:42:17 UTC (rev 199804)
@@ -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
@@ -104,15 +104,18 @@
bool hasPendingActivity() const final;
protected:
- IDBRequest(IDBClient::IDBConnectionToServer&, ScriptExecutionContext&);
+ IDBRequest(ScriptExecutionContext&, uint64_t connectionIdentifier);
void enqueueEvent(Ref<Event>&&);
bool dispatchEvent(Event&) override;
- IDBClient::IDBConnectionToServer& connection() { return m_connection; }
-
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();
+
// FIXME: Protected data members aren't great for maintainability.
// Consider adding protected helper functions and making these private.
bool m_isDone { false };
@@ -154,7 +157,6 @@
RefPtr<IDBDatabase> m_databaseResult;
IDBError m_idbError;
- IDBClient::IDBConnectionToServer& m_connection;
IDBResourceIdentifier m_resourceIdentifier;
// Could consider storing these three in a union or union-like class instead.
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-04-21 04:42:17 UTC (rev 199804)
@@ -36,9 +36,20 @@
IDBConnectionProxy::IDBConnectionProxy(IDBConnectionToServer& connection)
: m_connectionToServer(connection)
+ , m_serverConnectionIdentifier(connection.identifier())
{
+ ASSERT(isMainThread());
}
+// 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.
+IDBConnectionToServer& IDBConnectionProxy::connectionToServer()
+{
+ ASSERT(isMainThread());
+ return m_connectionToServer.get();
+}
+
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,
@@ -46,10 +57,12 @@
if (!isMainThread())
return nullptr;
- auto request = IDBOpenDBRequest::createOpenRequest(m_connectionToServer.get(), context, databaseIdentifier, version);
- m_connectionToServer->openDatabase(request.get());
+ auto request = IDBOpenDBRequest::maybeCreateOpenRequest(context, databaseIdentifier, version);
+ if (!request)
+ return nullptr;
- return adoptRef(&request.leakRef());
+ m_connectionToServer->openDatabase(*request);
+ return request;
}
RefPtr<IDBOpenDBRequest> IDBConnectionProxy::deleteDatabase(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)
@@ -59,10 +72,12 @@
if (!isMainThread())
return nullptr;
- auto request = IDBOpenDBRequest::createDeleteRequest(m_connectionToServer.get(), context, databaseIdentifier);
- m_connectionToServer->deleteDatabase(request.get());
+ auto request = IDBOpenDBRequest::maybeCreateDeleteRequest(context, databaseIdentifier);
+ if (!request)
+ return nullptr;
- return adoptRef(&request.leakRef());
+ m_connectionToServer->deleteDatabase(*request);
+ return request;
}
} // namesapce IDBClient
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h 2016-04-21 04:42:17 UTC (rev 199804)
@@ -38,14 +38,23 @@
namespace IDBClient {
class IDBConnectionProxy {
+ WTF_MAKE_NONCOPYABLE(IDBConnectionProxy);
public:
IDBConnectionProxy(IDBConnectionToServer&);
RefPtr<IDBOpenDBRequest> openDatabase(ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);
RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const IDBDatabaseIdentifier&);
+ uint64_t serverConnectionIdentifier() const { return m_serverConnectionIdentifier; }
+
+ // 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.
+ IDBConnectionToServer& connectionToServer();
+
private:
Ref<IDBConnectionToServer> m_connectionToServer;
+ uint64_t m_serverConnectionIdentifier;
};
} // namespace IDBClient
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp 2016-04-21 04:42:17 UTC (rev 199804)
@@ -53,6 +53,13 @@
{
}
+IDBResourceIdentifier::IDBResourceIdentifier(uint64_t connectionIdentifier)
+ : m_idbConnectionIdentifier(connectionIdentifier)
+ , m_resourceNumber(nextClientResourceNumber())
+{
+}
+
+
IDBResourceIdentifier::IDBResourceIdentifier(uint64_t connectionIdentifier, uint64_t resourceIdentifier)
: m_idbConnectionIdentifier(connectionIdentifier)
, m_resourceNumber(resourceIdentifier)
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h (199803 => 199804)
--- trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h 2016-04-21 04:40:18 UTC (rev 199803)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h 2016-04-21 04:42:17 UTC (rev 199804)
@@ -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 IDBResourceIdentifier_h
-#define IDBResourceIdentifier_h
+#pragma once
#if ENABLE(INDEXED_DATABASE)
@@ -48,6 +47,10 @@
IDBResourceIdentifier(const IDBClient::IDBConnectionToServer&, const IDBRequest&);
explicit IDBResourceIdentifier(const IDBServer::IDBConnectionToClient&);
+ // FIXME: This constructor will be needed during the development of IDB-in-Workers.
+ // It should be removed when no longer necessary.
+ explicit IDBResourceIdentifier(uint64_t connectionIdentifier);
+
static IDBResourceIdentifier deletedValue();
WEBCORE_EXPORT bool isHashTableDeletedValue() const;
@@ -149,4 +152,3 @@
} // namespace WTF
#endif // ENABLE(INDEXED_DATABASE)
-#endif // IDBResourceIdentifier_h