Changeset 199804 in webkit
- Timestamp:
- Apr 20, 2016 9:42:17 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r199802 r199804 1 2016-04-20 Brady Eidson <beidson@apple.com> 2 3 Modern IDB (Workers): Remove IDBRequest/IDBOpenDBRequest's requirement to get an IDBServerConnection around. 4 https://bugs.webkit.org/show_bug.cgi?id=156826 5 6 Reviewed by Alex Christensen. 7 8 No new tests (No behavior change, existing tests pass). 9 10 This doesn't appear to do much but make things a little more complicated, but it's the first of a few 11 small pushes in the right direction. 12 13 * Modules/indexeddb/IDBOpenDBRequest.cpp: 14 (WebCore::IDBOpenDBRequest::maybeCreateDeleteRequest): 15 (WebCore::IDBOpenDBRequest::maybeCreateOpenRequest): 16 (WebCore::IDBOpenDBRequest::IDBOpenDBRequest): 17 (WebCore::IDBOpenDBRequest::onSuccess): 18 (WebCore::IDBOpenDBRequest::onUpgradeNeeded): 19 (WebCore::IDBOpenDBRequest::requestCompleted): 20 (WebCore::IDBOpenDBRequest::createDeleteRequest): Deleted. 21 (WebCore::IDBOpenDBRequest::createOpenRequest): Deleted. 22 * Modules/indexeddb/IDBOpenDBRequest.h: 23 24 * Modules/indexeddb/IDBRequest.cpp: 25 (WebCore::IDBRequest::IDBRequest): 26 (WebCore::IDBRequest::connectionToServer): 27 * Modules/indexeddb/IDBRequest.h: 28 (WebCore::IDBRequest::connection): Deleted. 29 30 * Modules/indexeddb/client/IDBConnectionProxy.cpp: 31 (WebCore::IDBClient::IDBConnectionProxy::IDBConnectionProxy): 32 (WebCore::IDBClient::IDBConnectionProxy::connectionToServer): 33 (WebCore::IDBClient::IDBConnectionProxy::openDatabase): 34 (WebCore::IDBClient::IDBConnectionProxy::deleteDatabase): 35 * Modules/indexeddb/client/IDBConnectionProxy.h: 36 (WebCore::IDBClient::IDBConnectionProxy::serverConnectionIdentifier): 37 38 * Modules/indexeddb/shared/IDBResourceIdentifier.cpp: 39 (WebCore::IDBResourceIdentifier::IDBResourceIdentifier): 40 * Modules/indexeddb/shared/IDBResourceIdentifier.h: 41 1 42 2016-04-20 John Wilander <wilander@apple.com> 2 43 -
trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
r199668 r199804 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 31 31 #include "DOMError.h" 32 #include "IDBConnectionProxy.h" 33 #include "IDBConnectionToServer.h" 32 34 #include "IDBDatabase.h" 33 35 #include "IDBError.h" … … 37 39 #include "IDBVersionChangeEvent.h" 38 40 #include "Logging.h" 41 #include "ScriptExecutionContext.h" 39 42 40 43 namespace WebCore { 41 44 42 Ref <IDBOpenDBRequest> IDBOpenDBRequest::createDeleteRequest(IDBClient::IDBConnectionToServer& connection,ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier)45 RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::maybeCreateDeleteRequest(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier) 43 46 { 44 47 ASSERT(databaseIdentifier.isValid()); 45 return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, 0, IndexedDB::RequestType::Delete)); 46 } 47 48 Ref<IDBOpenDBRequest> IDBOpenDBRequest::createOpenRequest(IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version) 48 auto* proxy = context.idbConnectionProxy(); 49 if (!proxy) 50 return nullptr; 51 52 return adoptRef(new IDBOpenDBRequest(context, proxy->serverConnectionIdentifier(), databaseIdentifier, 0, IndexedDB::RequestType::Delete)); 53 } 54 55 RefPtr<IDBOpenDBRequest> IDBOpenDBRequest::maybeCreateOpenRequest(ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version) 49 56 { 50 57 ASSERT(databaseIdentifier.isValid()); 51 return adoptRef(*new IDBOpenDBRequest(connection, context, databaseIdentifier, version, IndexedDB::RequestType::Open)); 58 auto* proxy = context.idbConnectionProxy(); 59 if (!proxy) 60 return nullptr; 61 62 return adoptRef(new IDBOpenDBRequest(context, proxy->serverConnectionIdentifier(), databaseIdentifier, version, IndexedDB::RequestType::Open)); 52 63 } 53 64 54 IDBOpenDBRequest::IDBOpenDBRequest( IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType)55 : IDBRequest(con nection, context)65 IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, uint64_t serverConnectionIdentifier, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version, IndexedDB::RequestType requestType) 66 : IDBRequest(context, serverConnectionIdentifier) 56 67 , m_databaseIdentifier(databaseIdentifier) 57 68 , m_version(version) … … 118 129 LOG(IndexedDB, "IDBOpenDBRequest::onSuccess()"); 119 130 120 if (!scriptExecutionContext()) 121 return; 122 123 setResult(IDBDatabase::create(*scriptExecutionContext(), connection(), resultData)); 131 auto* connection = connectionToServer(); 132 if (!connection) 133 return; 134 135 setResult(IDBDatabase::create(*scriptExecutionContext(), *connection, resultData)); 124 136 m_isDone = true; 125 137 … … 129 141 void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData) 130 142 { 131 Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connection(), resultData); 143 auto* connection = connectionToServer(); 144 if (!connection) 145 return; 146 147 Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), *connection, resultData); 132 148 Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this); 133 149 … … 163 179 { 164 180 LOG(IndexedDB, "IDBOpenDBRequest::requestCompleted"); 181 182 auto* connection = connectionToServer(); 183 if (!connection) 184 return; 165 185 166 186 // If an Open request was completed after the page has navigated, leaving this request … … 170 190 switch (data.type()) { 171 191 case IDBResultType::OpenDatabaseSuccess: 172 connection ().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue());192 connection->abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), IDBResourceIdentifier::emptyValue()); 173 193 break; 174 194 case IDBResultType::OpenDatabaseUpgradeNeeded: 175 connection ().abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier());195 connection->abortOpenAndUpgradeNeeded(data.databaseConnectionIdentifier(), data.transactionInfo().identifier()); 176 196 break; 177 197 default: -
trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.h
r199668 r199804 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 class IDBOpenDBRequest final : public IDBRequest { 38 38 public: 39 static Ref <IDBOpenDBRequest> createDeleteRequest(IDBClient::IDBConnectionToServer&,ScriptExecutionContext&, const IDBDatabaseIdentifier&);40 static Ref <IDBOpenDBRequest> createOpenRequest(IDBClient::IDBConnectionToServer&,ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version);39 static RefPtr<IDBOpenDBRequest> maybeCreateDeleteRequest(ScriptExecutionContext&, const IDBDatabaseIdentifier&); 40 static RefPtr<IDBOpenDBRequest> maybeCreateOpenRequest(ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version); 41 41 42 42 virtual ~IDBOpenDBRequest(); … … 53 53 54 54 private: 55 IDBOpenDBRequest( IDBClient::IDBConnectionToServer&, ScriptExecutionContext&, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType);55 IDBOpenDBRequest(ScriptExecutionContext&, uint64_t serverConnectionIdentifier, const IDBDatabaseIdentifier&, uint64_t version, IndexedDB::RequestType); 56 56 57 57 bool dispatchEvent(Event&) final; -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp
r199668 r199804 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 33 33 #include "EventQueue.h" 34 34 #include "IDBBindingUtilities.h" 35 #include "IDBConnectionProxy.h" 35 36 #include "IDBCursor.h" 36 37 #include "IDBDatabase.h" … … 69 70 } 70 71 71 IDBRequest::IDBRequest( IDBClient::IDBConnectionToServer& connection, ScriptExecutionContext& context)72 IDBRequest::IDBRequest(ScriptExecutionContext& context, uint64_t connectionIdentifier) 72 73 : ActiveDOMObject(&context) 73 , m_connection(connection) 74 , m_resourceIdentifier(connection) 74 , m_resourceIdentifier(connectionIdentifier) 75 75 { 76 76 suspendIfNeeded(); … … 80 80 : ActiveDOMObject(&context) 81 81 , m_transaction(&transaction) 82 , m_connection(transaction.serverConnection())83 82 , m_resourceIdentifier(transaction.serverConnection()) 84 83 , m_objectStoreSource(&objectStore) … … 90 89 : ActiveDOMObject(&context) 91 90 , m_transaction(&transaction) 92 , m_connection(transaction.serverConnection())93 91 , m_resourceIdentifier(transaction.serverConnection()) 94 92 , m_objectStoreSource(cursor.objectStore()) … … 104 102 : ActiveDOMObject(&context) 105 103 , m_transaction(&transaction) 106 , m_connection(transaction.serverConnection())107 104 , m_resourceIdentifier(transaction.serverConnection()) 108 105 , m_indexSource(&index) … … 411 408 } 412 409 410 // FIXME: Temporarily required during bringup of IDB-in-Workers. 411 // Once all IDB object reliance on the IDBConnectionToServer has been shifted to reliance on 412 // IDBConnectionProxy, remove this. 413 IDBClient::IDBConnectionToServer* IDBRequest::connectionToServer() 414 { 415 ASSERT(isMainThread()); 416 auto* context = scriptExecutionContext(); 417 auto* proxy = context ? context->idbConnectionProxy() : nullptr; 418 return proxy ? &proxy->connectionToServer() : nullptr; 419 } 420 413 421 } // namespace WebCore 414 422 -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.h
r199668 r199804 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 105 105 106 106 protected: 107 IDBRequest( IDBClient::IDBConnectionToServer&, ScriptExecutionContext&);107 IDBRequest(ScriptExecutionContext&, uint64_t connectionIdentifier); 108 108 109 109 void enqueueEvent(Ref<Event>&&); 110 110 bool dispatchEvent(Event&) override; 111 111 112 IDBClient::IDBConnectionToServer& connection() { return m_connection; }112 void setResult(Ref<IDBDatabase>&&); 113 113 114 void setResult(Ref<IDBDatabase>&&); 114 // FIXME: Temporarily required during bringup of IDB-in-Workers. 115 // Once all IDB object reliance on the IDBConnectionToServer has been shifted to reliance on 116 // IDBConnectionProxy, remove this. 117 IDBClient::IDBConnectionToServer* connectionToServer(); 115 118 116 119 // FIXME: Protected data members aren't great for maintainability. … … 155 158 156 159 IDBError m_idbError; 157 IDBClient::IDBConnectionToServer& m_connection;158 160 IDBResourceIdentifier m_resourceIdentifier; 159 161 -
trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp
r199797 r199804 37 37 IDBConnectionProxy::IDBConnectionProxy(IDBConnectionToServer& connection) 38 38 : m_connectionToServer(connection) 39 , m_serverConnectionIdentifier(connection.identifier()) 39 40 { 41 ASSERT(isMainThread()); 42 } 43 44 // FIXME: Temporarily required during bringup of IDB-in-Workers. 45 // Once all IDB object reliance on the IDBConnectionToServer has been shifted to reliance on 46 // IDBConnectionProxy, remove this. 47 IDBConnectionToServer& IDBConnectionProxy::connectionToServer() 48 { 49 ASSERT(isMainThread()); 50 return m_connectionToServer.get(); 40 51 } 41 52 … … 47 58 return nullptr; 48 59 49 auto request = IDBOpenDBRequest::createOpenRequest(m_connectionToServer.get(), context, databaseIdentifier, version); 50 m_connectionToServer->openDatabase(request.get()); 60 auto request = IDBOpenDBRequest::maybeCreateOpenRequest(context, databaseIdentifier, version); 61 if (!request) 62 return nullptr; 51 63 52 return adoptRef(&request.leakRef()); 64 m_connectionToServer->openDatabase(*request); 65 return request; 53 66 } 54 67 … … 60 73 return nullptr; 61 74 62 auto request = IDBOpenDBRequest::createDeleteRequest(m_connectionToServer.get(), context, databaseIdentifier); 63 m_connectionToServer->deleteDatabase(request.get()); 75 auto request = IDBOpenDBRequest::maybeCreateDeleteRequest(context, databaseIdentifier); 76 if (!request) 77 return nullptr; 64 78 65 return adoptRef(&request.leakRef()); 79 m_connectionToServer->deleteDatabase(*request); 80 return request; 66 81 } 67 82 -
trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h
r199797 r199804 39 39 40 40 class IDBConnectionProxy { 41 WTF_MAKE_NONCOPYABLE(IDBConnectionProxy); 41 42 public: 42 43 IDBConnectionProxy(IDBConnectionToServer&); … … 45 46 RefPtr<IDBOpenDBRequest> deleteDatabase(ScriptExecutionContext&, const IDBDatabaseIdentifier&); 46 47 48 uint64_t serverConnectionIdentifier() const { return m_serverConnectionIdentifier; } 49 50 // FIXME: Temporarily required during bringup of IDB-in-Workers. 51 // Once all IDB object reliance on the IDBConnectionToServer has been shifted to reliance on 52 // IDBConnectionProxy, remove this. 53 IDBConnectionToServer& connectionToServer(); 54 47 55 private: 48 56 Ref<IDBConnectionToServer> m_connectionToServer; 57 uint64_t m_serverConnectionIdentifier; 49 58 }; 50 59 -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.cpp
r198762 r199804 54 54 } 55 55 56 IDBResourceIdentifier::IDBResourceIdentifier(uint64_t connectionIdentifier) 57 : m_idbConnectionIdentifier(connectionIdentifier) 58 , m_resourceNumber(nextClientResourceNumber()) 59 { 60 } 61 62 56 63 IDBResourceIdentifier::IDBResourceIdentifier(uint64_t connectionIdentifier, uint64_t resourceIdentifier) 57 64 : m_idbConnectionIdentifier(connectionIdentifier) -
trunk/Source/WebCore/Modules/indexeddb/shared/IDBResourceIdentifier.h
r198762 r199804 1 1 /* 2 * Copyright (C) 2015 Apple Inc. All rights reserved.2 * Copyright (C) 2015, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #ifndef IDBResourceIdentifier_h 27 #define IDBResourceIdentifier_h 26 #pragma once 28 27 29 28 #if ENABLE(INDEXED_DATABASE) … … 48 47 IDBResourceIdentifier(const IDBClient::IDBConnectionToServer&, const IDBRequest&); 49 48 explicit IDBResourceIdentifier(const IDBServer::IDBConnectionToClient&); 49 50 // FIXME: This constructor will be needed during the development of IDB-in-Workers. 51 // It should be removed when no longer necessary. 52 explicit IDBResourceIdentifier(uint64_t connectionIdentifier); 50 53 51 54 static IDBResourceIdentifier deletedValue(); … … 150 153 151 154 #endif // ENABLE(INDEXED_DATABASE) 152 #endif // IDBResourceIdentifier_h
Note: See TracChangeset
for help on using the changeset viewer.