Changeset 223191 in webkit
- Timestamp:
- Oct 11, 2017 10:27:08 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 31 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r223190 r223191 1 2017-10-11 Brady Eidson <beidson@apple.com> 2 3 Add a SW context process (where SW scripts will actually execute). 4 https://bugs.webkit.org/show_bug.cgi?id=178156 5 6 Reviewed by Andy Estes. 7 8 * http/tests/workers/service/basic-register-exceptions-expected.txt: 9 * http/tests/workers/service/basic-register-expected.txt: 10 * http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt: 11 1 12 2017-10-11 Joanmarie Diggs <jdiggs@igalia.com> 2 13 -
trunk/LayoutTests/http/tests/workers/service/basic-register-exceptions-expected.txt
r222980 r223191 5 5 CONSOLE MESSAGE: line 60: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() must be either HTTP or HTTPS 6 6 CONSOLE MESSAGE: line 70: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() cannot have a path that contains '%2f' or '%5c' 7 CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/image-mime-type.php fetched with 0 characters, but we're not using the result yet7 CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Failed to start service worker script of length 0 8 8 CONSOLE MESSAGE: line 80: Registration failed with error: SecurityError: Script origin does not match the registering client's origin 9 9 CONSOLE MESSAGE: line 91: Registration failed with error: SecurityError: Scope origin does not match the registering client's origin -
trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt
r222980 r223191 1 CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker.js fetched with 41 characters, but we're not using the result yet2 CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker-doesnt-exist.js fetched with 0 characters, but we're not using the result yet1 CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Failed to start service worker script of length 41 2 CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Failed to start service worker script of length 0 3 3 -
trunk/LayoutTests/http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt
r221198 r223191 1 ALERT: Done1 ALERT: Unexpected error received from server: UnknownError: Failed to start service worker script of length 41 2 2 -
trunk/Source/WebCore/ChangeLog
r223190 r223191 1 2017-10-11 Brady Eidson <beidson@apple.com> 2 3 Add a SW context process (where SW scripts will actually execute). 4 https://bugs.webkit.org/show_bug.cgi?id=178156 5 6 Reviewed by Andy Estes. 7 8 No new tests (Covered by changes to existing tests). 9 10 This patch adds an auxiliary "ServiceWorker context" WebProcess to a WebProcessPool. 11 12 This process is where ServiceWorker scripts will execute, separate from the client WebProcess 13 hosting the page(s) they are serving. 14 15 This patch also adds all of the plumbing to pass along a fetched service worker script to this 16 context WebProcess, as well as message back failure to actually start the script so we can test. 17 18 Touches lots of code sites but is basically just a lot of plumbing. 19 20 * WebCore.xcodeproj/project.pbxproj: 21 22 * workers/service/ServiceWorkerContextData.h: Copied from Source/WebCore/workers/service/server/SWServerWorker.h. 23 (WebCore::ServiceWorkerContextData::encode const): 24 (WebCore::ServiceWorkerContextData::decode): 25 26 * workers/service/server/SWServer.cpp: 27 (WebCore::SWServer::Connection::finishFetchingScriptInServer): 28 (WebCore::SWServer::Connection::scriptContextFailedToStart): 29 (WebCore::SWServer::scriptFetchFinished): 30 (WebCore::SWServer::scriptContextFailedToStart): 31 (WebCore::SWServer::createWorker): 32 * workers/service/server/SWServer.h: 33 34 * workers/service/server/SWServerRegistration.cpp: 35 (WebCore::SWServerRegistration::scriptFetchFinished): 36 (WebCore::SWServerRegistration::scriptContextFailedToStart): 37 * workers/service/server/SWServerRegistration.h: 38 39 * workers/service/server/SWServerWorker.cpp: 40 (WebCore::SWServerWorker::SWServerWorker): 41 (WebCore::SWServerWorker::~SWServerWorker): 42 * workers/service/server/SWServerWorker.h: 43 (WebCore::SWServerWorker::create): 44 (WebCore::SWServerWorker::scriptURL const): 45 (WebCore::SWServerWorker::script const): 46 (WebCore::SWServerWorker::type const): 47 (WebCore::SWServerWorker::workerID const): 48 1 49 2017-10-11 Joanmarie Diggs <jdiggs@igalia.com> 2 50 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r223076 r223191 2465 2465 51C81B890C4422F70019ECE3 /* FTPDirectoryParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */; }; 2466 2466 51C81B8A0C4422F70019ECE3 /* FTPDirectoryParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */; }; 2467 51CA7EE91F883390003D3131 /* ServiceWorkerContextData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2467 2468 51CBFC990D10E483002DBF51 /* CachedFramePlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2468 2469 51D1248B1E73627F002B2820 /* NetworkStorageSessionCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */; }; … … 10364 10365 51C81B870C4422F70019ECE3 /* FTPDirectoryParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FTPDirectoryParser.cpp; sourceTree = "<group>"; }; 10365 10366 51C81B880C4422F70019ECE3 /* FTPDirectoryParser.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FTPDirectoryParser.h; sourceTree = "<group>"; }; 10367 51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerContextData.h; sourceTree = "<group>"; }; 10366 10368 51CBFC980D10E483002DBF51 /* CachedFramePlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedFramePlatformData.h; sourceTree = "<group>"; }; 10367 10369 51D1248A1E73625C002B2820 /* NetworkStorageSessionCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkStorageSessionCocoa.mm; sourceTree = "<group>"; }; … … 19213 19215 51F175571F3EBC0C00C74950 /* ServiceWorkerContainer.h */, 19214 19216 51F175561F3EBC0C00C74950 /* ServiceWorkerContainer.idl */, 19217 51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */, 19215 19218 517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */, 19216 19219 51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */, … … 30153 30156 51F1755D1F3EBC8300C74950 /* ServiceWorker.h in Headers */, 30154 30157 51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */, 30158 51CA7EE91F883390003D3131 /* ServiceWorkerContextData.h in Headers */, 30155 30159 517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */, 30156 30160 51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */, -
trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h
r223190 r223191 26 26 #pragma once 27 27 28 #include "ServiceWorkerRegistrationKey.h" 29 28 30 #if ENABLE(SERVICE_WORKER) 29 30 #include "URL.h"31 31 32 32 namespace WebCore { 33 33 34 class SWServerWorker { 35 public: 36 SWServerWorker(const URL&); 37 SWServerWorker(const SWServerWorker&) = delete; 38 ~SWServerWorker(); 39 const URL& scriptURL() const { return m_scriptURL; } 34 struct ServiceWorkerContextData { 35 ServiceWorkerRegistrationKey registrationKey; 36 String workerID; 37 String script; 38 39 template<class Encoder> void encode(Encoder&) const; 40 template<class Decoder> static std::optional<ServiceWorkerContextData> decode(Decoder&); 41 }; 40 42 41 private: 42 URL m_scriptURL; 43 }; 43 template<class Encoder> 44 void ServiceWorkerContextData::encode(Encoder& encoder) const 45 { 46 encoder << registrationKey << workerID << script; 47 } 48 49 template<class Decoder> 50 std::optional<ServiceWorkerContextData> ServiceWorkerContextData::decode(Decoder& decoder) 51 { 52 auto registrationKey = ServiceWorkerRegistrationKey::decode(decoder); 53 if (!registrationKey) 54 return std::nullopt; 55 56 String workerID; 57 if (!decoder.decode(workerID)) 58 return std::nullopt; 59 60 String script; 61 if (!decoder.decode(script)) 62 return std::nullopt; 63 64 return {{ WTFMove(*registrationKey), WTFMove(workerID), WTFMove(script) }}; 65 } 44 66 45 67 } // namespace WebCore -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r222980 r223191 33 33 #include "Logging.h" 34 34 #include "SWServerRegistration.h" 35 #include "SWServerWorker.h" 36 #include "ServiceWorkerContextData.h" 35 37 #include "ServiceWorkerFetchResult.h" 36 38 #include "ServiceWorkerJobData.h" 39 #include <wtf/UUID.h> 37 40 #include <wtf/text/WTFString.h> 38 41 … … 76 79 void SWServer::Connection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result) 77 80 { 78 m_server.scriptFetchFinished(result); 81 m_server.scriptFetchFinished(*this, result); 82 } 83 84 void SWServer::Connection::scriptContextFailedToStart(const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message) 85 { 86 m_server.scriptContextFailedToStart(*this, registrationKey, workerID, message); 79 87 } 80 88 … … 129 137 } 130 138 131 void SWServer::scriptFetchFinished( const ServiceWorkerFetchResult& result)139 void SWServer::scriptFetchFinished(Connection& connection, const ServiceWorkerFetchResult& result) 132 140 { 133 141 LOG(ServiceWorker, "Server handling scriptFetchFinished for current job %" PRIu64 "-%" PRIu64 " in client", result.connectionIdentifier, result.jobIdentifier); … … 139 147 return; 140 148 141 registration->scriptFetchFinished(result); 149 registration->scriptFetchFinished(connection, result); 150 } 151 152 void SWServer::scriptContextFailedToStart(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message) 153 { 154 ASSERT(m_connections.contains(connection.identifier())); 155 156 if (auto* registration = m_registrations.get(registrationKey)) 157 registration->scriptContextFailedToStart(connection, workerID, message); 158 } 159 160 Ref<SWServerWorker> SWServer::createWorker(Connection& connection, const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type) 161 { 162 String workerID = createCanonicalUUIDString(); 163 164 auto result = m_workersByID.add(workerID, SWServerWorker::create(registrationKey, url, script, type, workerID)); 165 ASSERT(result.isNewEntry); 166 167 connection.startServiceWorkerContext({ registrationKey, workerID, script }); 168 169 return result.iterator->value.get(); 142 170 } 143 171 -
trunk/Source/WebCore/workers/service/server/SWServer.h
r222980 r223191 28 28 #if ENABLE(SERVICE_WORKER) 29 29 30 #include "SWServerRegistration.h"31 30 #include "ServiceWorkerJob.h" 32 31 #include "ServiceWorkerRegistrationKey.h" … … 43 42 44 43 class SWServerRegistration; 44 class SWServerWorker; 45 45 struct ExceptionData; 46 struct ServiceWorkerContextData; 46 47 struct ServiceWorkerFetchResult; 47 48 struct ServiceWorkerRegistrationData; … … 54 55 WEBCORE_EXPORT virtual ~Connection(); 55 56 57 WEBCORE_EXPORT void scriptContextFailedToStart(const ServiceWorkerRegistrationKey&, const String& workerID, const String& message); 58 56 59 protected: 57 60 WEBCORE_EXPORT Connection(SWServer&, uint64_t identifier); … … 62 65 63 66 private: 67 // Messages to the client WebProcess 64 68 virtual void rejectJobInClient(uint64_t jobIdentifier, const ExceptionData&) = 0; 65 69 virtual void resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0; 66 70 virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0; 71 72 // Messages to the SW host WebProcess 73 virtual void startServiceWorkerContext(const ServiceWorkerContextData&) = 0; 67 74 68 75 SWServer& m_server; … … 80 87 void postTaskReply(CrossThreadTask&&); 81 88 89 Ref<SWServerWorker> createWorker(Connection&, const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType); 90 82 91 private: 83 92 void registerConnection(Connection&); … … 87 96 void handleTaskRepliesOnMainThread(); 88 97 89 void scriptFetchFinished(const ServiceWorkerFetchResult&); 98 void scriptFetchFinished(Connection&, const ServiceWorkerFetchResult&); 99 void scriptContextFailedToStart(Connection&, const ServiceWorkerRegistrationKey&, const String& workerID, const String& message); 90 100 91 101 HashMap<uint64_t, Connection*> m_connections; 92 102 HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations; 103 104 HashMap<String, Ref<SWServerWorker>> m_workersByID; 93 105 94 106 RefPtr<Thread> m_taskThread; -
trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp
r222980 r223191 65 65 } 66 66 67 void SWServerRegistration::scriptFetchFinished( const ServiceWorkerFetchResult& result)67 void SWServerRegistration::scriptFetchFinished(SWServer::Connection& connection, const ServiceWorkerFetchResult& result) 68 68 { 69 69 ASSERT(m_currentJob && m_currentJob->identifier() == result.jobIdentifier); 70 70 71 // FIXME: We fetched the script contents but don't do anything with them yet. 72 // These errors are for testing the current state of the feature. 73 74 String message; 75 if (result.scriptError.isNull()) 76 message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetched with ", String::number(result.script.length()), " characters, but we're not using the result yet"); 77 else 78 message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription()); 71 if (!result.scriptError.isNull()) { 72 rejectCurrentJob(ExceptionData { UnknownError, makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription()) }); 73 74 // If newestWorker is null, invoke Clear Registration algorithm passing this registration as its argument. 75 // FIXME: We don't have "clear registration" yet. 76 77 return; 78 } 79 80 m_lastUpdateTime = currentTime(); 81 82 // FIXME: If the script data matches byte-for-byte with the existing newestWorker, 83 // then resolve and finish the job without doing anything further. 84 85 // FIXME: Support the proper worker type (classic vs module) 86 m_server.createWorker(connection, m_registrationKey, m_currentJob->scriptURL, result.script, WorkerType::Classic); 87 } 88 89 void SWServerRegistration::scriptContextFailedToStart(SWServer::Connection&, const String& workerID, const String& message) 90 { 91 ASSERT(m_currentJob); 92 UNUSED_PARAM(workerID); 79 93 80 94 rejectCurrentJob(ExceptionData { UnknownError, message }); -
trunk/Source/WebCore/workers/service/server/SWServerRegistration.h
r222980 r223191 28 28 #if ENABLE(SERVICE_WORKER) 29 29 30 #include "SWServer.h" 30 31 #include "ServiceWorkerJobData.h" 31 32 #include "ServiceWorkerRegistrationData.h" … … 48 49 49 50 void enqueueJob(const ServiceWorkerJobData&); 50 void scriptFetchFinished(const ServiceWorkerFetchResult&); 51 51 void scriptFetchFinished(SWServer::Connection&, const ServiceWorkerFetchResult&); 52 void scriptContextFailedToStart(SWServer::Connection&, const String& workerID, const String& message); 53 52 54 ServiceWorkerRegistrationData data() const; 53 55 … … 78 80 URL m_scopeURL; 79 81 std::optional<ServiceWorkerUpdateViaCache> m_updateViaCache; 82 83 double m_lastUpdateTime { 0 }; 80 84 81 85 Timer m_jobTimer; -
trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp
r221392 r223191 29 29 #if ENABLE(SERVICE_WORKER) 30 30 31 #include <wtf/MainThread.h>32 33 31 namespace WebCore { 34 32 35 SWServerWorker::SWServerWorker(const URL& url) 36 : m_scriptURL(url) 33 SWServerWorker::SWServerWorker(const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type, const String& workerID) 34 : m_registrationKey(registrationKey) 35 , m_scriptURL(url) 36 , m_script(script) 37 , m_workerID(workerID) 38 , m_type(type) 37 39 { 38 ASSERT(!isMainThread());39 40 } 40 41 41 42 SWServerWorker::~SWServerWorker() 42 43 { 43 ASSERT(!isMainThread());44 44 } 45 45 -
trunk/Source/WebCore/workers/service/server/SWServerWorker.h
r221392 r223191 28 28 #if ENABLE(SERVICE_WORKER) 29 29 30 #include "ServiceWorkerRegistrationKey.h" 30 31 #include "URL.h" 32 #include <wtf/ThreadSafeRefCounted.h> 31 33 32 34 namespace WebCore { 33 35 34 class SWServerWorker { 36 enum class WorkerType; 37 38 class SWServerWorker : public ThreadSafeRefCounted<SWServerWorker> { 35 39 public: 36 SWServerWorker(const URL&); 40 static Ref<SWServerWorker> create(const ServiceWorkerRegistrationKey& registrationKey, const URL& url, const String& script, WorkerType type, const String& workerID) 41 { 42 return adoptRef(*new SWServerWorker(registrationKey, url, script, type, workerID)); 43 } 44 37 45 SWServerWorker(const SWServerWorker&) = delete; 38 46 ~SWServerWorker(); 47 39 48 const URL& scriptURL() const { return m_scriptURL; } 49 const String& script() const { return m_script; } 50 WorkerType type() const { return m_type; } 51 const String& workerID() const { return m_workerID; } 52 53 private: 54 SWServerWorker(const ServiceWorkerRegistrationKey&, const URL&, const String& script, WorkerType, const String& workerID); 40 55 41 private: 56 ServiceWorkerRegistrationKey m_registrationKey; 42 57 URL m_scriptURL; 58 String m_script; 59 String m_workerID; 60 WorkerType m_type; 43 61 }; 44 62 -
trunk/Source/WebKit/ChangeLog
r223179 r223191 1 2017-10-11 Brady Eidson <beidson@apple.com> 2 3 Add a SW context process (where SW scripts will actually execute). 4 https://bugs.webkit.org/show_bug.cgi?id=178156 5 6 Reviewed by Andy Estes. 7 8 This patch adds an auxiliary "ServiceWorker context" WebProcess to a WebProcessPool. 9 10 This process is where ServiceWorker scripts will execute, separate from the client WebProcess 11 hosting the page(s) they are serving. 12 13 This patch also adds all of the plumbing to pass along a fetched service worker script to this 14 context WebProcess, as well as message back failure to actually start the script so we can test. 15 16 Touches lots of code sites but is basically just a lot of plumbing. 17 18 * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: 19 (WebKit::WebSWServerConnection::WebSWServerConnection): 20 (WebKit::WebSWServerConnection::startServiceWorkerContext): 21 (WebKit::WebSWServerConnection::sendToContextProcess): 22 (WebKit::WebSWServerConnection::setContextConnection): 23 * StorageProcess/ServiceWorker/WebSWServerConnection.h: 24 25 * StorageProcess/StorageProcess.cpp: 26 (WebKit::StorageProcess::workerContextProcessConnection): 27 (WebKit::StorageProcess::createWorkerContextProcessConnection): 28 (WebKit::StorageProcess::didGetWorkerContextProcessConnection): 29 (WebKit::StorageProcess::serviceWorkerContextFailedToStart): 30 (WebKit::StorageProcess::registerSWServerConnection): 31 (WebKit::StorageProcess::unregisterSWServerConnection): 32 * StorageProcess/StorageProcess.h: 33 * StorageProcess/StorageProcess.messages.in: 34 35 * StorageProcess/StorageToWebProcessConnection.cpp: 36 (WebKit::StorageToWebProcessConnection::~StorageToWebProcessConnection): 37 (WebKit::StorageToWebProcessConnection::establishSWServerConnection): 38 (WebKit::StorageToWebProcessConnection::removeSWServerConnection): 39 (WebKit::StorageToWebProcessConnection::workerContextProcessConnectionCreated): 40 * StorageProcess/StorageToWebProcessConnection.h: 41 42 * UIProcess/Storage/StorageProcessProxy.cpp: 43 (WebKit::StorageProcessProxy::create): 44 (WebKit::StorageProcessProxy::StorageProcessProxy): 45 (WebKit::StorageProcessProxy::didClose): 46 (WebKit::StorageProcessProxy::getWorkerContextProcessConnection): 47 (WebKit::StorageProcessProxy::didGetWorkerContextProcessConnection): 48 * UIProcess/Storage/StorageProcessProxy.h: 49 * UIProcess/Storage/StorageProcessProxy.messages.in: 50 51 * UIProcess/WebProcessPool.cpp: 52 (WebKit::WebProcessPool::ensureStorageProcessAndWebsiteDataStore): 53 (WebKit::WebProcessPool::getWorkerContextProcessConnection): 54 (WebKit::WebProcessPool::didGetWorkerContextProcessConnection): 55 (WebKit::WebProcessPool::disconnectProcess): 56 (WebKit::WebProcessPool::createWebPage): 57 * UIProcess/WebProcessPool.h: 58 59 * UIProcess/WebProcessProxy.cpp: 60 (WebKit::WebProcessProxy::didGetWorkerContextConnection): 61 * UIProcess/WebProcessProxy.h: 62 * UIProcess/WebProcessProxy.messages.in: 63 64 * WebProcess/WebProcess.cpp: 65 (WebKit::WebProcess::getWorkerContextConnection): 66 (WebKit::WebProcess::startServiceWorkerContext): 67 * WebProcess/WebProcess.h: 68 * WebProcess/WebProcess.messages.in: 69 1 70 2017-10-11 Don Olmstead <don.olmstead@sony.com> 2 71 -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
r222980 r223191 33 33 #include "StorageToWebProcessConnectionMessages.h" 34 34 #include "WebProcess.h" 35 #include "WebProcessMessages.h" 35 36 #include "WebSWClientConnectionMessages.h" 36 37 #include "WebSWServerConnectionMessages.h" … … 38 39 #include <WebCore/ExceptionData.h> 39 40 #include <WebCore/NotImplemented.h> 41 #include <WebCore/ServiceWorkerContextData.h> 40 42 #include <WebCore/ServiceWorkerJobData.h> 43 #include <WebCore/ServiceWorkerRegistrationData.h> 41 44 #include <wtf/MainThread.h> 42 45 … … 49 52 : SWServer::Connection(server, connectionIdentifier) 50 53 , m_sessionID(sessionID) 51 , m_con nection(connection)54 , m_contentConnection(connection) 52 55 { 53 56 } … … 77 80 } 78 81 82 void WebSWServerConnection::startServiceWorkerContext(const ServiceWorkerContextData& data) 83 { 84 if (sendToContextProcess(Messages::WebProcess::StartServiceWorkerContext(identifier(), data))) 85 return; 86 87 m_pendingContextDatas.append(data); 88 } 89 90 template<typename U> bool WebSWServerConnection::sendToContextProcess(U&& message) 91 { 92 if (!m_contextConnection) 93 return false; 94 95 return m_contextConnection->send<U>(WTFMove(message), 0); 96 } 97 98 void WebSWServerConnection::setContextConnection(IPC::Connection* connection) 99 { 100 m_contextConnection = connection; 101 102 // We can now start any pending service worker contexts. 103 for (auto& pendingContextData : m_pendingContextDatas) 104 startServiceWorkerContext(pendingContextData); 105 106 m_pendingContextDatas.clear(); 107 } 108 79 109 } // namespace WebKit 80 110 -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
r222980 r223191 35 35 namespace WebCore { 36 36 struct ExceptionData; 37 struct ServiceWorkerRegistrationKey; 37 38 } 38 39 … … 46 47 47 48 void disconnectedFromWebProcess(); 49 void setContextConnection(IPC::Connection*); 48 50 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 49 51 50 52 private: 51 // Implement SWServer::Connection 53 // Implement SWServer::Connection (Messages to the client WebProcess) 52 54 void rejectJobInClient(uint64_t jobIdentifier, const WebCore::ExceptionData&) final; 53 55 void resolveJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) final; 54 56 void startScriptFetchInClient(uint64_t jobIdentifier) final; 55 57 56 IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); } 58 // Messages to the SW context WebProcess 59 void startServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final; 60 61 IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); } 57 62 uint64_t messageSenderDestinationID() final { return identifier(); } 58 63 64 template<typename U> bool sendToContextProcess(U&& message); 65 59 66 PAL::SessionID m_sessionID; 60 67 61 Ref<IPC::Connection> m_connection; 68 Ref<IPC::Connection> m_contentConnection; 69 RefPtr<IPC::Connection> m_contextConnection; 70 71 Deque<WebCore::ServiceWorkerContextData> m_pendingContextDatas; 62 72 }; // class WebSWServerConnection 63 73 -
trunk/Source/WebKit/StorageProcess/StorageProcess.cpp
r223158 r223191 32 32 #include "StorageToWebProcessConnection.h" 33 33 #include "WebCoreArgumentCoders.h" 34 #include "WebSWServerConnection.h" 34 35 #include "WebsiteData.h" 35 36 #include <WebCore/FileSystem.h> … … 330 331 return *result.iterator->value; 331 332 } 333 334 IPC::Connection* StorageProcess::workerContextProcessConnection() 335 { 336 return m_workerContextProcessConnection.get(); 337 } 338 339 void StorageProcess::createWorkerContextProcessConnection() 340 { 341 if (m_waitingForWorkerContextProcessConnection) 342 return; 343 344 m_waitingForWorkerContextProcessConnection = true; 345 parentProcessConnection()->send(Messages::StorageProcessProxy::GetWorkerContextProcessConnection(), 0); 346 } 347 348 void StorageProcess::didGetWorkerContextProcessConnection(const IPC::Attachment& encodedConnectionIdentifier) 349 { 350 ASSERT(m_waitingForWorkerContextProcessConnection); 351 m_waitingForWorkerContextProcessConnection = false; 352 353 #if USE(UNIX_DOMAIN_SOCKETS) 354 IPC::Connection::Identifier connectionIdentifier = encodedConnectionIdentifier.releaseFileDescriptor(); 355 #elif OS(DARWIN) 356 IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port()); 357 #else 358 ASSERT_NOT_REACHED(); 359 #endif 360 361 if (IPC::Connection::identifierIsNull(connectionIdentifier)) { 362 LOG_ERROR("StorageProcess::didGetWorkerContextProcessConnection - Received null connection identifier"); 363 return; 364 } 365 366 m_workerContextProcessConnection = IPC::Connection::createClientConnection(connectionIdentifier, *this); 367 m_workerContextProcessConnection->open(); 368 369 for (auto& connection : m_storageToWebProcessConnections) 370 connection->workerContextProcessConnectionCreated(); 371 } 372 373 void StorageProcess::serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const ServiceWorkerRegistrationKey& registrationKey, const String& workerID, const String& message) 374 { 375 if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier)) 376 connection->scriptContextFailedToStart(registrationKey, workerID, message); 377 } 378 379 void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection) 380 { 381 ASSERT(!m_swServerConnections.contains(connection.identifier())); 382 m_swServerConnections.add(connection.identifier(), &connection); 383 } 384 385 void StorageProcess::unregisterSWServerConnection(WebSWServerConnection& connection) 386 { 387 ASSERT(m_swServerConnections.get(connection.identifier()) == &connection); 388 m_swServerConnections.remove(connection.identifier()); 389 } 332 390 #endif 333 391 -
trunk/Source/WebKit/StorageProcess/StorageProcess.h
r223141 r223191 38 38 class SWServer; 39 39 struct SecurityOriginData; 40 struct ServiceWorkerRegistrationKey; 40 41 } 41 42 … … 43 44 44 45 class StorageToWebProcessConnection; 46 class WebSWServerConnection; 45 47 enum class WebsiteDataType; 46 48 struct StorageProcessCreationParameters; … … 68 70 #endif 69 71 72 #if ENABLE(SERVICE_WORKER) 73 IPC::Connection* workerContextProcessConnection(); 74 void createWorkerContextProcessConnection(); 75 #endif 76 70 77 #if ENABLE(SANDBOX_EXTENSIONS) 71 78 void getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, WTF::Function<void (SandboxExtension::HandleArray&&)>&& completionHandler); … … 74 81 #if ENABLE(SERVICE_WORKER) 75 82 WebCore::SWServer& swServerForSession(PAL::SessionID); 83 void registerSWServerConnection(WebSWServerConnection&); 84 void unregisterSWServerConnection(WebSWServerConnection&); 76 85 #endif 77 86 … … 102 111 void didGetSandboxExtensionsForBlobFiles(uint64_t requestID, SandboxExtension::HandleArray&&); 103 112 #endif 104 113 #if ENABLE(SERVICE_WORKER) 114 void didGetWorkerContextProcessConnection(const IPC::Attachment& encodedConnectionIdentifier); 115 void serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, const String& workerID, const String& message); 116 #endif 105 117 #if ENABLE(INDEXED_DATABASE) 106 118 Vector<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path); … … 126 138 127 139 #if ENABLE(SERVICE_WORKER) 140 void didCreateWorkerContextProcessConnection(const IPC::Attachment&); 141 142 RefPtr<IPC::Connection> m_workerContextProcessConnection; 143 bool m_waitingForWorkerContextProcessConnection { false }; 128 144 HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers; 145 HashMap<uint64_t, WebSWServerConnection*> m_swServerConnections; 129 146 #endif 130 147 }; -
trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in
r220857 r223191 35 35 DidGetSandboxExtensionsForBlobFiles(uint64_t requestID, WebKit::SandboxExtension::HandleArray extensions) 36 36 #endif 37 38 #if ENABLE(SERVICE_WORKER) 39 DidGetWorkerContextProcessConnection(IPC::Attachment connectionHandle) 40 ServiceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, String workerID, String message) 41 #endif 37 42 } -
trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp
r223141 r223191 56 56 { 57 57 m_connection->invalidate(); 58 59 #if ENABLE(SERVICE_WORKER) 60 for (auto& connection : m_swConnections.values()) 61 StorageProcess::singleton().unregisterSWServerConnection(*connection); 62 #endif 58 63 } 59 64 … … 139 144 140 145 auto& server = StorageProcess::singleton().swServerForSession(sessionID); 141 m_swConnections.set(serverConnectionIdentifier, std::make_unique<WebSWServerConnection>(server, m_connection.get(), serverConnectionIdentifier, sessionID)); 146 auto connectionResult = m_swConnections.add(serverConnectionIdentifier, std::make_unique<WebSWServerConnection>(server, m_connection.get(), serverConnectionIdentifier, sessionID)); 147 ASSERT(connectionResult.isNewEntry); 148 149 StorageProcess::singleton().registerSWServerConnection(*(connectionResult.iterator->value)); 150 151 if (auto* connection = StorageProcess::singleton().workerContextProcessConnection()) 152 connectionResult.iterator->value->setContextConnection(connection); 153 else 154 StorageProcess::singleton().createWorkerContextProcessConnection(); 142 155 } 143 156 … … 147 160 148 161 auto connection = m_swConnections.take(serverConnectionIdentifier); 162 StorageProcess::singleton().unregisterSWServerConnection(*connection); 149 163 connection->disconnectedFromWebProcess(); 164 } 165 166 void StorageToWebProcessConnection::workerContextProcessConnectionCreated() 167 { 168 auto* ipcConnection = StorageProcess::singleton().workerContextProcessConnection(); 169 ASSERT(ipcConnection); 170 171 for (auto& swConnection : m_swConnections.values()) 172 swConnection->setContextConnection(ipcConnection); 150 173 } 151 174 #endif … … 170 193 #endif 171 194 172 173 195 } // namespace WebKit -
trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.h
r223141 r223191 45 45 IPC::Connection& connection() { return m_connection.get(); } 46 46 47 #if ENABLE(SERVICE_WORKER) 48 void workerContextProcessConnectionCreated(); 49 #endif 50 47 51 private: 48 52 StorageToWebProcessConnection(IPC::Connection::Identifier); -
trunk/Source/WebKit/UIProcess/Storage/StorageProcessProxy.cpp
r222183 r223191 45 45 } 46 46 47 Ref<StorageProcessProxy> StorageProcessProxy::create(WebProcessPool *processPool)47 Ref<StorageProcessProxy> StorageProcessProxy::create(WebProcessPool& processPool) 48 48 { 49 49 return adoptRef(*new StorageProcessProxy(processPool)); 50 50 } 51 51 52 StorageProcessProxy::StorageProcessProxy(WebProcessPool *processPool)53 : ChildProcessProxy(processPool ->alwaysRunsAtBackgroundPriority())52 StorageProcessProxy::StorageProcessProxy(WebProcessPool& processPool) 53 : ChildProcessProxy(processPool.alwaysRunsAtBackgroundPriority()) 54 54 , m_processPool(processPool) 55 55 , m_numPendingConnectionRequests(0) … … 152 152 153 153 // Tell ProcessPool to forget about this storage process. This may cause us to be deleted. 154 m_processPool ->storageProcessCrashed(this);154 m_processPool.storageProcessCrashed(this); 155 155 } 156 156 … … 221 221 } 222 222 223 #if ENABLE(SERVICE_WORKER) 224 void StorageProcessProxy::getWorkerContextProcessConnection() 225 { 226 ASSERT(!m_waitingOnWorkerContextProcessConnection); 227 m_waitingOnWorkerContextProcessConnection = true; 228 229 m_processPool.getWorkerContextProcessConnection(*this); 230 } 231 232 void StorageProcessProxy::didGetWorkerContextProcessConnection(const IPC::Attachment& connection) 233 { 234 send(Messages::StorageProcess::DidGetWorkerContextProcessConnection(connection), 0); 235 } 236 237 #endif 238 223 239 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/Storage/StorageProcessProxy.h
r220857 r223191 49 49 class StorageProcessProxy : public ChildProcessProxy { 50 50 public: 51 static Ref<StorageProcessProxy> create(WebProcessPool *);51 static Ref<StorageProcessProxy> create(WebProcessPool&); 52 52 ~StorageProcessProxy(); 53 53 … … 58 58 void getStorageProcessConnection(Ref<Messages::WebProcessProxy::GetStorageProcessConnection::DelayedReply>&&); 59 59 60 #if ENABLE(SERVICE_WORKER) 61 void didGetWorkerContextProcessConnection(const IPC::Attachment& connection); 62 #endif 63 60 64 private: 61 StorageProcessProxy(WebProcessPool *);65 StorageProcessProxy(WebProcessPool&); 62 66 63 67 // ChildProcessProxy … … 80 84 void getSandboxExtensionsForBlobFiles(uint64_t requestID, const Vector<String>& paths); 81 85 #endif 86 #if ENABLE(SERVICE_WORKER) 87 void getWorkerContextProcessConnection(); 88 bool m_waitingOnWorkerContextProcessConnection { false }; 89 #endif 82 90 83 91 // ProcessLauncher::Client 84 92 void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override; 85 93 86 WebProcessPool *m_processPool;94 WebProcessPool& m_processPool; 87 95 88 96 unsigned m_numPendingConnectionRequests; -
trunk/Source/WebKit/UIProcess/Storage/StorageProcessProxy.messages.in
r220105 r223191 31 31 GetSandboxExtensionsForBlobFiles(uint64_t requestID, Vector<String> paths) 32 32 #endif 33 34 #if ENABLE(SERVICE_WORKER) 35 GetWorkerContextProcessConnection() 36 #endif 33 37 } -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r223073 r223191 546 546 #endif 547 547 548 m_storageProcess = StorageProcessProxy::create( this);548 m_storageProcess = StorageProcessProxy::create(*this); 549 549 m_storageProcess->send(Messages::StorageProcess::InitializeWebsiteDataStore(parameters), 0); 550 550 } … … 574 574 m_storageProcess = nullptr; 575 575 } 576 577 #if ENABLE(SERVICE_WORKER) 578 void WebProcessPool::getWorkerContextProcessConnection(StorageProcessProxy& proxy) 579 { 580 ASSERT_UNUSED(proxy, &proxy == m_storageProcess); 581 582 if (!m_workerContextProcess) { 583 if (!m_websiteDataStore) 584 m_websiteDataStore = API::WebsiteDataStore::defaultDataStore().ptr(); 585 auto& newProcess = createNewWebProcess(m_websiteDataStore->websiteDataStore()); 586 m_workerContextProcess = &newProcess; 587 } 588 589 m_workerContextProcess->send(Messages::WebProcess::GetWorkerContextConnection(), 0); 590 } 591 592 void WebProcessPool::didGetWorkerContextProcessConnection(const IPC::Attachment& connection) 593 { 594 if (!m_storageProcess) 595 return; 596 m_storageProcess->didGetWorkerContextProcessConnection(connection); 597 } 598 #endif 576 599 577 600 void WebProcessPool::willStartUsingPrivateBrowsing() … … 883 906 if (m_processWithPageCache == process) 884 907 m_processWithPageCache = nullptr; 908 #if ENABLE(SERVICE_WORKER) 909 if (m_workerContextProcess == process) 910 m_workerContextProcess = nullptr; 911 #endif 885 912 886 913 static_cast<WebContextSupplement*>(supplement<WebGeolocationManagerProxy>())->processDidClose(process); … … 960 987 } else 961 988 process = &createNewWebProcessRespectingProcessCountLimit(pageConfiguration->websiteDataStore()->websiteDataStore()); 989 990 ASSERT(process.get() != m_workerContextProcess); 962 991 963 992 return process->createWebPage(pageClient, WTFMove(pageConfiguration)); -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r222664 r223191 320 320 void getStorageProcessConnection(Ref<Messages::WebProcessProxy::GetStorageProcessConnection::DelayedReply>&&); 321 321 void storageProcessCrashed(StorageProcessProxy*); 322 #if ENABLE(SERVICE_WORKER) 323 void getWorkerContextProcessConnection(StorageProcessProxy&); 324 #endif 322 325 323 326 #if PLATFORM(COCOA) … … 413 416 static void unregisterProcessPoolCreationListener(uint64_t identifier); 414 417 418 #if ENABLE(SERVICE_WORKER) 419 void didGetWorkerContextProcessConnection(const IPC::Attachment& connection); 420 #endif 421 415 422 private: 416 423 void platformInitialize(); … … 478 485 479 486 WebProcessProxy* m_processWithPageCache; 487 #if ENABLE(SERVICE_WORKER) 488 WebProcessProxy* m_workerContextProcess { nullptr }; 489 bool m_waitingForWorkerContextProcessConnection { false }; 490 #endif 480 491 481 492 Ref<WebPageGroup> m_defaultPageGroup; -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r223149 r223191 1218 1218 #endif 1219 1219 1220 #if ENABLE(SERVICE_WORKER) 1221 void WebProcessProxy::didGetWorkerContextConnection(const IPC::Attachment& connection) 1222 { 1223 m_processPool->didGetWorkerContextProcessConnection(connection); 1224 } 1225 #endif 1226 1220 1227 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r223061 r223191 182 182 void didExceedInactiveMemoryLimitWhileActive(); 183 183 184 #if ENABLE(SERVICE_WORKER) 185 void didGetWorkerContextConnection(const IPC::Attachment& connection); 186 #endif 187 184 188 void processTerminated(); 185 189 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in
r220105 r223191 55 55 MemoryPressureStatusChanged(bool isUnderMemoryPressure) 56 56 DidExceedInactiveMemoryLimitWhileActive() 57 58 #if ENABLE(SERVICE_WORKER) 59 DidGetWorkerContextConnection(IPC::Attachment connection) 60 #endif 57 61 } -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r223149 r223191 43 43 #include "SessionTracker.h" 44 44 #include "StatisticsData.h" 45 #include "StorageProcessMessages.h" 45 46 #include "UserData.h" 46 47 #include "WebAutomationSessionProxy.h" … … 106 107 #include <WebCore/SchemeRegistry.h> 107 108 #include <WebCore/SecurityOrigin.h> 109 #include <WebCore/ServiceWorkerContextData.h> 108 110 #include <WebCore/Settings.h> 109 111 #include <WebCore/URLParser.h> … … 1615 1617 #endif 1616 1618 1619 #if ENABLE(SERVICE_WORKER) 1620 void WebProcess::getWorkerContextConnection() 1621 { 1622 ASSERT(!m_workerContextConnection); 1623 1624 #if USE(UNIX_DOMAIN_SOCKETS) 1625 IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection(); 1626 IPC::Connection::Identifier connectionIdentifier(socketPair.server); 1627 IPC::Attachment connectionClientPort(socketPair.client); 1628 #elif OS(DARWIN) 1629 mach_port_t listeningPort; 1630 if (mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort) != KERN_SUCCESS) 1631 CRASH(); 1632 1633 if (mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND) != KERN_SUCCESS) 1634 CRASH(); 1635 1636 IPC::Connection::Identifier connectionIdentifier(listeningPort); 1637 IPC::Attachment connectionClientPort(listeningPort, MACH_MSG_TYPE_MOVE_SEND); 1638 #else 1639 RELEASE_ASSERT_NOT_REACHED(); 1640 #endif 1641 1642 m_workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this); 1643 m_workerContextConnection->open(); 1644 1645 WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidGetWorkerContextConnection(connectionClientPort), 0); 1646 } 1647 1648 void WebProcess::startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data) 1649 { 1650 // FIXME: Here is where we will actually start the script. 1651 // For now we bounce back a failure message to the requesting process for test coverage. 1652 1653 auto message = makeString("Failed to start service worker script of length ", String::number(data.script.length())); 1654 m_workerContextConnection->send(Messages::StorageProcess::ServiceWorkerContextFailedToStart(serverConnectionIdentifier, data.registrationKey, data.workerID, message), 0); 1655 } 1656 1657 #endif 1658 1617 1659 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebProcess.h
r222619 r223191 72 72 struct SecurityOriginData; 73 73 struct SoupNetworkProxySettings; 74 75 #if ENABLE(SERVICE_WORKER) 76 struct ServiceWorkerContextData; 77 #endif 74 78 } 75 79 … … 291 295 void gamepadDisconnected(unsigned index); 292 296 #endif 293 294 297 #if USE(SOUP) 295 298 void setNetworkProxySettings(const WebCore::SoupNetworkProxySettings&); 299 #endif 300 #if ENABLE(SERVICE_WORKER) 301 void getWorkerContextConnection(); 302 void startServiceWorkerContext(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&); 303 RefPtr<IPC::Connection> m_workerContextConnection; 296 304 #endif 297 305 -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r220857 r223191 114 114 SetNetworkProxySettings(struct WebCore::SoupNetworkProxySettings settings) 115 115 #endif 116 117 #if ENABLE(SERVICE_WORKER) 118 GetWorkerContextConnection() 119 StartServiceWorkerContext(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData) 120 #endif 116 121 }
Note: See TracChangeset
for help on using the changeset viewer.