<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[224804] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/224804">224804</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-11-13 22:21:43 -0800 (Mon, 13 Nov 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Send ServiceWorkerData structs to the WebProcesses instead of ServiceWorkerIdentifiers
https://bugs.webkit.org/show_bug.cgi?id=179649

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

Rebaseline a couple of WPT tests that are now passing.

* web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https-expected.txt:
* web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt:

Source/WebCore:

Send ServiceWorkerData structs to the WebProcesses instead of ServiceWorkerIdentifiers so that the
WebProcesses can correctly construct ServiceWorker objects, with the right attributes / state.

No new tests, rebaselined existing tests.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* workers/service/ServiceWorker.cpp:
(WebCore::ServiceWorker::getOrCreate):
(WebCore::ServiceWorker::ServiceWorker):
(WebCore::ServiceWorker::~ServiceWorker):
(WebCore::ServiceWorker::scheduleTaskToUpdateState):
(WebCore::ServiceWorker::postMessage):
* workers/service/ServiceWorker.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerData.cpp: Copied from Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp.
(WebCore::ServiceWorkerData::isolatedCopy const):
* workers/service/ServiceWorkerData.h: Copied from Source/WebCore/workers/service/server/SWServerWorker.cpp.
(WebCore::ServiceWorkerData::encode const):
(WebCore::ServiceWorkerData::decode):
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
(WebCore::ServiceWorkerRegistration::updateStateFromServer):
* workers/service/ServiceWorkerRegistration.h:
* workers/service/ServiceWorkerRegistrationData.cpp:
(WebCore::ServiceWorkerRegistrationData::isolatedCopy const):
* workers/service/ServiceWorkerRegistrationData.h:
(WebCore::ServiceWorkerRegistrationData::encode const):
(WebCore::ServiceWorkerRegistrationData::decode):
* workers/service/server/SWClientConnection.cpp:
(WebCore::SWClientConnection::postMessageToServiceWorkerClient):
(WebCore::SWClientConnection::updateRegistrationState):
* workers/service/server/SWClientConnection.h:
* workers/service/server/SWServer.h:
* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::updateRegistrationState):
(WebCore::SWServerRegistration::data const):
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::SWServerWorker):
(WebCore::m_script):
* workers/service/server/SWServerWorker.h:
(WebCore::SWServerWorker::scriptURL const):
(WebCore::SWServerWorker::type const):
(WebCore::SWServerWorker::identifier const):
(WebCore::SWServerWorker::state const):
(WebCore::SWServerWorker::setState):
(WebCore::SWServerWorker::data const):

Source/WebKit:

* Shared/WebCoreArgumentCoders.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::updateRegistrationStateInClient):
(WebKit::WebSWServerConnection::postMessageToServiceWorkerClient):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::postMessageToServiceWorkerClient):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerregisterwaitforeverininstallworkerhttpsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerskipwaitinghttpsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkercpp">trunk/Source/WebCore/workers/service/ServiceWorker.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerh">trunk/Source/WebCore/workers/service/ServiceWorker.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerContainercpp">trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerContainerh">trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerRegistrationcpp">trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerRegistrationh">trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerRegistrationDatacpp">trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerRegistrationDatah">trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverSWClientConnectioncpp">trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverSWClientConnectionh">trunk/Source/WebCore/workers/service/server/SWClientConnection.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverSWServerh">trunk/Source/WebCore/workers/service/server/SWServer.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverSWServerRegistrationcpp">trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverSWServerWorkercpp">trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverSWServerWorkerh">trunk/Source/WebCore/workers/service/server/SWServerWorker.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitStorageProcessServiceWorkerWebSWServerConnectioncpp">trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp</a></li>
<li><a href="#trunkSourceWebKitStorageProcessServiceWorkerWebSWServerConnectionh">trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessStorageWebSWClientConnectioncpp">trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessStorageWebSWClientConnectionh">trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessStorageWebSWClientConnectionmessagesin">trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerDatacpp">trunk/Source/WebCore/workers/service/ServiceWorkerData.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerDatah">trunk/Source/WebCore/workers/service/ServiceWorkerData.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2017-11-13  Chris Dumez  <cdumez@apple.com>
+
+        Send ServiceWorkerData structs to the WebProcesses instead of ServiceWorkerIdentifiers
+        https://bugs.webkit.org/show_bug.cgi?id=179649
+
+        Reviewed by Brady Eidson.
+
+        Rebaseline a couple of WPT tests that are now passing.
+
+        * web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https-expected.txt:
+        * web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt:
+
</ins><span class="cx"> 2017-11-13  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         matchRegistration does not need to go to StorageProcess if no service worker is registered
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerregisterwaitforeverininstallworkerhttpsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https-expected.txt (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https-expected.txt      2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/register-wait-forever-in-install-worker.https-expected.txt 2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> 
</span><del>-FAIL register worker that calls waitUntil with a promise that never resolves in oninstall assert_equals: expected "https://localhost:9443/service-workers/service-worker/resources/empty-worker.js" but got "https://localhost:9443/service-workers/service-worker/resources/wait-forever-in-install-worker.js"
</del><ins>+PASS register worker that calls waitUntil with a promise that never resolves in oninstall 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsserviceworkersserviceworkerskipwaitinghttpsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> 
</span><del>-FAIL Test skipWaiting with both active and waiting workers assert_equals: Worker with url2 should be waiting expected "https://localhost:9443/service-workers/service-worker/resources/empty-worker.js" but got "https://localhost:9443/service-workers/service-worker/resources/empty.js"
</del><ins>+PASS Test skipWaiting with both active and waiting workers 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/ChangeLog      2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2017-11-13  Chris Dumez  <cdumez@apple.com>
+
+        Send ServiceWorkerData structs to the WebProcesses instead of ServiceWorkerIdentifiers
+        https://bugs.webkit.org/show_bug.cgi?id=179649
+
+        Reviewed by Brady Eidson.
+
+        Send ServiceWorkerData structs to the WebProcesses instead of ServiceWorkerIdentifiers so that the
+        WebProcesses can correctly construct ServiceWorker objects, with the right attributes / state.
+
+        No new tests, rebaselined existing tests.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * workers/service/ServiceWorker.cpp:
+        (WebCore::ServiceWorker::getOrCreate):
+        (WebCore::ServiceWorker::ServiceWorker):
+        (WebCore::ServiceWorker::~ServiceWorker):
+        (WebCore::ServiceWorker::scheduleTaskToUpdateState):
+        (WebCore::ServiceWorker::postMessage):
+        * workers/service/ServiceWorker.h:
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState):
+        * workers/service/ServiceWorkerContainer.h:
+        * workers/service/ServiceWorkerData.cpp: Copied from Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp.
+        (WebCore::ServiceWorkerData::isolatedCopy const):
+        * workers/service/ServiceWorkerData.h: Copied from Source/WebCore/workers/service/server/SWServerWorker.cpp.
+        (WebCore::ServiceWorkerData::encode const):
+        (WebCore::ServiceWorkerData::decode):
+        * workers/service/ServiceWorkerRegistration.cpp:
+        (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
+        (WebCore::ServiceWorkerRegistration::updateStateFromServer):
+        * workers/service/ServiceWorkerRegistration.h:
+        * workers/service/ServiceWorkerRegistrationData.cpp:
+        (WebCore::ServiceWorkerRegistrationData::isolatedCopy const):
+        * workers/service/ServiceWorkerRegistrationData.h:
+        (WebCore::ServiceWorkerRegistrationData::encode const):
+        (WebCore::ServiceWorkerRegistrationData::decode):
+        * workers/service/server/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::postMessageToServiceWorkerClient):
+        (WebCore::SWClientConnection::updateRegistrationState):
+        * workers/service/server/SWClientConnection.h:
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::updateRegistrationState):
+        (WebCore::SWServerRegistration::data const):
+        * workers/service/server/SWServerWorker.cpp:
+        (WebCore::SWServerWorker::SWServerWorker):
+        (WebCore::m_script):
+        * workers/service/server/SWServerWorker.h:
+        (WebCore::SWServerWorker::scriptURL const):
+        (WebCore::SWServerWorker::type const):
+        (WebCore::SWServerWorker::identifier const):
+        (WebCore::SWServerWorker::state const):
+        (WebCore::SWServerWorker::setState):
+        (WebCore::SWServerWorker::data const):
+
</ins><span class="cx"> 2017-11-13  Ryosuke Niwa  <rniwa@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         iOS: Enable release asserts in updateStyleIfNeeded() and updateLayout() for WebKit2
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/Sources.txt    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -2172,6 +2172,7 @@
</span><span class="cx"> workers/service/ServiceWorkerClients.cpp
</span><span class="cx"> workers/service/ServiceWorkerContainer.cpp
</span><span class="cx"> workers/service/ServiceWorkerContextData.cpp
</span><ins>+workers/service/ServiceWorkerData.cpp
</ins><span class="cx"> workers/service/ServiceWorkerGlobalScope.cpp
</span><span class="cx"> workers/service/ServiceWorkerJob.cpp
</span><span class="cx"> workers/service/ServiceWorkerJobData.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -2243,6 +2243,7 @@
</span><span class="cx">          83D35AEC1C7187FA00F70D5A /* XMLHttpRequestEventTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D35AEA1C7187ED00F70D5A /* XMLHttpRequestEventTarget.h */; };
</span><span class="cx">          83D35AF21C718D9000F70D5A /* JSXMLHttpRequestEventTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D35AF01C718D8400F70D5A /* JSXMLHttpRequestEventTarget.h */; };
</span><span class="cx">          83E359A21BB1031D002CEB98 /* JSHTMLTimeElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E359A01BB1031D002CEB98 /* JSHTMLTimeElement.h */; };
</span><ins>+               83E866801FBA565B008855C5 /* ServiceWorkerData.h in Headers */ = {isa = PBXBuildFile; fileRef = 83E8667D1FBA563F008855C5 /* ServiceWorkerData.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           83EE598F1F50958E003E8B30 /* JSErrorCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 83EE598B1F50958B003E8B30 /* JSErrorCallback.h */; };
</span><span class="cx">          83FB33711F508A5400986E54 /* FileSystemDirectoryEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 83FB336D1F508A4E00986E54 /* FileSystemDirectoryEntry.h */; };
</span><span class="cx">          83FB33731F508A5800986E54 /* FileSystemEntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 83FB336F1F508A4E00986E54 /* FileSystemEntry.h */; };
</span><span class="lines">@@ -9534,6 +9535,8 @@
</span><span class="cx">          83E045EF1DAA104F00B0D8B9 /* JSUIEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSUIEventInit.h; sourceTree = "<group>"; };
</span><span class="cx">          83E359A01BB1031D002CEB98 /* JSHTMLTimeElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSHTMLTimeElement.h; sourceTree = "<group>"; };
</span><span class="cx">          83E359A11BB1031D002CEB98 /* JSHTMLTimeElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTimeElement.cpp; sourceTree = "<group>"; };
</span><ins>+               83E8667D1FBA563F008855C5 /* ServiceWorkerData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerData.h; sourceTree = "<group>"; };
+               83E8667F1FBA5640008855C5 /* ServiceWorkerData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerData.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           83E959E11B8BC22B004D9385 /* NativeNodeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeNodeFilter.h; sourceTree = "<group>"; };
</span><span class="cx">          83E9B3001DA5A51E00FFE8F6 /* JSScrollToOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScrollToOptions.cpp; sourceTree = "<group>"; };
</span><span class="cx">          83E9B3011DA5A51E00FFE8F6 /* JSScrollToOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSScrollToOptions.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -17296,6 +17299,8 @@
</span><span class="cx">                          51F175561F3EBC0C00C74950 /* ServiceWorkerContainer.idl */,
</span><span class="cx">                          517C87161F8FD4D300EB8076 /* ServiceWorkerContextData.cpp */,
</span><span class="cx">                          51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */,
</span><ins>+                               83E8667F1FBA5640008855C5 /* ServiceWorkerData.cpp */,
+                               83E8667D1FBA563F008855C5 /* ServiceWorkerData.h */,
</ins><span class="cx">                           517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */,
</span><span class="cx">                          51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */,
</span><span class="cx">                          51F175541F3EBC0C00C74950 /* ServiceWorkerGlobalScope.h */,
</span><span class="lines">@@ -28980,6 +28985,7 @@
</span><span class="cx">                          8369FDFC1FA102E300C1FF1F /* ServiceWorkerClientType.h in Headers */,
</span><span class="cx">                          51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */,
</span><span class="cx">                          51CA7EE91F883390003D3131 /* ServiceWorkerContextData.h in Headers */,
</span><ins>+                               83E866801FBA565B008855C5 /* ServiceWorkerData.h in Headers */,
</ins><span class="cx">                           A52B348F1FA3BDA6008B6246 /* ServiceWorkerDebuggable.h in Headers */,
</span><span class="cx">                          419ACF921F97E7DA009F1A83 /* ServiceWorkerFetch.h in Headers */,
</span><span class="cx">                          517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorker.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorker.cpp   2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.cpp      2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -53,13 +53,23 @@
</span><span class="cx">     return allWorkersMap;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ServiceWorker::ServiceWorker(ScriptExecutionContext& context, ServiceWorkerIdentifier identifier, const URL& scriptURL, State state)
</del><ins>+Ref<ServiceWorker> ServiceWorker::getOrCreate(ScriptExecutionContext& context, ServiceWorkerData&& data)
+{
+    auto it = allWorkers().find(data.identifier);
+    if (it != allWorkers().end()) {
+        for (auto& worker : it->value) {
+            if (worker->scriptExecutionContext() == &context)
+                return *worker;
+        }
+    }
+    return adoptRef(*new ServiceWorker(context, WTFMove(data)));
+}
+
+ServiceWorker::ServiceWorker(ScriptExecutionContext& context, ServiceWorkerData&& data)
</ins><span class="cx">     : ContextDestructionObserver(&context)
</span><del>-    , m_identifier(identifier)
-    , m_scriptURL(scriptURL)
-    , m_state(state)
</del><ins>+    , m_data(WTFMove(data))
</ins><span class="cx"> {
</span><del>-    auto result = mutableAllWorkers().ensure(identifier, [] {
</del><ins>+    auto result = mutableAllWorkers().ensure(identifier(), [] {
</ins><span class="cx">         return HashSet<ServiceWorker*>();
</span><span class="cx">     });
</span><span class="cx">     result.iterator->value.add(this);
</span><span class="lines">@@ -67,7 +77,7 @@
</span><span class="cx"> 
</span><span class="cx"> ServiceWorker::~ServiceWorker()
</span><span class="cx"> {
</span><del>-    auto iterator = mutableAllWorkers().find(m_identifier);
</del><ins>+    auto iterator = mutableAllWorkers().find(identifier());
</ins><span class="cx"> 
</span><span class="cx">     ASSERT(iterator->value.contains(this));
</span><span class="cx">     iterator->value.remove(this);
</span><span class="lines">@@ -86,7 +96,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     context->postTask([this, protectedThis = makeRef(*this), state](ScriptExecutionContext&) {
</span><del>-        m_state = state;
</del><ins>+        m_data.state = state;
</ins><span class="cx">         dispatchEvent(Event::create(eventNames().statechangeEvent, false, false));
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="lines">@@ -117,7 +127,7 @@
</span><span class="cx">         return Exception { NotSupportedError, ASCIILiteral("Passing MessagePort objects to postMessage is not yet supported") };
</span><span class="cx"> 
</span><span class="cx">     auto& swConnection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context.sessionID());
</span><del>-    swConnection.postMessageToServiceWorkerGlobalScope(m_identifier, message.releaseReturnValue(), context);
</del><ins>+    swConnection.postMessageToServiceWorkerGlobalScope(identifier(), message.releaseReturnValue(), context);
</ins><span class="cx"> 
</span><span class="cx">     return { };
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorker.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorker.h     2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.h        2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -29,8 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include "ContextDestructionObserver.h"
</span><span class="cx"> #include "EventTarget.h"
</span><del>-#include "ServiceWorkerIdentifier.h"
-#include "ServiceWorkerTypes.h"
</del><ins>+#include "ServiceWorkerData.h"
</ins><span class="cx"> #include "URL.h"
</span><span class="cx"> #include <heap/Strong.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="lines">@@ -46,22 +45,19 @@
</span><span class="cx"> class ServiceWorker final : public RefCounted<ServiceWorker>, public EventTargetWithInlineData, public ContextDestructionObserver {
</span><span class="cx"> public:
</span><span class="cx">     using State = ServiceWorkerState;
</span><del>-    static Ref<ServiceWorker> create(ScriptExecutionContext& context, ServiceWorkerIdentifier identifier, const URL& scriptURL, State state = State::Installing)
-    {
-        return adoptRef(*new ServiceWorker(context, identifier, scriptURL, state));
-    }
</del><ins>+    static Ref<ServiceWorker> getOrCreate(ScriptExecutionContext&, ServiceWorkerData&&);
</ins><span class="cx"> 
</span><span class="cx">     virtual ~ServiceWorker();
</span><span class="cx"> 
</span><del>-    const URL& scriptURL() const { return m_scriptURL; }
</del><ins>+    const URL& scriptURL() const { return m_data.scriptURL; }
</ins><span class="cx"> 
</span><del>-    State state() const { return m_state; }
</del><ins>+    State state() const { return m_data.state; }
</ins><span class="cx">     
</span><span class="cx">     void scheduleTaskToUpdateState(State);
</span><span class="cx"> 
</span><span class="cx">     ExceptionOr<void> postMessage(ScriptExecutionContext&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&);
</span><span class="cx"> 
</span><del>-    ServiceWorkerIdentifier identifier() const { return m_identifier; }
</del><ins>+    ServiceWorkerIdentifier identifier() const { return m_data.identifier; }
</ins><span class="cx"> 
</span><span class="cx">     using RefCounted::ref;
</span><span class="cx">     using RefCounted::deref;
</span><span class="lines">@@ -69,7 +65,7 @@
</span><span class="cx">     static const HashMap<ServiceWorkerIdentifier, HashSet<ServiceWorker*>>& allWorkers();
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    ServiceWorker(ScriptExecutionContext&, ServiceWorkerIdentifier, const URL& scriptURL, State);
</del><ins>+    ServiceWorker(ScriptExecutionContext&, ServiceWorkerData&&);
</ins><span class="cx">     static HashMap<ServiceWorkerIdentifier, HashSet<ServiceWorker*>>& mutableAllWorkers();
</span><span class="cx"> 
</span><span class="cx">     EventTargetInterface eventTargetInterface() const final;
</span><span class="lines">@@ -77,9 +73,7 @@
</span><span class="cx">     void refEventTarget() final { ref(); }
</span><span class="cx">     void derefEventTarget() final { deref(); }
</span><span class="cx"> 
</span><del>-    ServiceWorkerIdentifier m_identifier;
-    URL m_scriptURL;
-    State m_state;
</del><ins>+    ServiceWorkerData m_data;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerContainercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp  2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp     2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -241,15 +241,19 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerIdentifier>& serviceWorkerIdentifier)
</del><ins>+void ServiceWorkerContainer::scheduleTaskToUpdateRegistrationState(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerData>& serviceWorkerData)
</ins><span class="cx"> {
</span><span class="cx">     auto* context = scriptExecutionContext();
</span><span class="cx">     if (!context)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    context->postTask([this, protectedThis = makeRef(*this), identifier, state, serviceWorkerIdentifier](ScriptExecutionContext&) {
</del><ins>+    RefPtr<ServiceWorker> serviceWorker;
+    if (serviceWorkerData)
+        serviceWorker = ServiceWorker::getOrCreate(*context, ServiceWorkerData { *serviceWorkerData });
+
+    context->postTask([this, protectedThis = makeRef(*this), identifier, state, serviceWorker = WTFMove(serviceWorker)](ScriptExecutionContext&) mutable {
</ins><span class="cx">         if (auto* registration = m_registrations.get(identifier))
</span><del>-            registration->updateStateFromServer(state, serviceWorkerIdentifier);
</del><ins>+            registration->updateStateFromServer(state, WTFMove(serviceWorker));
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerContainerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h    2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h       2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">     void updateRegistration(const URL& scopeURL, const URL& scriptURL, WorkerType, Ref<DeferredPromise>&&);
</span><span class="cx"> 
</span><span class="cx">     void getRegistration(const String& clientURL, Ref<DeferredPromise>&&);
</span><del>-    void scheduleTaskToUpdateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerIdentifier>&);
</del><ins>+    void scheduleTaskToUpdateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerData>&);
</ins><span class="cx">     void scheduleTaskToFireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier);
</span><span class="cx"> 
</span><span class="cx">     using RegistrationsPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<ServiceWorkerRegistration>>>;
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerDatacppfromrev224803trunkSourceWebCoreworkersserviceServiceWorkerRegistrationDatacpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/workers/service/ServiceWorkerData.cpp (from rev 224803, trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp) (0 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerData.cpp                               (rev 0)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerData.cpp  2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SERVICE_WORKER)
+#include "ServiceWorkerData.h"
+
+namespace WebCore {
+
+ServiceWorkerData ServiceWorkerData::isolatedCopy() const
+{
+    return {
+        identifier,
+        scriptURL.isolatedCopy(),
+        state,
+        type
+    };
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
</ins></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerDatahfromrev224803trunkSourceWebCoreworkersserviceServiceWorkerRegistrationDatacpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/workers/service/ServiceWorkerData.h (from rev 224803, trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp) (0 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerData.h                         (rev 0)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerData.h    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ServiceWorkerIdentifier.h"
+#include "ServiceWorkerTypes.h"
+#include "URL.h"
+#include "WorkerType.h"
+
+namespace WebCore {
+
+struct ServiceWorkerData {
+    ServiceWorkerIdentifier identifier;
+    URL scriptURL;
+    ServiceWorkerState state;
+    WorkerType type;
+
+    ServiceWorkerData isolatedCopy() const;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static std::optional<ServiceWorkerData> decode(Decoder&);
+};
+
+template<class Encoder>
+void ServiceWorkerData::encode(Encoder& encoder) const
+{
+    encoder << identifier << scriptURL << state << type;
+}
+
+template<class Decoder>
+std::optional<ServiceWorkerData> ServiceWorkerData::decode(Decoder& decoder)
+{
+    std::optional<ServiceWorkerIdentifier> identifier;
+    decoder >> identifier;
+    if (!identifier)
+        return std::nullopt;
+
+    std::optional<URL> scriptURL;
+    decoder >> scriptURL;
+    if (!scriptURL)
+        return std::nullopt;
+
+    std::optional<ServiceWorkerState> state;
+    decoder >> state;
+    if (!state)
+        return std::nullopt;
+
+    std::optional<WorkerType> type;
+    decoder >> type;
+    if (!type)
+        return std::nullopt;
+
+    return { { WTFMove(*identifier), WTFMove(*scriptURL), WTFMove(*state), WTFMove(*type) } };
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
</ins></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerRegistrationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp       2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp  2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -45,15 +45,12 @@
</span><span class="cx">     LOG(ServiceWorker, "Creating registration %p for registration key %s", this, m_registrationData.key.loggingString().utf8().data());
</span><span class="cx">     suspendIfNeeded();
</span><span class="cx"> 
</span><del>-    // FIXME: Reconcile worker state properly (see below)
-    if (m_registrationData.installingServiceWorkerIdentifier)
-        m_installingWorker = ServiceWorker::create(context, *m_registrationData.installingServiceWorkerIdentifier, m_registrationData.scriptURL, ServiceWorker::State::Installing);
-    if (m_registrationData.waitingServiceWorkerIdentifier)
-        m_waitingWorker = ServiceWorker::create(context, *m_registrationData.waitingServiceWorkerIdentifier, m_registrationData.scriptURL, ServiceWorker::State::Installed);
-    if (m_registrationData.activeServiceWorkerIdentifier) {
-        // FIXME: Activating or Activated? This is why we have to have more data here...
-        m_activeWorker = ServiceWorker::create(context, *m_registrationData.activeServiceWorkerIdentifier, m_registrationData.scriptURL, ServiceWorker::State::Activated);
-    }
</del><ins>+    if (m_registrationData.installingWorker)
+        m_installingWorker = ServiceWorker::getOrCreate(context, WTFMove(*m_registrationData.installingWorker));
+    if (m_registrationData.waitingWorker)
+        m_waitingWorker = ServiceWorker::getOrCreate(context, WTFMove(*m_registrationData.waitingWorker));
+    if (m_registrationData.activeWorker)
+        m_activeWorker = ServiceWorker::getOrCreate(context, WTFMove(*m_registrationData.activeWorker));
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: Implement proper selection of service workers.
</span><span class="cx">     context.setActiveServiceWorker(getNewestWorker());
</span><span class="lines">@@ -146,30 +143,17 @@
</span><span class="cx">     container->removeRegistration(m_registrationData.scopeURL, WTFMove(promise));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ServiceWorkerRegistration::updateStateFromServer(ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
</del><ins>+void ServiceWorkerRegistration::updateStateFromServer(ServiceWorkerRegistrationState state, RefPtr<ServiceWorker>&& serviceWorker)
</ins><span class="cx"> {
</span><del>-    auto* context = scriptExecutionContext();
-    if (!context)
-        return;
-
-    RefPtr<ServiceWorker> worker;
-    if (serviceWorkerIdentifier) {
-        auto* newestWorker = getNewestWorker();
-        if (newestWorker && newestWorker->identifier() == *serviceWorkerIdentifier)
-            worker = newestWorker;
-        else
-            worker = ServiceWorker::create(*context, *serviceWorkerIdentifier, m_registrationData.scriptURL);
-    }
-
</del><span class="cx">     switch (state) {
</span><span class="cx">     case ServiceWorkerRegistrationState::Installing:
</span><del>-        m_installingWorker = WTFMove(worker);
</del><ins>+        m_installingWorker = WTFMove(serviceWorker);
</ins><span class="cx">         break;
</span><span class="cx">     case ServiceWorkerRegistrationState::Waiting:
</span><del>-        m_waitingWorker = WTFMove(worker);
</del><ins>+        m_waitingWorker = WTFMove(serviceWorker);
</ins><span class="cx">         break;
</span><span class="cx">     case ServiceWorkerRegistrationState::Active:
</span><del>-        m_activeWorker = WTFMove(worker);
</del><ins>+        m_activeWorker = WTFMove(serviceWorker);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerRegistrationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.h    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">     
</span><span class="cx">     const ServiceWorkerRegistrationData& data() const { return m_registrationData; }
</span><span class="cx"> 
</span><del>-    void updateStateFromServer(ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>);
</del><ins>+    void updateStateFromServer(ServiceWorkerRegistrationState, RefPtr<ServiceWorker>&&);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     ServiceWorkerRegistration(ScriptExecutionContext&, Ref<ServiceWorkerContainer>&&, ServiceWorkerRegistrationData&&);
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerRegistrationDatacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp   2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.cpp      2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -36,11 +36,10 @@
</span><span class="cx">         key.isolatedCopy(),
</span><span class="cx">         identifier,
</span><span class="cx">         scopeURL.isolatedCopy(),
</span><del>-        scriptURL.isolatedCopy(),
</del><span class="cx">         updateViaCache,
</span><del>-        installingServiceWorkerIdentifier,
-        waitingServiceWorkerIdentifier,
-        activeServiceWorkerIdentifier,
</del><ins>+        installingWorker ? std::optional<ServiceWorkerData>(installingWorker->isolatedCopy()) : std::nullopt,
+        waitingWorker ? std::optional<ServiceWorkerData>(waitingWorker->isolatedCopy()) : std::nullopt,
+        activeWorker ? std::optional<ServiceWorkerData>(activeWorker->isolatedCopy()) : std::nullopt,
</ins><span class="cx">     };
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerRegistrationDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h     2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistrationData.h        2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_WORKER)
</span><span class="cx"> 
</span><ins>+#include "ServiceWorkerData.h"
</ins><span class="cx"> #include "ServiceWorkerIdentifier.h"
</span><span class="cx"> #include "ServiceWorkerRegistrationKey.h"
</span><span class="cx"> #include "ServiceWorkerTypes.h"
</span><span class="lines">@@ -39,12 +40,11 @@
</span><span class="cx">     ServiceWorkerRegistrationKey key;
</span><span class="cx">     ServiceWorkerRegistrationIdentifier identifier;
</span><span class="cx">     URL scopeURL;
</span><del>-    URL scriptURL;
</del><span class="cx">     ServiceWorkerUpdateViaCache updateViaCache;
</span><span class="cx"> 
</span><del>-    std::optional<ServiceWorkerIdentifier> installingServiceWorkerIdentifier;
-    std::optional<ServiceWorkerIdentifier> waitingServiceWorkerIdentifier;
-    std::optional<ServiceWorkerIdentifier> activeServiceWorkerIdentifier;
</del><ins>+    std::optional<ServiceWorkerData> installingWorker;
+    std::optional<ServiceWorkerData> waitingWorker;
+    std::optional<ServiceWorkerData> activeWorker;
</ins><span class="cx"> 
</span><span class="cx">     ServiceWorkerRegistrationData isolatedCopy() const;
</span><span class="cx"> 
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx"> template<class Encoder>
</span><span class="cx"> void ServiceWorkerRegistrationData::encode(Encoder& encoder) const
</span><span class="cx"> {
</span><del>-    encoder << key << identifier << scopeURL << scriptURL << updateViaCache << installingServiceWorkerIdentifier << waitingServiceWorkerIdentifier << activeServiceWorkerIdentifier;
</del><ins>+    encoder << key << identifier << scopeURL << updateViaCache << installingWorker << waitingWorker << activeWorker;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template<class Decoder>
</span><span class="lines">@@ -77,32 +77,27 @@
</span><span class="cx">     if (!scopeURL)
</span><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><del>-    std::optional<URL> scriptURL;
-    decoder >> scriptURL;
-    if (!scriptURL)
-        return std::nullopt;
-
</del><span class="cx">     std::optional<ServiceWorkerUpdateViaCache> updateViaCache;
</span><span class="cx">     decoder >> updateViaCache;
</span><span class="cx">     if (!updateViaCache)
</span><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><del>-    std::optional<std::optional<ServiceWorkerIdentifier>> installingServiceWorkerIdentifier;
-    decoder >> installingServiceWorkerIdentifier;
-    if (!installingServiceWorkerIdentifier)
</del><ins>+    std::optional<std::optional<ServiceWorkerData>> installingWorker;
+    decoder >> installingWorker;
+    if (!installingWorker)
</ins><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><del>-    std::optional<std::optional<ServiceWorkerIdentifier>> waitingServiceWorkerIdentifier;
-    decoder >> waitingServiceWorkerIdentifier;
-    if (!waitingServiceWorkerIdentifier)
</del><ins>+    std::optional<std::optional<ServiceWorkerData>> waitingWorker;
+    decoder >> waitingWorker;
+    if (!waitingWorker)
</ins><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><del>-    std::optional<std::optional<ServiceWorkerIdentifier>> activeServiceWorkerIdentifier;
-    decoder >> activeServiceWorkerIdentifier;
-    if (!activeServiceWorkerIdentifier)
</del><ins>+    std::optional<std::optional<ServiceWorkerData>> activeWorker;
+    decoder >> activeWorker;
+    if (!activeWorker)
</ins><span class="cx">         return std::nullopt;
</span><span class="cx"> 
</span><del>-    return { { WTFMove(*key), WTFMove(*identifier), WTFMove(*scopeURL), WTFMove(*scriptURL), WTFMove(*updateViaCache), WTFMove(*installingServiceWorkerIdentifier), WTFMove(*waitingServiceWorkerIdentifier), WTFMove(*activeServiceWorkerIdentifier) } };
</del><ins>+    return { { WTFMove(*key), WTFMove(*identifier), WTFMove(*scopeURL), WTFMove(*updateViaCache), WTFMove(*installingWorker), WTFMove(*waitingWorker), WTFMove(*activeWorker) } };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WTF
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverSWClientConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp       2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp  2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -118,7 +118,7 @@
</span><span class="cx">     job->startScriptFetch();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
</del><ins>+void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerData&& sourceData, const String& sourceOrigin)
</ins><span class="cx"> {
</span><span class="cx">     // FIXME: destinationScriptExecutionContextIdentifier can only identify a Document at the moment.
</span><span class="cx">     auto* destinationDocument = Document::allDocumentsMap().get(destinationScriptExecutionContextIdentifier);
</span><span class="lines">@@ -129,14 +129,7 @@
</span><span class="cx">     if (!container)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    std::optional<MessageEventSource> source;
-    auto* activeServiceWorker = destinationDocument->activeServiceWorker();
-    if (activeServiceWorker && activeServiceWorker->identifier() == sourceIdentifier)
-        source = MessageEventSource { RefPtr<ServiceWorker> { activeServiceWorker } };
-    else {
-        // FIXME: Pass in valid scriptURL.
-        source = MessageEventSource { RefPtr<ServiceWorker> { ServiceWorker::create(*destinationDocument, sourceIdentifier, URL()) } };
-    }
</del><ins>+    MessageEventSource source = RefPtr<ServiceWorker> { ServiceWorker::getOrCreate(*destinationDocument, WTFMove(sourceData)) };
</ins><span class="cx"> 
</span><span class="cx">     // FIXME: We should pass in ports.
</span><span class="cx">     auto messageEvent = MessageEvent::create({ }, WTFMove(message), sourceOrigin, { }, WTFMove(source));
</span><span class="lines">@@ -152,10 +145,10 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SWClientConnection::updateRegistrationState(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
</del><ins>+void SWClientConnection::updateRegistrationState(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerData>& serviceWorkerData)
</ins><span class="cx"> {
</span><span class="cx">     forEachContainer([&](ServiceWorkerContainer& container) {
</span><del>-        container.scheduleTaskToUpdateRegistrationState(identifier, state, serviceWorkerIdentifier);
</del><ins>+        container.scheduleTaskToUpdateRegistrationState(identifier, state, serviceWorkerData);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverSWClientConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/SWClientConnection.h 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.h    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> enum class ServiceWorkerState;
</span><span class="cx"> enum class ShouldNotifyWhenResolved;
</span><span class="cx"> struct ExceptionData;
</span><ins>+struct ServiceWorkerData;
</ins><span class="cx"> struct ServiceWorkerFetchResult;
</span><span class="cx"> struct ServiceWorkerRegistrationData;
</span><span class="cx"> 
</span><span class="lines">@@ -74,8 +75,8 @@
</span><span class="cx">     WEBCORE_EXPORT void registrationJobResolvedInServer(uint64_t jobIdentifier, ServiceWorkerRegistrationData&&, ShouldNotifyWhenResolved);
</span><span class="cx">     WEBCORE_EXPORT void unregistrationJobResolvedInServer(uint64_t jobIdentifier, bool unregistrationResult);
</span><span class="cx">     WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier);
</span><del>-    WEBCORE_EXPORT void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerIdentifier source, const String& sourceOrigin);
-    WEBCORE_EXPORT void updateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>);
</del><ins>+    WEBCORE_EXPORT void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, ServiceWorkerData&& source, const String& sourceOrigin);
+    WEBCORE_EXPORT void updateRegistrationState(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerData>&);
</ins><span class="cx">     WEBCORE_EXPORT void updateWorkerState(ServiceWorkerIdentifier, ServiceWorkerState);
</span><span class="cx">     WEBCORE_EXPORT void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverSWServerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/SWServer.h   2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h      2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">         const SWServerRegistration* doRegistrationMatching(const SecurityOriginData& topOrigin, const URL& clientURL) const { return m_server.doRegistrationMatching(topOrigin, clientURL); }
</span><span class="cx"> 
</span><span class="cx">         // Messages to the client WebProcess
</span><del>-        virtual void updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, std::optional<ServiceWorkerIdentifier>) = 0;
</del><ins>+        virtual void updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier, ServiceWorkerRegistrationState, const std::optional<ServiceWorkerData>&) = 0;
</ins><span class="cx">         virtual void updateWorkerStateInClient(ServiceWorkerIdentifier, ServiceWorkerState) = 0;
</span><span class="cx">         virtual void fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier) = 0;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverSWServerRegistrationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp     2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp        2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -81,12 +81,12 @@
</span><span class="cx">         break;
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier;
</del><ins>+    std::optional<ServiceWorkerData> serviceWorkerData;
</ins><span class="cx">     if (worker)
</span><del>-        serviceWorkerIdentifier = worker->identifier();
</del><ins>+        serviceWorkerData = worker->data();
</ins><span class="cx"> 
</span><span class="cx">     forEachConnection([&](auto& connection) {
</span><del>-        connection.updateRegistrationStateInClient(identifier(), state, serviceWorkerIdentifier);
</del><ins>+        connection.updateRegistrationStateInClient(identifier(), state, serviceWorkerData);
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -118,19 +118,19 @@
</span><span class="cx"> 
</span><span class="cx"> ServiceWorkerRegistrationData SWServerRegistration::data() const
</span><span class="cx"> {
</span><del>-    std::optional<ServiceWorkerIdentifier> installingID;
</del><ins>+    std::optional<ServiceWorkerData> installingWorkerData;
</ins><span class="cx">     if (m_installingWorker)
</span><del>-        installingID = m_installingWorker->identifier();
</del><ins>+        installingWorkerData = m_installingWorker->data();
</ins><span class="cx"> 
</span><del>-    std::optional<ServiceWorkerIdentifier> waitingID;
</del><ins>+    std::optional<ServiceWorkerData> waitingWorkerData;
</ins><span class="cx">     if (m_waitingWorker)
</span><del>-        waitingID = m_waitingWorker->identifier();
</del><ins>+        waitingWorkerData = m_waitingWorker->data();
</ins><span class="cx"> 
</span><del>-    std::optional<ServiceWorkerIdentifier> activeID;
</del><ins>+    std::optional<ServiceWorkerData> activeWorkerData;
</ins><span class="cx">     if (m_activeWorker)
</span><del>-        activeID = m_activeWorker->identifier();
</del><ins>+        activeWorkerData = m_activeWorker->data();
</ins><span class="cx"> 
</span><del>-    return { m_registrationKey, identifier(), m_scopeURL, m_scriptURL, m_updateViaCache, installingID, waitingID, activeID };
</del><ins>+    return { m_registrationKey, identifier(), m_scopeURL, m_updateViaCache, WTFMove(installingWorkerData), WTFMove(waitingWorkerData), WTFMove(activeWorkerData) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SWServerRegistration::addClientServiceWorkerRegistration(uint64_t connectionIdentifier)
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverSWServerWorkercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp   2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp      2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -43,14 +43,12 @@
</span><span class="cx">     return allWorkers().get(identifier);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SWServerWorker::SWServerWorker(SWServer& server, const ServiceWorkerRegistrationKey& registrationKey, SWServerToContextConnectionIdentifier contextConnectionIdentifier, const URL& url, const String& script, WorkerType type, ServiceWorkerIdentifier identifier)
</del><ins>+SWServerWorker::SWServerWorker(SWServer& server, const ServiceWorkerRegistrationKey& registrationKey, SWServerToContextConnectionIdentifier contextConnectionIdentifier, const URL& scriptURL, const String& script, WorkerType type, ServiceWorkerIdentifier identifier)
</ins><span class="cx">     : m_server(server)
</span><span class="cx">     , m_registrationKey(registrationKey)
</span><span class="cx">     , m_contextConnectionIdentifier(contextConnectionIdentifier)
</span><del>-    , m_scriptURL(url)
</del><ins>+    , m_data { identifier, scriptURL, ServiceWorkerState::Redundant, type }
</ins><span class="cx">     , m_script(script)
</span><del>-    , m_identifier(identifier)
-    , m_type(type)
</del><span class="cx"> {
</span><span class="cx">     auto result = allWorkers().add(identifier, this);
</span><span class="cx">     ASSERT_UNUSED(result, result.isNewEntry);
</span><span class="lines">@@ -58,7 +56,7 @@
</span><span class="cx"> 
</span><span class="cx"> SWServerWorker::~SWServerWorker()
</span><span class="cx"> {
</span><del>-    auto taken = allWorkers().take(m_identifier);
</del><ins>+    auto taken = allWorkers().take(identifier());
</ins><span class="cx">     ASSERT_UNUSED(taken, taken == this);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverSWServerWorkerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/SWServerWorker.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/SWServerWorker.h     2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebCore/workers/service/server/SWServerWorker.h        2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SERVICE_WORKER)
</span><span class="cx"> 
</span><ins>+#include "ServiceWorkerData.h"
</ins><span class="cx"> #include "ServiceWorkerIdentifier.h"
</span><span class="cx"> #include "ServiceWorkerRegistrationKey.h"
</span><span class="cx"> #include "ServiceWorkerTypes.h"
</span><span class="lines">@@ -46,21 +47,21 @@
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     SWServerWorker(const SWServerWorker&) = delete;
</span><del>-    ~SWServerWorker();
</del><ins>+    WEBCORE_EXPORT ~SWServerWorker();
</ins><span class="cx"> 
</span><span class="cx">     void terminate();
</span><span class="cx"> 
</span><span class="cx">     SWServer& server();
</span><span class="cx">     const ServiceWorkerRegistrationKey& registrationKey() const { return m_registrationKey; }
</span><del>-    const URL& scriptURL() const { return m_scriptURL; }
</del><ins>+    const URL& scriptURL() const { return m_data.scriptURL; }
</ins><span class="cx">     const String& script() const { return m_script; }
</span><del>-    WorkerType type() const { return m_type; }
</del><ins>+    WorkerType type() const { return m_data.type; }
</ins><span class="cx"> 
</span><del>-    ServiceWorkerIdentifier identifier() const { return m_identifier; }
</del><ins>+    ServiceWorkerIdentifier identifier() const { return m_data.identifier; }
</ins><span class="cx">     SWServerToContextConnectionIdentifier contextConnectionIdentifier() const { return m_contextConnectionIdentifier; }
</span><span class="cx"> 
</span><del>-    ServiceWorkerState state() const { return m_state; }
-    void setState(ServiceWorkerState state) { m_state = state; }
</del><ins>+    ServiceWorkerState state() const { return m_data.state; }
+    void setState(ServiceWorkerState state) { m_data.state = state; }
</ins><span class="cx"> 
</span><span class="cx">     bool hasPendingEvents() const { return m_hasPendingEvents; }
</span><span class="cx">     void setHasPendingEvents(bool value) { m_hasPendingEvents = value; }
</span><span class="lines">@@ -72,6 +73,8 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static SWServerWorker* existingWorkerForIdentifier(ServiceWorkerIdentifier);
</span><span class="cx"> 
</span><ins>+    const ServiceWorkerData& data() const { return m_data; }
+
</ins><span class="cx"> private:
</span><span class="cx">     SWServerWorker(SWServer&, const ServiceWorkerRegistrationKey&, SWServerToContextConnectionIdentifier, const URL&, const String& script, WorkerType, ServiceWorkerIdentifier);
</span><span class="cx"> 
</span><span class="lines">@@ -78,12 +81,8 @@
</span><span class="cx">     SWServer& m_server;
</span><span class="cx">     ServiceWorkerRegistrationKey m_registrationKey;
</span><span class="cx">     SWServerToContextConnectionIdentifier m_contextConnectionIdentifier;
</span><del>-    URL m_scriptURL;
</del><ins>+    ServiceWorkerData m_data;
</ins><span class="cx">     String m_script;
</span><del>-    ServiceWorkerIdentifier m_identifier;
-    WorkerType m_type;
-    
-    ServiceWorkerState m_state { ServiceWorkerState::Redundant };
</del><span class="cx">     bool m_hasPendingEvents { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebKit/ChangeLog       2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2017-11-13  Chris Dumez  <cdumez@apple.com>
+
+        Send ServiceWorkerData structs to the WebProcesses instead of ServiceWorkerIdentifiers
+        https://bugs.webkit.org/show_bug.cgi?id=179649
+
+        Reviewed by Brady Eidson.
+
+        * Shared/WebCoreArgumentCoders.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::updateRegistrationStateInClient):
+        (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient):
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+
</ins><span class="cx"> 2017-11-13  Brady Eidson  <beidson@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Massive "Server-process-to-context-process" connection overhaul.
</span></span></pre></div>
<a id="trunkSourceWebKitStorageProcessServiceWorkerWebSWServerConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp       2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp  2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -91,9 +91,9 @@
</span><span class="cx">     send(Messages::WebSWClientConnection::StartScriptFetchForServer(jobIdentifier));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebSWServerConnection::updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, std::optional<ServiceWorkerIdentifier> serviceWorkerIdentifier)
</del><ins>+void WebSWServerConnection::updateRegistrationStateInClient(ServiceWorkerRegistrationIdentifier identifier, ServiceWorkerRegistrationState state, const std::optional<ServiceWorkerData>& serviceWorkerData)
</ins><span class="cx"> {
</span><del>-    send(Messages::WebSWClientConnection::UpdateRegistrationState(identifier, state, serviceWorkerIdentifier));
</del><ins>+    send(Messages::WebSWClientConnection::UpdateRegistrationState(identifier, state, serviceWorkerData));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebSWServerConnection::fireUpdateFoundEvent(ServiceWorkerRegistrationIdentifier identifier)
</span><span class="lines">@@ -142,9 +142,13 @@
</span><span class="cx">     m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidNotHandle { }, fetchIdentifier);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebSWServerConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceServiceWorkerIdentifier, const String& sourceOrigin)
</del><ins>+void WebSWServerConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
</ins><span class="cx"> {
</span><del>-    send(Messages::WebSWClientConnection::PostMessageToServiceWorkerClient { destinationScriptExecutionContextIdentifier, message, sourceServiceWorkerIdentifier, sourceOrigin });
</del><ins>+    auto* sourceServiceWorker = server().workerByID(sourceIdentifier);
+    if (!sourceServiceWorker)
+        return;
+
+    send(Messages::WebSWClientConnection::PostMessageToServiceWorkerClient { destinationScriptExecutionContextIdentifier, message, sourceServiceWorker->data(), sourceOrigin });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebSWServerConnection::matchRegistration(uint64_t registrationMatchRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL)
</span></span></pre></div>
<a id="trunkSourceWebKitStorageProcessServiceWorkerWebSWServerConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">     void resolveRegistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&, WebCore::ShouldNotifyWhenResolved) final;
</span><span class="cx">     void resolveUnregistrationJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationKey&, bool unregistrationResult) final;
</span><span class="cx">     void startScriptFetchInClient(uint64_t jobIdentifier) final;
</span><del>-    void updateRegistrationStateInClient(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ServiceWorkerRegistrationState, std::optional<WebCore::ServiceWorkerIdentifier>) final;
</del><ins>+    void updateRegistrationStateInClient(WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ServiceWorkerRegistrationState, const std::optional<WebCore::ServiceWorkerData>&) final;
</ins><span class="cx">     void updateWorkerStateInClient(WebCore::ServiceWorkerIdentifier, WebCore::ServiceWorkerState) final;
</span><span class="cx">     void fireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier) final;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessStorageWebSWClientConnectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -131,9 +131,9 @@
</span><span class="cx">     return ServiceWorkerClientFetch::create(provider, WTFMove(loader), identifier, m_connection.get(), WTFMove(callback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebSWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin)
</del><ins>+void WebSWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, ServiceWorkerData&& source, const String& sourceOrigin)
</ins><span class="cx"> {
</span><del>-    SWClientConnection::postMessageToServiceWorkerClient(destinationScriptExecutionContextIdentifier, SerializedScriptValue::adopt(message.vector()), sourceIdentifier, sourceOrigin);
</del><ins>+    SWClientConnection::postMessageToServiceWorkerClient(destinationScriptExecutionContextIdentifier, SerializedScriptValue::adopt(message.vector()), WTFMove(source), sourceOrigin);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessStorageWebSWClientConnectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h   2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h      2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     bool hasServiceWorkerRegisteredForOrigin(const WebCore::SecurityOrigin&) const final;
</span><span class="cx">     Ref<ServiceWorkerClientFetch> startFetch(WebServiceWorkerProvider&, Ref<WebCore::ResourceLoader>&&, uint64_t identifier, ServiceWorkerClientFetch::Callback&&);
</span><span class="cx"> 
</span><del>-    void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerIdentifier sourceIdentifier, const String& sourceOrigin);
</del><ins>+    void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, WebCore::ServiceWorkerData&& source, const String& sourceOrigin);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessStorageWebSWClientConnectionmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in (224803 => 224804)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in 2017-11-14 06:03:07 UTC (rev 224803)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in    2017-11-14 06:21:43 UTC (rev 224804)
</span><span class="lines">@@ -28,12 +28,12 @@
</span><span class="cx">     RegistrationJobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration, enum WebCore::ShouldNotifyWhenResolved shouldNotifyWhenResolved)
</span><span class="cx">     UnregistrationJobResolvedInServer(uint64_t identifier, bool unregistrationResult)
</span><span class="cx">     StartScriptFetchForServer(uint64_t jobIdentifier)
</span><del>-    UpdateRegistrationState(WebCore::ServiceWorkerRegistrationIdentifier identifier, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerIdentifier> serviceWorkerIdentifier)
</del><ins>+    UpdateRegistrationState(WebCore::ServiceWorkerRegistrationIdentifier identifier, enum WebCore::ServiceWorkerRegistrationState state, std::optional<WebCore::ServiceWorkerData> serviceWorkerIdentifier)
</ins><span class="cx">     UpdateWorkerState(WebCore::ServiceWorkerIdentifier serviceWorkerIdentifier, enum WebCore::ServiceWorkerState state)
</span><span class="cx">     FireUpdateFoundEvent(WebCore::ServiceWorkerRegistrationIdentifier identifier)
</span><span class="cx"> 
</span><span class="cx">     SetSWOriginTableSharedMemory(WebKit::SharedMemory::Handle handle)
</span><del>-    PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, WebCore::ServiceWorkerIdentifier sourceServiceWorkerIdentifier, String sourceOrigin)
</del><ins>+    PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerData source, String sourceOrigin)
</ins><span class="cx"> 
</span><span class="cx">     DidMatchRegistration(uint64_t matchRequestIdentifier, std::optional<WebCore::ServiceWorkerRegistrationData> data)
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>