<!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>[248668] trunk/Source</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/248668">248668</a></dd>
<dt>Author</dt> <dd>youenn@apple.com</dd>
<dt>Date</dt> <dd>2019-08-14 04:06:27 -0700 (Wed, 14 Aug 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove SessionID default constructor
https://bugs.webkit.org/show_bug.cgi?id=200669

Reviewed by Alex Christensen.

Source/WebCore:

Remove SessionID default constructor

Update CookieRequestHeaderFiledProxy decoder to use an Optional<SessionID>.
Update ServiceWorkerContextData accordingly.
Update RegistrationStore/RegistrationDatabase to store a map of changed registration as follows:
- The RegistrationStore map contains an Optional value. In case of removing, the map will contain WTF::nullopt.
- RegistrationDatabase computes two vectors for removed registrations and updated registrations.

No change of behavior.

* dom/Document.cpp:
* loader/CookieJar.cpp:
(WebCore::CookieJar::cookieRequestHeaderFieldProxy):
* platform/network/CookieRequestHeaderFieldProxy.h:
(WebCore::CookieRequestHeaderFieldProxy::decode):
* workers/Worker.cpp:
(WebCore::Worker::notifyFinished):
* workers/service/ServiceWorkerContextData.h:
(WebCore::ServiceWorkerContextData::decode):
* workers/service/server/RegistrationDatabase.cpp:
(WebCore::RegistrationDatabase::pushChanges):
(WebCore::RegistrationDatabase::doPushChanges):
* workers/service/server/RegistrationDatabase.h:
* workers/service/server/RegistrationStore.cpp:
(WebCore::RegistrationStore::pushChangesToDatabase):
(WebCore::RegistrationStore::clearAll):
(WebCore::RegistrationStore::flushChanges):
(WebCore::RegistrationStore::startSuspension):
(WebCore::RegistrationStore::removeRegistration):
* workers/service/server/RegistrationStore.h:

Source/WebCore/PAL:

* pal/SessionID.h:

Source/WebKit:

Update IPC decoder to use an Optional<SessionID>.
Update PageConfiguration to use emptySessionID instead of default constructor.

* NetworkProcess/NetworkSessionCreationParameters.cpp:
(WebKit::NetworkSessionCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/APIPageConfiguration.cpp:
(API::PageConfiguration::PageConfiguration):
(API::PageConfiguration::sessionID): Deleted.
(API::PageConfiguration::setSessionID): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePALChangeLog">trunk/Source/WebCore/PAL/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePALpalSessionIDh">trunk/Source/WebCore/PAL/pal/SessionID.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderCookieJarcpp">trunk/Source/WebCore/loader/CookieJar.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkCookieRequestHeaderFieldProxyh">trunk/Source/WebCore/platform/network/CookieRequestHeaderFieldProxy.h</a></li>
<li><a href="#trunkSourceWebCoreworkersWorkercpp">trunk/Source/WebCore/workers/Worker.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceServiceWorkerContextDatah">trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverRegistrationDatabasecpp">trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverRegistrationDatabaseh">trunk/Source/WebCore/workers/service/server/RegistrationDatabase.h</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverRegistrationStorecpp">trunk/Source/WebCore/workers/service/server/RegistrationStore.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersserviceserverRegistrationStoreh">trunk/Source/WebCore/workers/service/server/RegistrationStore.h</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitNetworkProcessNetworkSessionCreationParameterscpp">trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKitSharedWebPageCreationParametersh">trunk/Source/WebKit/Shared/WebPageCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIPageConfigurationcpp">trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/ChangeLog      2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -1,5 +1,43 @@
</span><span class="cx"> 2019-08-14  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><ins>+        Remove SessionID default constructor
+        https://bugs.webkit.org/show_bug.cgi?id=200669
+
+        Reviewed by Alex Christensen.
+
+        Remove SessionID default constructor
+
+        Update CookieRequestHeaderFiledProxy decoder to use an Optional<SessionID>.
+        Update ServiceWorkerContextData accordingly.
+        Update RegistrationStore/RegistrationDatabase to store a map of changed registration as follows:
+        - The RegistrationStore map contains an Optional value. In case of removing, the map will contain WTF::nullopt.
+        - RegistrationDatabase computes two vectors for removed registrations and updated registrations.
+
+        No change of behavior.
+
+        * dom/Document.cpp:
+        * loader/CookieJar.cpp:
+        (WebCore::CookieJar::cookieRequestHeaderFieldProxy):
+        * platform/network/CookieRequestHeaderFieldProxy.h:
+        (WebCore::CookieRequestHeaderFieldProxy::decode):
+        * workers/Worker.cpp:
+        (WebCore::Worker::notifyFinished):
+        * workers/service/ServiceWorkerContextData.h:
+        (WebCore::ServiceWorkerContextData::decode):
+        * workers/service/server/RegistrationDatabase.cpp:
+        (WebCore::RegistrationDatabase::pushChanges):
+        (WebCore::RegistrationDatabase::doPushChanges):
+        * workers/service/server/RegistrationDatabase.h:
+        * workers/service/server/RegistrationStore.cpp:
+        (WebCore::RegistrationStore::pushChangesToDatabase):
+        (WebCore::RegistrationStore::clearAll):
+        (WebCore::RegistrationStore::flushChanges):
+        (WebCore::RegistrationStore::startSuspension):
+        (WebCore::RegistrationStore::removeRegistration):
+        * workers/service/server/RegistrationStore.h:
+
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
</ins><span class="cx">         Make privateBrowsingStateDidChange take an explicit SessionID
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=200666
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorePALChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/ChangeLog (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/ChangeLog       2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/PAL/ChangeLog  2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -1,5 +1,14 @@
</span><span class="cx"> 2019-08-14  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><ins>+        Remove SessionID default constructor
+        https://bugs.webkit.org/show_bug.cgi?id=200669
+
+        Reviewed by Alex Christensen.
+
+        * pal/SessionID.h:
+
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
</ins><span class="cx">         Fail decoding an invalid SessionID
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=200663
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorePALpalSessionIDh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PAL/pal/SessionID.h (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PAL/pal/SessionID.h 2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/PAL/pal/SessionID.h    2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -32,10 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> class SessionID {
</span><span class="cx"> public:
</span><del>-    SessionID()
-        : SessionID(emptySessionID())
-    {
-    }
</del><ins>+    SessionID() = delete;
</ins><span class="cx"> 
</span><span class="cx">     enum SessionConstants : uint64_t {
</span><span class="cx">         EphemeralSessionMask    = 0x8000000000000000,
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp    2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/dom/Document.cpp       2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -560,6 +560,7 @@
</span><span class="cx">     , m_isSynthesized(constructionFlags & Synthesized)
</span><span class="cx">     , m_isNonRenderedPlaceholder(constructionFlags & NonRenderedPlaceholder)
</span><span class="cx">     , m_orientationNotifier(currentOrientation(frame))
</span><ins>+    , m_sessionID(PAL::SessionID::emptySessionID())
</ins><span class="cx">     , m_identifier(DocumentIdentifier::generate())
</span><span class="cx">     , m_undoManager(UndoManager::create(*this))
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderCookieJarcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/CookieJar.cpp (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CookieJar.cpp        2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/loader/CookieJar.cpp   2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -94,17 +94,14 @@
</span><span class="cx"> {
</span><span class="cx">     TraceScope scope(FetchCookiesStart, FetchCookiesEnd);
</span><span class="cx"> 
</span><del>-    CookieRequestHeaderFieldProxy proxy;
-    proxy.sessionID = document.sessionID();
-    proxy.firstParty = document.firstPartyForCookies();
-    proxy.sameSiteInfo = sameSiteInfo(document);
-    proxy.url = url;
-    proxy.includeSecureCookies = shouldIncludeSecureCookies(document, url);
</del><ins>+    Optional<uint64_t> frameID;
+    Optional<PageIdentifier> pageID;
</ins><span class="cx">     if (auto* frame = document.frame()) {
</span><del>-        proxy.frameID = frame->loader().client().frameID();
-        proxy.pageID = frame->loader().client().pageID();
</del><ins>+        frameID = frame->loader().client().frameID();
+        pageID = frame->loader().client().pageID();
</ins><span class="cx">     }
</span><del>-    return proxy;
</del><ins>+
+    return { document.sessionID(), document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, shouldIncludeSecureCookies(document, url) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CookieJar::setCookies(Document& document, const URL& url, const String& cookieString)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkCookieRequestHeaderFieldProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/CookieRequestHeaderFieldProxy.h (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/CookieRequestHeaderFieldProxy.h    2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/platform/network/CookieRequestHeaderFieldProxy.h       2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -61,25 +61,37 @@
</span><span class="cx"> template<class Decoder>
</span><span class="cx"> Optional<CookieRequestHeaderFieldProxy> CookieRequestHeaderFieldProxy::decode(Decoder& decoder)
</span><span class="cx"> {
</span><del>-    CookieRequestHeaderFieldProxy result;
-    if (!decoder.decode(result.sessionID))
</del><ins>+    Optional<PAL::SessionID> sessionID;
+    decoder >> sessionID;
+    if (!sessionID)
+        return { };
+
+    URL firstParty;
+    if (!decoder.decode(firstParty))
</ins><span class="cx">         return WTF::nullopt;
</span><del>-    if (!decoder.decode(result.firstParty))
</del><ins>+
+    SameSiteInfo sameSiteInfo;
+    if (!decoder.decode(sameSiteInfo))
</ins><span class="cx">         return WTF::nullopt;
</span><del>-    if (!decoder.decode(result.sameSiteInfo))
</del><ins>+
+    URL url;
+    if (!decoder.decode(url))
</ins><span class="cx">         return WTF::nullopt;
</span><del>-    if (!decoder.decode(result.url))
</del><ins>+
+    Optional<uint64_t> frameID;
+    if (!decoder.decode(frameID))
</ins><span class="cx">         return WTF::nullopt;
</span><del>-    if (!decoder.decode(result.frameID))
-        return WTF::nullopt;
</del><ins>+
</ins><span class="cx">     Optional<Optional<PageIdentifier>> pageID;
</span><span class="cx">     decoder >> pageID;
</span><span class="cx">     if (!pageID)
</span><span class="cx">         return WTF::nullopt;
</span><del>-    result.pageID = *pageID;
-    if (!decoder.decode(result.includeSecureCookies))
</del><ins>+
+    IncludeSecureCookies includeSecureCookies;
+    if (!decoder.decode(includeSecureCookies))
</ins><span class="cx">         return WTF::nullopt;
</span><del>-    return result;
</del><ins>+
+    return CookieRequestHeaderFieldProxy { *sessionID, WTFMove(firstParty), WTFMove(sameSiteInfo), WTFMove(url), frameID, *pageID, includeSecureCookies };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersWorkercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/Worker.cpp (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/Worker.cpp  2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/workers/Worker.cpp     2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -182,7 +182,7 @@
</span><span class="cx"> void Worker::notifyFinished()
</span><span class="cx"> {
</span><span class="cx">     auto* context = scriptExecutionContext();
</span><del>-    PAL::SessionID sessionID = context ? context->sessionID() : PAL::SessionID();
</del><ins>+    PAL::SessionID sessionID = context ? context->sessionID() : PAL::SessionID::emptySessionID();
</ins><span class="cx"> 
</span><span class="cx">     if (m_scriptLoader->failed() || !sessionID.isValid())
</span><span class="cx">         dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::Yes));
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceServiceWorkerContextDatah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h  2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h     2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -40,7 +40,6 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> struct ServiceWorkerContextData {
</span><del>-
</del><span class="cx">     struct ImportedScript {
</span><span class="cx">         String script;
</span><span class="cx">         URL responseURL;
</span><span class="lines">@@ -132,8 +131,9 @@
</span><span class="cx">     if (!decoder.decodeEnum(workerType))
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><del>-    PAL::SessionID sessionID;
-    if (!decoder.decode(sessionID))
</del><ins>+    Optional<PAL::SessionID> sessionID;
+    decoder >> sessionID;
+    if (!sessionID)
</ins><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><span class="cx">     bool loadedFromDisk;
</span><span class="lines">@@ -144,7 +144,7 @@
</span><span class="cx">     if (!decoder.decode(scriptResourceMap))
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><del>-    return {{ WTFMove(*jobDataIdentifier), WTFMove(*registration), WTFMove(*serviceWorkerIdentifier), WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(referrerPolicy), WTFMove(scriptURL), workerType, sessionID, loadedFromDisk, WTFMove(scriptResourceMap) }};
</del><ins>+    return {{ WTFMove(*jobDataIdentifier), WTFMove(*registration), WTFMove(*serviceWorkerIdentifier), WTFMove(script), WTFMove(contentSecurityPolicy), WTFMove(referrerPolicy), WTFMove(scriptURL), workerType, *sessionID, loadedFromDisk, WTFMove(scriptResourceMap) }};
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverRegistrationDatabasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp     2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp        2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -273,11 +273,20 @@
</span><span class="cx">     return WTF::nullopt;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RegistrationDatabase::pushChanges(Vector<ServiceWorkerContextData>&& datas, CompletionHandler<void()>&& completionHandler)
</del><ins>+void RegistrationDatabase::pushChanges(const HashMap<ServiceWorkerRegistrationKey, Optional<ServiceWorkerContextData>>& changedRegistrations, CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    postTaskToWorkQueue([this, datas = crossThreadCopy(datas), completionHandler = WTFMove(completionHandler)]() mutable {
-        doPushChanges(WTFMove(datas));
</del><ins>+    Vector<ServiceWorkerContextData> updatedRegistrations;
+    Vector<ServiceWorkerRegistrationKey> removedRegistrations;
+    for (auto& keyValue : changedRegistrations) {
+        if (keyValue.value)
+            updatedRegistrations.append(keyValue.value->isolatedCopy());
+        else
+            removedRegistrations.append(keyValue.key.isolatedCopy());
+    }
</ins><span class="cx"> 
</span><ins>+    postTaskToWorkQueue([this, updatedRegistrations = WTFMove(updatedRegistrations), removedRegistrations = WTFMove(removedRegistrations), completionHandler = WTFMove(completionHandler)]() mutable {
+        doPushChanges(updatedRegistrations, removedRegistrations);
+
</ins><span class="cx">         if (!completionHandler)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="lines">@@ -305,7 +314,7 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RegistrationDatabase::doPushChanges(Vector<ServiceWorkerContextData>&& datas)
</del><ins>+void RegistrationDatabase::doPushChanges(const Vector<ServiceWorkerContextData>& updatedRegistrations, const Vector<ServiceWorkerRegistrationKey>& removedRegistrations)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_database) {
</span><span class="cx">         openSQLiteDatabase(m_databaseFilePath);
</span><span class="lines">@@ -322,19 +331,17 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    for (auto& data : datas) {
-        if (data.registration.identifier == ServiceWorkerRegistrationIdentifier()) {
-            SQLiteStatement sql(*m_database, "DELETE FROM Records WHERE key = ?");
-            if (sql.prepare() != SQLITE_OK
-                || sql.bindText(1, data.registration.key.toDatabaseKey()) != SQLITE_OK
-                || sql.step() != SQLITE_DONE) {
-                RELEASE_LOG_ERROR(ServiceWorker, "Failed to remove registration data from records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
-                return;
-            }
-
-            continue;
</del><ins>+    for (auto& registration : removedRegistrations) {
+        SQLiteStatement sql(*m_database, "DELETE FROM Records WHERE key = ?");
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindText(1, registration.toDatabaseKey()) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            RELEASE_LOG_ERROR(ServiceWorker, "Failed to remove registration data from records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
+            return;
</ins><span class="cx">         }
</span><ins>+    }
</ins><span class="cx"> 
</span><ins>+    for (auto& data : updatedRegistrations) {
</ins><span class="cx">         WTF::Persistence::Encoder cspEncoder;
</span><span class="cx">         data.contentSecurityPolicy.encode(cspEncoder);
</span><span class="cx"> 
</span><span class="lines">@@ -361,7 +368,7 @@
</span><span class="cx"> 
</span><span class="cx">     transaction.commit();
</span><span class="cx"> 
</span><del>-    LOG(ServiceWorker, "Pushed %zu changes to ServiceWorker registration database", datas.size());
</del><ins>+    LOG(ServiceWorker, "Updated ServiceWorker registration database (%zu added/updated registrations and %zu removed registrations", updatedRegistrations.size(), removedRegistrations.size());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String RegistrationDatabase::importRecords()
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverRegistrationDatabaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/RegistrationDatabase.h (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/RegistrationDatabase.h       2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/workers/service/server/RegistrationDatabase.h  2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #if ENABLE(SERVICE_WORKER)
</span><span class="cx"> 
</span><span class="cx"> #include "SecurityOrigin.h"
</span><ins>+#include "ServiceWorkerRegistrationKey.h"
</ins><span class="cx"> #include <pal/SessionID.h>
</span><span class="cx"> #include <wtf/ThreadSafeRefCounted.h>
</span><span class="cx"> #include <wtf/WeakPtr.h>
</span><span class="lines">@@ -52,8 +53,7 @@
</span><span class="cx"> 
</span><span class="cx">     ~RegistrationDatabase();
</span><span class="cx"> 
</span><del>-
-    void pushChanges(Vector<ServiceWorkerContextData>&&, CompletionHandler<void()>&&);
</del><ins>+    void pushChanges(const HashMap<ServiceWorkerRegistrationKey, Optional<ServiceWorkerContextData>>&, CompletionHandler<void()>&&);
</ins><span class="cx">     void clearAll(CompletionHandler<void()>&&);
</span><span class="cx">     void close(CompletionHandler<void()>&&);
</span><span class="cx"> 
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">     String ensureValidRecordsTable();
</span><span class="cx">     String importRecords();
</span><span class="cx">     void importRecordsIfNecessary();
</span><del>-    void doPushChanges(Vector<ServiceWorkerContextData>&&);
</del><ins>+    void doPushChanges(const Vector<ServiceWorkerContextData>&, const Vector<ServiceWorkerRegistrationKey>&);
</ins><span class="cx">     void doClearOrigin(const SecurityOrigin&);
</span><span class="cx"> 
</span><span class="cx">     // Replies to the main thread.
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverRegistrationStorecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/RegistrationStore.cpp (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/RegistrationStore.cpp        2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/workers/service/server/RegistrationStore.cpp   2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx">     m_databasePushTimer.startOneShot(0_s);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RegistrationStore::pushChangesToDatabase(WTF::CompletionHandler<void()>&& completionHandler)
</del><ins>+void RegistrationStore::pushChangesToDatabase(CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     if (m_isSuspended) {
</span><span class="cx">         m_needsPushingChanges = true;
</span><span class="lines">@@ -57,16 +57,11 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Vector<ServiceWorkerContextData> changesToPush;
-    changesToPush.reserveInitialCapacity(m_updatedRegistrations.size());
-    for (auto& value : m_updatedRegistrations.values())
-        changesToPush.uncheckedAppend(WTFMove(value));
-
</del><ins>+    m_database->pushChanges(m_updatedRegistrations, WTFMove(completionHandler));
</ins><span class="cx">     m_updatedRegistrations.clear();
</span><del>-    m_database->pushChanges(WTFMove(changesToPush), WTFMove(completionHandler));
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RegistrationStore::clearAll(WTF::CompletionHandler<void()>&& completionHandler)
</del><ins>+void RegistrationStore::clearAll(CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     m_needsPushingChanges = false;
</span><span class="cx">     m_updatedRegistrations.clear();
</span><span class="lines">@@ -74,7 +69,7 @@
</span><span class="cx">     m_database->clearAll(WTFMove(completionHandler));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RegistrationStore::flushChanges(WTF::CompletionHandler<void()>&& completionHandler)
</del><ins>+void RegistrationStore::flushChanges(CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     if (m_databasePushTimer.isActive()) {
</span><span class="cx">         pushChangesToDatabase(WTFMove(completionHandler));
</span><span class="lines">@@ -84,7 +79,7 @@
</span><span class="cx">     completionHandler();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RegistrationStore::startSuspension(WTF::CompletionHandler<void()>&& completionHandler)
</del><ins>+void RegistrationStore::startSuspension(CompletionHandler<void()>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     m_isSuspended = true;
</span><span class="cx">     closeDatabase(WTFMove(completionHandler));
</span><span class="lines">@@ -120,9 +115,7 @@
</span><span class="cx">     if (key.isEmpty())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    ServiceWorkerContextData contextData;
-    contextData.registration.key = key;
-    m_updatedRegistrations.set(key, WTFMove(contextData));
</del><ins>+    m_updatedRegistrations.set(key, WTF::nullopt);
</ins><span class="cx">     scheduleDatabasePushIfNecessary();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersserviceserverRegistrationStoreh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/server/RegistrationStore.h (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/server/RegistrationStore.h  2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebCore/workers/service/server/RegistrationStore.h     2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> class RegistrationStore : public CanMakeWeakPtr<RegistrationStore> {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    explicit RegistrationStore(SWServer&, String&& databaseDirectory);
</del><ins>+    RegistrationStore(SWServer&, String&& databaseDirectory);
</ins><span class="cx">     ~RegistrationStore();
</span><span class="cx"> 
</span><span class="cx">     void clearAll(CompletionHandler<void()>&&);
</span><span class="lines">@@ -68,13 +68,13 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void scheduleDatabasePushIfNecessary();
</span><del>-    void pushChangesToDatabase(WTF::CompletionHandler<void()>&&);
</del><ins>+    void pushChangesToDatabase(CompletionHandler<void()>&&);
</ins><span class="cx">     void pushChangesToDatabase() { pushChangesToDatabase({ }); }
</span><span class="cx"> 
</span><span class="cx">     SWServer& m_server;
</span><span class="cx">     Ref<RegistrationDatabase> m_database;
</span><span class="cx"> 
</span><del>-    HashMap<ServiceWorkerRegistrationKey, ServiceWorkerContextData> m_updatedRegistrations;
</del><ins>+    HashMap<ServiceWorkerRegistrationKey, Optional<ServiceWorkerContextData>> m_updatedRegistrations;
</ins><span class="cx">     Timer m_databasePushTimer;
</span><span class="cx"> 
</span><span class="cx">     bool m_isSuspended { false };
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebKit/ChangeLog       2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -1,5 +1,23 @@
</span><span class="cx"> 2019-08-14  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><ins>+        Remove SessionID default constructor
+        https://bugs.webkit.org/show_bug.cgi?id=200669
+
+        Reviewed by Alex Christensen.
+
+        Update IPC decoder to use an Optional<SessionID>.
+        Update PageConfiguration to use emptySessionID instead of default constructor.
+
+        * NetworkProcess/NetworkSessionCreationParameters.cpp:
+        (WebKit::NetworkSessionCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/APIPageConfiguration.cpp:
+        (API::PageConfiguration::PageConfiguration):
+        (API::PageConfiguration::sessionID): Deleted.
+        (API::PageConfiguration::setSessionID): Deleted.
+
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
</ins><span class="cx">         Make WebSWOriginStore::m_webSWServerConnections a WeakHashSet
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=200661
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitNetworkProcessNetworkSessionCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp  2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSessionCreationParameters.cpp     2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -95,8 +95,9 @@
</span><span class="cx"> 
</span><span class="cx"> Optional<NetworkSessionCreationParameters> NetworkSessionCreationParameters::decode(IPC::Decoder& decoder)
</span><span class="cx"> {
</span><del>-    PAL::SessionID sessionID;
-    if (!decoder.decode(sessionID))
</del><ins>+    Optional<PAL::SessionID> sessionID;
+    decoder >> sessionID;
+    if (!sessionID)
</ins><span class="cx">         return WTF::nullopt;
</span><span class="cx">     
</span><span class="cx">     Optional<String> boundInterfaceIdentifier;
</span><span class="lines">@@ -245,7 +246,7 @@
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><span class="cx">     return {{
</span><del>-        sessionID
</del><ins>+        *sessionID
</ins><span class="cx">         , WTFMove(*boundInterfaceIdentifier)
</span><span class="cx">         , WTFMove(*allowsCellularAccess)
</span><span class="cx"> #if PLATFORM(COCOA)
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebPageCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h   2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h      2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -97,7 +97,7 @@
</span><span class="cx">     String userAgent;
</span><span class="cx"> 
</span><span class="cx">     Vector<BackForwardListItemState> itemStates;
</span><del>-    PAL::SessionID sessionID;
</del><ins>+    PAL::SessionID sessionID { PAL::SessionID::emptySessionID() };
</ins><span class="cx"> 
</span><span class="cx">     UserContentControllerIdentifier userContentControllerID;
</span><span class="cx">     uint64_t visitedLinkTableID;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIPageConfigurationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp (248667 => 248668)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp       2019-08-14 10:25:00 UTC (rev 248667)
+++ trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp  2019-08-14 11:06:27 UTC (rev 248668)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PageConfiguration::PageConfiguration()
</span><ins>+    : m_sessionID(PAL::SessionID::emptySessionID())
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -164,7 +165,7 @@
</span><span class="cx">     if (m_websiteDataStore)
</span><span class="cx">         m_sessionID = m_websiteDataStore->websiteDataStore().sessionID();
</span><span class="cx">     else
</span><del>-        m_sessionID = PAL::SessionID();
</del><ins>+        m_sessionID = PAL::SessionID::emptySessionID();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebsitePolicies* PageConfiguration::defaultWebsitePolicies() const
</span></span></pre>
</div>
</div>

</body>
</html>