Document no longer needs to store a SessionID
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Sep 2019 21:35:58 +0000 (21:35 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Sep 2019 21:35:58 +0000 (21:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202024

Reviewed by Geoffrey Garen.

Document no longer needs to store a SessionID, now that we have a single
session per WebProcess. It can simply get its sessionID from its Page.

Source/WebCore:

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::create):
* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::didOpenSocketStream):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* dom/DOMImplementation.cpp:
(WebCore::createXMLDocument):
(WebCore::DOMImplementation::createDocument):
(WebCore::DOMImplementation::createHTMLDocument):
* dom/DOMImplementation.h:
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::m_undoManager):
(WebCore::Document::create):
(WebCore::Document::createNonRenderedPlaceholder):
(WebCore::Document::cloneDocumentWithoutChildren const):
(WebCore::Document::sessionID const):
(WebCore::Document::privateBrowsingStateDidChange):
(WebCore::Document::ensureTemplateDocument):
(WebCore::Document::logger):
(WebCore::Document::didLogMessage):
* dom/Document.h:
(WebCore::Document::create):
* dom/XMLDocument.h:
(WebCore::XMLDocument::create):
(WebCore::XMLDocument::createXHTML):
(WebCore::XMLDocument::XMLDocument):
* html/FTPDirectoryDocument.cpp:
(WebCore::FTPDirectoryDocument::FTPDirectoryDocument):
* html/FTPDirectoryDocument.h:
* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::parseAdClickAttribution const):
* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::createSynthesizedDocument):
(WebCore::HTMLDocument::HTMLDocument):
(WebCore::HTMLDocument::cloneDocumentWithoutChildren const):
* html/HTMLDocument.h:
(WebCore::HTMLDocument::create):
* html/ImageDocument.cpp:
(WebCore::ImageDocument::ImageDocument):
* html/MediaDocument.cpp:
(WebCore::MediaDocument::MediaDocument):
* html/MediaDocument.h:
* html/PluginDocument.cpp:
(WebCore::PluginDocument::PluginDocument):
* html/TextDocument.cpp:
(WebCore::TextDocument::TextDocument):
* html/TextDocument.h:
* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::patchDocument):
* loader/CookieJar.cpp:
(WebCore::CookieJar::cookieRequestHeaderFieldProxy):
(WebCore::CookieJar::cookieRequestHeaderFieldValue const):
* loader/CookieJar.h:
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::createDocument):
* loader/SinkDocument.cpp:
(WebCore::SinkDocument::SinkDocument):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::setResponse):
(WebCore::CachedResource::varyHeaderValuesMatch):
* loader/cache/CachedSVGDocument.cpp:
(WebCore::CachedSVGDocument::finishLoading):
* loader/cache/CachedSVGFont.cpp:
(WebCore::CachedSVGFont::ensureCustomFontData):
* page/Page.cpp:
(WebCore::Page::configureLoggingChannel):
* platform/network/CacheValidation.cpp:
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::collectVaryingRequestHeaders):
(WebCore::verifyVaryingRequestHeaders):
* platform/network/CacheValidation.h:
* svg/SVGDocument.cpp:
(WebCore::SVGDocument::SVGDocument):
(WebCore::SVGDocument::cloneDocumentWithoutChildren const):
* svg/SVGDocument.h:
(WebCore::SVGDocument::create):
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::isAlwaysOnLoggingAllowed const):
* worklets/WorkletGlobalScope.cpp:
(WebCore::WorkletGlobalScope::WorkletGlobalScope):
* worklets/WorkletGlobalScope.h:
* xml/DOMParser.cpp:
(WebCore::DOMParser::parseFromString):
* xml/DOMParser.h:
* xml/DOMParser.idl:
* xml/XMLHttpRequest.cpp:
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::createDocumentFromSource):

Source/WebKit:

* WebProcess/WebPage/WebCookieJar.cpp:
(WebKit::WebCookieJar::cookieRequestHeaderFieldValue const):
* WebProcess/WebPage/WebCookieJar.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250153 268f45cc-cd09-0410-ab3c-d52691b4dbfc

44 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/websockets/WebSocketChannel.cpp
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/dom/DOMImplementation.h
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/XMLDocument.h
Source/WebCore/html/FTPDirectoryDocument.cpp
Source/WebCore/html/FTPDirectoryDocument.h
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLDocument.cpp
Source/WebCore/html/HTMLDocument.h
Source/WebCore/html/ImageDocument.cpp
Source/WebCore/html/MediaDocument.cpp
Source/WebCore/html/MediaDocument.h
Source/WebCore/html/PluginDocument.cpp
Source/WebCore/html/TextDocument.cpp
Source/WebCore/html/TextDocument.h
Source/WebCore/inspector/DOMPatchSupport.cpp
Source/WebCore/loader/CookieJar.cpp
Source/WebCore/loader/CookieJar.h
Source/WebCore/loader/DocumentWriter.cpp
Source/WebCore/loader/SinkDocument.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedSVGDocument.cpp
Source/WebCore/loader/cache/CachedSVGFont.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/platform/network/CacheValidation.cpp
Source/WebCore/platform/network/CacheValidation.h
Source/WebCore/svg/SVGDocument.cpp
Source/WebCore/svg/SVGDocument.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/worklets/WorkletGlobalScope.cpp
Source/WebCore/worklets/WorkletGlobalScope.h
Source/WebCore/xml/DOMParser.cpp
Source/WebCore/xml/DOMParser.h
Source/WebCore/xml/DOMParser.idl
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XSLTProcessor.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/WebCookieJar.cpp
Source/WebKit/WebProcess/WebPage/WebCookieJar.h

index 3a3651c..7acac3f 100644 (file)
@@ -1,3 +1,104 @@
+2019-09-20  Chris Dumez  <cdumez@apple.com>
+
+        Document no longer needs to store a SessionID
+        https://bugs.webkit.org/show_bug.cgi?id=202024
+
+        Reviewed by Geoffrey Garen.
+
+        Document no longer needs to store a SessionID, now that we have a single
+        session per WebProcess. It can simply get its sessionID from its Page.
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::create):
+        * Modules/websockets/WebSocketChannel.cpp:
+        (WebCore::WebSocketChannel::didOpenSocketStream):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * dom/DOMImplementation.cpp:
+        (WebCore::createXMLDocument):
+        (WebCore::DOMImplementation::createDocument):
+        (WebCore::DOMImplementation::createHTMLDocument):
+        * dom/DOMImplementation.h:
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::m_undoManager):
+        (WebCore::Document::create):
+        (WebCore::Document::createNonRenderedPlaceholder):
+        (WebCore::Document::cloneDocumentWithoutChildren const):
+        (WebCore::Document::sessionID const):
+        (WebCore::Document::privateBrowsingStateDidChange):
+        (WebCore::Document::ensureTemplateDocument):
+        (WebCore::Document::logger):
+        (WebCore::Document::didLogMessage):
+        * dom/Document.h:
+        (WebCore::Document::create):
+        * dom/XMLDocument.h:
+        (WebCore::XMLDocument::create):
+        (WebCore::XMLDocument::createXHTML):
+        (WebCore::XMLDocument::XMLDocument):
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::FTPDirectoryDocument::FTPDirectoryDocument):
+        * html/FTPDirectoryDocument.h:
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::parseAdClickAttribution const):
+        * html/HTMLDocument.cpp:
+        (WebCore::HTMLDocument::createSynthesizedDocument):
+        (WebCore::HTMLDocument::HTMLDocument):
+        (WebCore::HTMLDocument::cloneDocumentWithoutChildren const):
+        * html/HTMLDocument.h:
+        (WebCore::HTMLDocument::create):
+        * html/ImageDocument.cpp:
+        (WebCore::ImageDocument::ImageDocument):
+        * html/MediaDocument.cpp:
+        (WebCore::MediaDocument::MediaDocument):
+        * html/MediaDocument.h:
+        * html/PluginDocument.cpp:
+        (WebCore::PluginDocument::PluginDocument):
+        * html/TextDocument.cpp:
+        (WebCore::TextDocument::TextDocument):
+        * html/TextDocument.h:
+        * inspector/DOMPatchSupport.cpp:
+        (WebCore::DOMPatchSupport::patchDocument):
+        * loader/CookieJar.cpp:
+        (WebCore::CookieJar::cookieRequestHeaderFieldProxy):
+        (WebCore::CookieJar::cookieRequestHeaderFieldValue const):
+        * loader/CookieJar.h:
+        * loader/DocumentWriter.cpp:
+        (WebCore::DocumentWriter::createDocument):
+        * loader/SinkDocument.cpp:
+        (WebCore::SinkDocument::SinkDocument):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::setResponse):
+        (WebCore::CachedResource::varyHeaderValuesMatch):
+        * loader/cache/CachedSVGDocument.cpp:
+        (WebCore::CachedSVGDocument::finishLoading):
+        * loader/cache/CachedSVGFont.cpp:
+        (WebCore::CachedSVGFont::ensureCustomFontData):
+        * page/Page.cpp:
+        (WebCore::Page::configureLoggingChannel):
+        * platform/network/CacheValidation.cpp:
+        (WebCore::cookieRequestHeaderFieldValue):
+        (WebCore::collectVaryingRequestHeaders):
+        (WebCore::verifyVaryingRequestHeaders):
+        * platform/network/CacheValidation.h:
+        * svg/SVGDocument.cpp:
+        (WebCore::SVGDocument::SVGDocument):
+        (WebCore::SVGDocument::cloneDocumentWithoutChildren const):
+        * svg/SVGDocument.h:
+        (WebCore::SVGDocument::create):
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::isAlwaysOnLoggingAllowed const):
+        * worklets/WorkletGlobalScope.cpp:
+        (WebCore::WorkletGlobalScope::WorkletGlobalScope):
+        * worklets/WorkletGlobalScope.h:
+        * xml/DOMParser.cpp:
+        (WebCore::DOMParser::parseFromString):
+        * xml/DOMParser.h:
+        * xml/DOMParser.idl:
+        * xml/XMLHttpRequest.cpp:
+        * xml/XSLTProcessor.cpp:
+        (WebCore::XSLTProcessor::createDocumentFromSource):
+
 2019-09-20  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         [SVG2]: Add auto behavior for rx and ry to the SVG <ellipse> and <rect> elements (Addressing review comments)
index 7ea332b..e0f31a7 100644 (file)
@@ -76,7 +76,7 @@ Ref<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context
         peerConnection->m_pendingActivity = peerConnection->makePendingActivity(peerConnection.get());
         if (auto* page = document.page()) {
             peerConnection->registerToController(page->rtcController());
-            page->libWebRTCProvider().setEnableLogging(!document.sessionID().isEphemeral());
+            page->libWebRTCProvider().setEnableLogging(!page->sessionID().isEphemeral());
         }
     }
     return peerConnection;
index a07a876..dbb1b45 100644 (file)
@@ -271,8 +271,8 @@ void WebSocketChannel::didOpenSocketStream(SocketStreamHandle& handle)
     }
     auto handshakeMessage = m_handshake->clientHandshakeMessage();
     Optional<CookieRequestHeaderFieldProxy> cookieRequestHeaderFieldProxy;
-    if (m_allowCookies)
-        cookieRequestHeaderFieldProxy = CookieJar::cookieRequestHeaderFieldProxy(*m_document, m_handshake->httpURLForAuthenticationAndCookies());
+    if (m_allowCookies && m_document->page())
+        cookieRequestHeaderFieldProxy = CookieJar::cookieRequestHeaderFieldProxy(m_document->page()->sessionID(), *m_document, m_handshake->httpURLForAuthenticationAndCookies());
     handle.sendHandshake(WTFMove(handshakeMessage), WTFMove(cookieRequestHeaderFieldProxy), [this, protectedThis = makeRef(*this)] (bool success, bool didAccessSecureCookies) {
         if (!success)
             fail("Failed to send WebSocket handshake.");
index 53c2728..62247e7 100644 (file)
@@ -2750,8 +2750,10 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         if ([attributeName isEqualToString:NSAccessibilityCaretBrowsingEnabledAttribute])
             return [NSNumber numberWithBool:m_object->caretBrowsingEnabled()];
         if ([attributeName isEqualToString:NSAccessibilityWebSessionIDAttribute]) {
-            if (Document* doc = m_object->topDocument())
-                return [NSNumber numberWithUnsignedLongLong:doc->sessionID().toUInt64()];
+            if (auto* document = m_object->topDocument()) {
+                if (auto* page = document->page())
+                    return [NSNumber numberWithUnsignedLongLong:page->sessionID().toUInt64()];
+            }
         }
     }
     
index 5030b7e..1466eaa 100644 (file)
@@ -77,18 +77,18 @@ ExceptionOr<Ref<DocumentType>> DOMImplementation::createDocumentType(const Strin
     return DocumentType::create(m_document, qualifiedName, publicId, systemId);
 }
 
-static inline Ref<XMLDocument> createXMLDocument(PAL::SessionID sessionID, const String& namespaceURI)
+static inline Ref<XMLDocument> createXMLDocument(const String& namespaceURI)
 {
     if (namespaceURI == SVGNames::svgNamespaceURI)
-        return SVGDocument::create(sessionID, nullptr, URL());
+        return SVGDocument::create(nullptr, URL());
     if (namespaceURI == HTMLNames::xhtmlNamespaceURI)
-        return XMLDocument::createXHTML(sessionID, nullptr, URL());
-    return XMLDocument::create(sessionID, nullptr, URL());
+        return XMLDocument::createXHTML(nullptr, URL());
+    return XMLDocument::create(nullptr, URL());
 }
 
 ExceptionOr<Ref<XMLDocument>> DOMImplementation::createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType* documentType)
 {
-    auto document = createXMLDocument(m_document.sessionID(), namespaceURI);
+    auto document = createXMLDocument(namespaceURI);
     document->setContextDocument(m_document.contextDocument());
     document->setSecurityOriginPolicy(m_document.securityOriginPolicy());
 
@@ -120,7 +120,7 @@ Ref<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const S
 
 Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
 {
-    auto document = HTMLDocument::create(m_document.sessionID(), nullptr, URL());
+    auto document = HTMLDocument::create(nullptr, URL());
     document->open();
     document->write(nullptr, { "<!doctype html><html><head></head><body></body></html>"_s });
     if (!title.isNull()) {
@@ -134,7 +134,7 @@ Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
     return document;
 }
 
-Ref<Document> DOMImplementation::createDocument(PAL::SessionID sessionID, const String& type, Frame* frame, const URL& url)
+Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
 {
     // FIXME: Inelegant to have this here just because this is the home of DOM APIs for creating documents.
     // This is internal, not a DOM API. Maybe we should put it in a new class called DocumentFactory,
@@ -142,11 +142,11 @@ Ref<Document> DOMImplementation::createDocument(PAL::SessionID sessionID, const
 
     // Plug-ins cannot take over for HTML, XHTML, plain text, or non-PDF images.
     if (equalLettersIgnoringASCIICase(type, "text/html"))
-        return HTMLDocument::create(sessionID, frame, url);
+        return HTMLDocument::create(frame, url);
     if (equalLettersIgnoringASCIICase(type, "application/xhtml+xml"))
-        return XMLDocument::createXHTML(sessionID, frame, url);
+        return XMLDocument::createXHTML(frame, url);
     if (equalLettersIgnoringASCIICase(type, "text/plain"))
-        return TextDocument::create(sessionID, frame, url);
+        return TextDocument::create(frame, url);
     bool isImage = MIMETypeRegistry::isSupportedImageMIMEType(type);
     if (frame && isImage && !MIMETypeRegistry::isPDFOrPostScriptMIMEType(type))
         return ImageDocument::create(*frame, url);
@@ -160,12 +160,12 @@ Ref<Document> DOMImplementation::createDocument(PAL::SessionID sessionID, const
     parameters.type = ContentType { type };
     parameters.url = url;
     if (MediaPlayer::supportsType(parameters))
-        return MediaDocument::create(sessionID, frame, url);
+        return MediaDocument::create(frame, url);
 #endif
 
 #if ENABLE(FTPDIR)
     if (equalLettersIgnoringASCIICase(type, "application/x-ftp-directory"))
-        return FTPDirectoryDocument::create(sessionID, frame, url);
+        return FTPDirectoryDocument::create(frame, url);
 #endif
 
     if (frame && frame->loader().client().shouldAlwaysUsePluginDocument(type))
@@ -184,12 +184,12 @@ Ref<Document> DOMImplementation::createDocument(PAL::SessionID sessionID, const
     if (frame && isImage)
         return ImageDocument::create(*frame, url);
     if (MIMETypeRegistry::isTextMIMEType(type))
-        return TextDocument::create(sessionID, frame, url);
+        return TextDocument::create(frame, url);
     if (equalLettersIgnoringASCIICase(type, "image/svg+xml"))
-        return SVGDocument::create(sessionID, frame, url);
+        return SVGDocument::create(frame, url);
     if (MIMETypeRegistry::isXMLMIMEType(type))
-        return XMLDocument::create(sessionID, frame, url);
-    return HTMLDocument::create(sessionID, frame, url);
+        return XMLDocument::create(frame, url);
+    return HTMLDocument::create(frame, url);
 }
 
 }
index 3757f37..4cdcacf 100644 (file)
@@ -43,7 +43,7 @@ public:
     static bool hasFeature() { return true; }
     WEBCORE_EXPORT static Ref<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media);
 
-    static Ref<Document> createDocument(PAL::SessionID, const String& MIMEType, Frame*, const URL&);
+    static Ref<Document> createDocument(const String& MIMEType, Frame*, const URL&);
 
 private:
     Document& m_document;
index 56843b1..8ed2f88 100644 (file)
@@ -511,7 +511,7 @@ static inline int currentOrientation(Frame* frame)
     return 0;
 }
 
-Document::Document(PAL::SessionID sessionID, Frame* frame, const URL& url, unsigned documentClasses, unsigned constructionFlags)
+Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsigned constructionFlags)
     : ContainerNode(*this, CreateDocument)
     , TreeScope(*this)
     , FrameDestructionObserver(frame)
@@ -561,12 +561,9 @@ Document::Document(PAL::SessionID sessionID, Frame* frame, const URL& url, unsig
     , m_isSynthesized(constructionFlags & Synthesized)
     , m_isNonRenderedPlaceholder(constructionFlags & NonRenderedPlaceholder)
     , m_orientationNotifier(currentOrientation(frame))
-    , m_sessionID(sessionID)
     , m_identifier(DocumentIdentifier::generate())
     , m_undoManager(UndoManager::create(*this))
 {
-    ASSERT(!frame || frame->sessionID() == m_sessionID);
-
     auto addResult = allDocumentsMap().add(m_identifier, this);
     ASSERT_UNUSED(addResult, addResult.isNewEntry);
 
@@ -597,7 +594,7 @@ Document::Document(PAL::SessionID sessionID, Frame* frame, const URL& url, unsig
 
 Ref<Document> Document::create(Document& contextDocument)
 {
-    auto document = adoptRef(*new Document(contextDocument.sessionID(), nullptr, URL()));
+    auto document = adoptRef(*new Document(nullptr, URL()));
     document->setContextDocument(contextDocument);
     document->setSecurityOriginPolicy(contextDocument.securityOriginPolicy());
     return document;
@@ -605,7 +602,7 @@ Ref<Document> Document::create(Document& contextDocument)
 
 Ref<Document> Document::createNonRenderedPlaceholder(Frame& frame, const URL& url)
 {
-    return adoptRef(*new Document(frame.sessionID(), &frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
+    return adoptRef(*new Document(&frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
 }
 
 Document::~Document()
@@ -3881,10 +3878,10 @@ Ref<Document> Document::cloneDocumentWithoutChildren() const
 {
     if (isXMLDocument()) {
         if (isXHTMLDocument())
-            return XMLDocument::createXHTML(sessionID(), nullptr, url());
-        return XMLDocument::create(sessionID(), nullptr, url());
+            return XMLDocument::createXHTML(nullptr, url());
+        return XMLDocument::create(nullptr, url());
     }
-    return create(sessionID(), url());
+    return create(url());
 }
 
 void Document::cloneDataFromDocument(const Document& other)
@@ -5068,9 +5065,10 @@ URL Document::completeURL(const String& url) const
     return completeURL(url, m_baseURL);
 }
 
-PAL::SessionID Document::sessionID() const
+Optional<PAL::SessionID> Document::sessionID() const
 {
-    return m_sessionID;
+    auto* page = this->page();
+    return page ? makeOptional(page->sessionID()) : WTF::nullopt;
 }
 
 void Document::setPageCacheState(PageCacheState state)
@@ -5270,7 +5268,6 @@ void Document::storageBlockingStateDidChange()
 
 void Document::privateBrowsingStateDidChange(PAL::SessionID sessionID)
 {
-    m_sessionID = sessionID;
     if (m_logger)
         m_logger->setEnabled(this, sessionID.isAlwaysOnLoggingAllowed());
 
@@ -6893,9 +6890,9 @@ Document& Document::ensureTemplateDocument()
         return const_cast<Document&>(*document);
 
     if (isHTMLDocument())
-        m_templateDocument = HTMLDocument::create(sessionID(), nullptr, WTF::blankURL());
+        m_templateDocument = HTMLDocument::create(nullptr, WTF::blankURL());
     else
-        m_templateDocument = create(sessionID(), WTF::blankURL());
+        m_templateDocument = create(WTF::blankURL());
 
     m_templateDocument->setContextDocument(contextDocument());
     m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor.
@@ -7792,7 +7789,7 @@ Logger& Document::logger()
 {
     if (!m_logger) {
         m_logger = Logger::create(this);
-        m_logger->setEnabled(this, sessionID().isAlwaysOnLoggingAllowed());
+        m_logger->setEnabled(this, sessionID() && sessionID()->isAlwaysOnLoggingAllowed());
         m_logger->addObserver(*this);
     }
 
@@ -8041,17 +8038,18 @@ void Document::didLogMessage(const WTFLogChannel& channel, WTFLogLevel level, Ve
         });
         return;
     }
-    if (!page())
+    auto* page = this->page();
+    if (!page)
         return;
 
-    ASSERT(sessionID().isAlwaysOnLoggingAllowed());
+    ASSERT(page->sessionID().isAlwaysOnLoggingAllowed());
 
     auto messageSource = messageSourceForWTFLogChannel(channel);
     if (messageSource == MessageSource::Other)
         return;
 
     m_logMessageTaskQueue.enqueueTask([this, level, messageSource, logMessages = WTFMove(logMessages)]() mutable {
-        if (!page())
+        if (!this->page())
             return;
 
         auto messageLevel = messageLevelFromWTFLogLevel(level);
index 6155af7..8c46d7e 100644 (file)
@@ -351,7 +351,7 @@ class Document
     , public Logger::Observer {
     WTF_MAKE_ISO_ALLOCATED(Document);
 public:
-    static Ref<Document> create(PAL::SessionID, const URL&);
+    static Ref<Document> create(const URL&);
     static Ref<Document> createNonRenderedPlaceholder(Frame&, const URL&);
     static Ref<Document> create(Document&);
 
@@ -683,7 +683,7 @@ public:
 
     WEBCORE_EXPORT URL completeURL(const String&) const final;
     URL completeURL(const String&, const URL& baseURLOverride) const;
-    WEBCORE_EXPORT PAL::SessionID sessionID() const;
+    WEBCORE_EXPORT Optional<PAL::SessionID> sessionID() const;
 
     String userAgent(const URL&) const final;
 
@@ -1538,7 +1538,7 @@ public:
 
 protected:
     enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
-    Document(PAL::SessionID, Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
+    Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
 
     void clearXMLVersion() { m_xmlVersion = String(); }
 
@@ -2018,7 +2018,6 @@ private:
 #endif
 
     OrientationNotifier m_orientationNotifier;
-    mutable PAL::SessionID m_sessionID;
     mutable RefPtr<Logger> m_logger;
     RefPtr<StringCallback> m_consoleMessageListener;
 
@@ -2082,9 +2081,9 @@ inline AXObjectCache* Document::existingAXObjectCache() const
     return existingAXObjectCacheSlow();
 }
 
-inline Ref<Document> Document::create(PAL::SessionID sessionID, const URL& url)
+inline Ref<Document> Document::create(const URL& url)
 {
-    return adoptRef(*new Document(sessionID, nullptr, url));
+    return adoptRef(*new Document(nullptr, url));
 }
 
 inline void Document::invalidateAccessKeyCache()
index d56feb9..964d9d7 100644 (file)
@@ -32,19 +32,19 @@ namespace WebCore {
 class XMLDocument : public Document {
     WTF_MAKE_ISO_ALLOCATED(XMLDocument);
 public:
-    static Ref<XMLDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
+    static Ref<XMLDocument> create(Frame* frame, const URL& url)
     {
-        return adoptRef(*new XMLDocument(sessionID, frame, url));
+        return adoptRef(*new XMLDocument(frame, url));
     }
 
-    static Ref<XMLDocument> createXHTML(PAL::SessionID sessionID, Frame* frame, const URL& url)
+    static Ref<XMLDocument> createXHTML(Frame* frame, const URL& url)
     {
-        return adoptRef(*new XMLDocument(sessionID, frame, url, XHTMLDocumentClass));
+        return adoptRef(*new XMLDocument(frame, url, XHTMLDocumentClass));
     }
 
 protected:
-    XMLDocument(PAL::SessionID sessionID, Frame* frame, const URL& url, unsigned documentClasses = DefaultDocumentClass)
-        : Document(sessionID, frame, url, XMLDocumentClass | documentClasses)
+    XMLDocument(Frame* frame, const URL& url, unsigned documentClasses = DefaultDocumentClass)
+        : Document(frame, url, XMLDocumentClass | documentClasses)
     { }
 };
 
index 51e1d00..f563074 100644 (file)
@@ -421,8 +421,8 @@ void FTPDirectoryDocumentParser::finish()
     HTMLDocumentParser::finish();
 }
 
-FTPDirectoryDocument::FTPDirectoryDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
-    : HTMLDocument(sessionID, frame, url)
+FTPDirectoryDocument::FTPDirectoryDocument(Frame* frame, const URL& url)
+    : HTMLDocument(frame, url)
 {
 #if !LOG_DISABLED
     LogFTP.state = WTFLogChannelState::On;
index f1cfd93..9cc876c 100644 (file)
@@ -31,13 +31,13 @@ namespace WebCore {
 class FTPDirectoryDocument final : public HTMLDocument {
     WTF_MAKE_ISO_ALLOCATED(FTPDirectoryDocument);
 public:
-    static Ref<FTPDirectoryDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
+    static Ref<FTPDirectoryDocument> create(Frame* frame, const URL& url)
     {
-        return adoptRef(*new FTPDirectoryDocument(sessionID, frame, url));
+        return adoptRef(*new FTPDirectoryDocument(frame, url));
     }
 
 private:
-    FTPDirectoryDocument(PAL::SessionID, Frame*, const URL&);
+    FTPDirectoryDocument(Frame*, const URL&);
     Ref<DocumentParser> createParser() override;
 };
 
index 535e0dc..a7a922a 100644 (file)
@@ -407,7 +407,7 @@ Optional<AdClickAttribution> HTMLAnchorElement::parseAdClickAttribution() const
     using Source = AdClickAttribution::Source;
     using Destination = AdClickAttribution::Destination;
 
-    if (document().sessionID().isEphemeral()
+    if (!document().sessionID() || document().sessionID()->isEphemeral()
         || !RuntimeEnabledFeatures::sharedFeatures().adClickAttributionEnabled()
         || !UserGestureIndicator::processingUserGesture())
         return WTF::nullopt;
index 1c21fb6..9887f5b 100644 (file)
@@ -89,11 +89,11 @@ using namespace HTMLNames;
 
 Ref<HTMLDocument> HTMLDocument::createSynthesizedDocument(Frame& frame, const URL& url)
 {
-    return adoptRef(*new HTMLDocument(frame.sessionID(), &frame, url, HTMLDocumentClass, Synthesized));
+    return adoptRef(*new HTMLDocument(&frame, url, HTMLDocumentClass, Synthesized));
 }
 
-HTMLDocument::HTMLDocument(PAL::SessionID sessionID, Frame* frame, const URL& url, DocumentClassFlags documentClasses, unsigned constructionFlags)
-    : Document(sessionID, frame, url, documentClasses | HTMLDocumentClass, constructionFlags)
+HTMLDocument::HTMLDocument(Frame* frame, const URL& url, DocumentClassFlags documentClasses, unsigned constructionFlags)
+    : Document(frame, url, documentClasses | HTMLDocumentClass, constructionFlags)
 {
     clearXMLVersion();
 }
@@ -252,7 +252,7 @@ bool HTMLDocument::isFrameSet() const
 
 Ref<Document> HTMLDocument::cloneDocumentWithoutChildren() const
 {
-    return create(sessionID(), nullptr, url());
+    return create(nullptr, url());
 }
 
 }
index 623b5d8..1c424da 100644 (file)
@@ -29,7 +29,7 @@ namespace WebCore {
 class HTMLDocument : public Document {
     WTF_MAKE_ISO_ALLOCATED(HTMLDocument);
 public:
-    static Ref<HTMLDocument> create(PAL::SessionID, Frame*, const URL&);
+    static Ref<HTMLDocument> create(Frame*, const URL&);
     static Ref<HTMLDocument> createSynthesizedDocument(Frame&, const URL&);
     virtual ~HTMLDocument();
 
@@ -54,7 +54,7 @@ public:
     static bool isCaseSensitiveAttribute(const QualifiedName&);
 
 protected:
-    HTMLDocument(PAL::SessionID, Frame*, const URL&, DocumentClassFlags = 0, unsigned constructionFlags = 0);
+    HTMLDocument(Frame*, const URL&, DocumentClassFlags = 0, unsigned constructionFlags = 0);
 
 private:
     bool isFrameSet() const final;
@@ -65,9 +65,9 @@ private:
     TreeScopeOrderedMap m_windowNamedItem;
 };
 
-inline Ref<HTMLDocument> HTMLDocument::create(PAL::SessionID sessionID, Frame* frame, const URL& url)
+inline Ref<HTMLDocument> HTMLDocument::create(Frame* frame, const URL& url)
 {
-    return adoptRef(*new HTMLDocument(sessionID, frame, url, HTMLDocumentClass));
+    return adoptRef(*new HTMLDocument(frame, url, HTMLDocumentClass));
 }
 
 } // namespace WebCore
index 22d927a..151f44c 100644 (file)
@@ -198,7 +198,7 @@ void ImageDocumentParser::finish()
 }
 
 ImageDocument::ImageDocument(Frame& frame, const URL& url)
-    : HTMLDocument(frame.sessionID(), &frame, url, ImageDocumentClass)
+    : HTMLDocument(&frame, url, ImageDocumentClass)
     , m_imageElement(nullptr)
     , m_imageSizeIsKnown(false)
 #if !PLATFORM(IOS_FAMILY)
index a3e63a5..aaed5ae 100644 (file)
@@ -144,8 +144,8 @@ void MediaDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
     finish();
 }
     
-MediaDocument::MediaDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
-    : HTMLDocument(sessionID, frame, url, MediaDocumentClass)
+MediaDocument::MediaDocument(Frame* frame, const URL& url)
+    : HTMLDocument(frame, url, MediaDocumentClass)
     , m_replaceMediaElementTimer(*this, &MediaDocument::replaceMediaElementTimerFired)
 {
     setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
index 955d35f..52bc551 100644 (file)
@@ -34,9 +34,9 @@ namespace WebCore {
 class MediaDocument final : public HTMLDocument {
     WTF_MAKE_ISO_ALLOCATED(MediaDocument);
 public:
-    static Ref<MediaDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
+    static Ref<MediaDocument> create(Frame* frame, const URL& url)
     {
-        return adoptRef(*new MediaDocument(sessionID, frame, url));
+        return adoptRef(*new MediaDocument(frame, url));
     }
     virtual ~MediaDocument();
 
@@ -45,7 +45,7 @@ public:
     String outgoingReferrer() const { return m_outgoingReferrer; }
 
 private:
-    MediaDocument(PAL::SessionID, Frame*, const URL&);
+    MediaDocument(Frame*, const URL&);
 
     Ref<DocumentParser> createParser() override;
 
index 0ff7367..2c4f76a 100644 (file)
@@ -142,7 +142,7 @@ void PluginDocumentParser::appendBytes(DocumentWriter&, const char*, size_t)
 }
 
 PluginDocument::PluginDocument(Frame& frame, const URL& url)
-    : HTMLDocument(frame.sessionID(), &frame, url, PluginDocumentClass)
+    : HTMLDocument(&frame, url, PluginDocumentClass)
 {
     setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
     lockCompatibilityMode();
index 6f596e2..e491526 100644 (file)
@@ -32,8 +32,8 @@ namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(TextDocument);
 
-TextDocument::TextDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
-    : HTMLDocument(sessionID, frame, url, TextDocumentClass)
+TextDocument::TextDocument(Frame* frame, const URL& url)
+    : HTMLDocument(frame, url, TextDocumentClass)
 {
     setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
     lockCompatibilityMode();
index 41d2fda..8c6ebb1 100644 (file)
@@ -31,13 +31,13 @@ namespace WebCore {
 class TextDocument final : public HTMLDocument {
     WTF_MAKE_ISO_ALLOCATED(TextDocument);
 public:
-    static Ref<TextDocument> create(PAL::SessionID sessionID, Frame* frame, const URL& url)
+    static Ref<TextDocument> create(Frame* frame, const URL& url)
     {
-        return adoptRef(*new TextDocument(sessionID, frame, url));
+        return adoptRef(*new TextDocument(frame, url));
     }
 
 private:
-    TextDocument(PAL::SessionID, Frame*, const URL&);
+    TextDocument(Frame*, const URL&);
     
     Ref<DocumentParser> createParser() override;
 };
index f2e586f..2e9d755 100644 (file)
@@ -76,11 +76,11 @@ void DOMPatchSupport::patchDocument(const String& markup)
 {
     RefPtr<Document> newDocument;
     if (m_document.isHTMLDocument())
-        newDocument = HTMLDocument::create(m_document.sessionID(), nullptr, URL());
+        newDocument = HTMLDocument::create(nullptr, URL());
     else if (m_document.isXHTMLDocument())
-        newDocument = XMLDocument::createXHTML(m_document.sessionID(), nullptr, URL());
+        newDocument = XMLDocument::createXHTML(nullptr, URL());
     else if (m_document.isSVGDocument())
-        newDocument = XMLDocument::create(m_document.sessionID(), nullptr, URL());
+        newDocument = XMLDocument::create(nullptr, URL());
 
     ASSERT(newDocument);
     RefPtr<DocumentParser> parser;
index 6d0362e..83829e7 100644 (file)
@@ -90,7 +90,7 @@ String CookieJar::cookies(Document& document, const URL& url) const
     return result.first;
 }
 
-CookieRequestHeaderFieldProxy CookieJar::cookieRequestHeaderFieldProxy(const Document& document, const URL& url)
+CookieRequestHeaderFieldProxy CookieJar::cookieRequestHeaderFieldProxy(PAL::SessionID sessionID, const Document& document, const URL& url)
 {
     TraceScope scope(FetchCookiesStart, FetchCookiesEnd);
 
@@ -101,7 +101,7 @@ CookieRequestHeaderFieldProxy CookieJar::cookieRequestHeaderFieldProxy(const Doc
         pageID = frame->loader().client().pageID();
     }
 
-    return { document.sessionID(), document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, shouldIncludeSecureCookies(document, url) };
+    return { sessionID, document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, shouldIncludeSecureCookies(document, url) };
 }
 
 void CookieJar::setCookies(Document& document, const URL& url, const String& cookieString)
@@ -128,7 +128,7 @@ bool CookieJar::cookiesEnabled(const Document&) const
     return false;
 }
 
-std::pair<String, SecureCookiesAccessed> CookieJar::cookieRequestHeaderFieldValue(const PAL::SessionID&, const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies) const
+std::pair<String, SecureCookiesAccessed> CookieJar::cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, IncludeSecureCookies includeSecureCookies) const
 {
     if (auto* session = m_storageSessionProvider->storageSession()) {
         std::pair<String, bool> result = session->cookieRequestHeaderFieldValue(firstParty, sameSiteInfo, url, frameID, pageID, includeSecureCookies);
@@ -148,7 +148,7 @@ String CookieJar::cookieRequestHeaderFieldValue(Document& document, const URL& u
         pageID = frame->loader().client().pageID();
     }
 
-    auto result = cookieRequestHeaderFieldValue(document.sessionID(), document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, shouldIncludeSecureCookies(document, url));
+    auto result = cookieRequestHeaderFieldValue(document.firstPartyForCookies(), sameSiteInfo(document), url, frameID, pageID, shouldIncludeSecureCookies(document, url));
     if (result.second == SecureCookiesAccessed::Yes)
         document.setSecureCookiesAccessed();
     return result.first;
index 8087b8c..be86a1e 100644 (file)
@@ -51,7 +51,7 @@ class WEBCORE_EXPORT CookieJar : public RefCounted<CookieJar> {
 public:
     static Ref<CookieJar> create(Ref<StorageSessionProvider>&&);
     
-    static CookieRequestHeaderFieldProxy cookieRequestHeaderFieldProxy(const Document&, const URL&);
+    static CookieRequestHeaderFieldProxy cookieRequestHeaderFieldProxy(PAL::SessionID, const Document&, const URL&);
 
     String cookieRequestHeaderFieldValue(Document&, const URL&) const;
 
@@ -60,7 +60,7 @@ public:
     virtual void setCookies(Document&, const URL&, const String& cookieString);
 
     virtual bool cookiesEnabled(const Document&) const;
-    virtual std::pair<String, SecureCookiesAccessed> cookieRequestHeaderFieldValue(const PAL::SessionID&, const URL& firstParty, const SameSiteInfo&, const URL&, Optional<FrameIdentifier>, Optional<PageIdentifier>, IncludeSecureCookies) const;
+    virtual std::pair<String, SecureCookiesAccessed> cookieRequestHeaderFieldValue(const URL& firstParty, const SameSiteInfo&, const URL&, Optional<FrameIdentifier>, Optional<PageIdentifier>, IncludeSecureCookies) const;
     virtual bool getRawCookies(const Document&, const URL&, Vector<Cookie>&) const;
     virtual void deleteCookie(const Document&, const URL&, const String& cookieName);
 
index d014751..ef02de1 100644 (file)
@@ -115,7 +115,7 @@ Ref<Document> DocumentWriter::createDocument(const URL& url)
 #endif
     if (!m_frame->loader().client().hasHTMLView())
         return Document::createNonRenderedPlaceholder(*m_frame, url);
-    return DOMImplementation::createDocument(m_frame->sessionID(), m_mimeType, m_frame, url);
+    return DOMImplementation::createDocument(m_mimeType, m_frame, url);
 }
 
 bool DocumentWriter::begin(const URL& urlReference, bool dispatch, Document* ownerDocument)
index 504fe21..b4be37a 100644 (file)
@@ -54,7 +54,7 @@ private:
 };
 
 SinkDocument::SinkDocument(Frame& frame, const URL& url)
-    : HTMLDocument(frame.sessionID(), &frame, url)
+    : HTMLDocument(&frame, url)
 {
     setCompatibilityMode(DocumentCompatibilityMode::QuirksMode);
     lockCompatibilityMode();
index 0567d1d..761a10b 100644 (file)
@@ -478,7 +478,7 @@ void CachedResource::setResponse(const ResourceResponse& response)
 {
     ASSERT(m_response.type() == ResourceResponse::Type::Default);
     m_response = response;
-    m_varyingHeaderValues = collectVaryingRequestHeaders(cookieJar(), m_resourceRequest, m_response, sessionID());
+    m_varyingHeaderValues = collectVaryingRequestHeaders(cookieJar(), m_resourceRequest, m_response);
 
 #if ENABLE(SERVICE_WORKER)
     if (m_response.source() == ResourceResponse::Source::ServiceWorker) {
@@ -860,7 +860,7 @@ bool CachedResource::varyHeaderValuesMatch(const ResourceRequest& request)
     if (m_varyingHeaderValues.isEmpty())
         return true;
 
-    return verifyVaryingRequestHeaders(cookieJar(), m_varyingHeaderValues, request, sessionID());
+    return verifyVaryingRequestHeaders(cookieJar(), m_varyingHeaderValues, request);
 }
 
 unsigned CachedResource::overheadSize() const
index 5b1ec32..7982707 100644 (file)
@@ -49,7 +49,7 @@ void CachedSVGDocument::finishLoading(SharedBuffer* data)
 {
     if (data) {
         // We don't need to create a new frame because the new document belongs to the parent UseElement.
-        m_document = SVGDocument::create(sessionID(), nullptr, response().url());
+        m_document = SVGDocument::create(nullptr, response().url());
         m_document->setContent(m_decoder->decodeAndFlush(data->data(), data->size()));
     }
     CachedResource::finishLoading(data);
index 0e934f2..ed288c1 100644 (file)
@@ -68,7 +68,7 @@ bool CachedSVGFont::ensureCustomFontData(const AtomString& remoteURI)
         {
             // We may get here during render tree updates when events are forbidden.
             // Frameless document can't run scripts or call back to the client so this is safe.
-            m_externalSVGDocument = SVGDocument::create(sessionID(), nullptr, URL());
+            m_externalSVGDocument = SVGDocument::create(nullptr, URL());
             auto decoder = TextResourceDecoder::create("application/xml");
 
             ScriptDisallowedScope::DisableAssertionsInScope disabledScope;
index 4538773..715859f 100644 (file)
@@ -2967,7 +2967,7 @@ void Page::configureLoggingChannel(const String& channelName, WTFLogChannelState
 
 #if USE(LIBWEBRTC)
         if (channel == &LogWebRTC && m_mainFrame->document())
-            libWebRTCProvider().setEnableLogging(!m_mainFrame->document()->sessionID().isEphemeral());
+            libWebRTCProvider().setEnableLogging(!sessionID().isEphemeral());
 #endif
     }
 
index 6ec13b2..4959050 100644 (file)
@@ -333,12 +333,12 @@ static String cookieRequestHeaderFieldValue(const NetworkStorageSession& session
     return session.cookieRequestHeaderFieldValue(request.firstPartyForCookies(), SameSiteInfo::create(request), request.url(), WTF::nullopt, WTF::nullopt, request.url().protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No).first;
 }
 
-static String cookieRequestHeaderFieldValue(const CookieJar* cookieJar, const PAL::SessionID& sessionID, const ResourceRequest& request)
+static String cookieRequestHeaderFieldValue(const CookieJar* cookieJar, const ResourceRequest& request)
 {
     if (!cookieJar)
         return { };
 
-    return cookieJar->cookieRequestHeaderFieldValue(sessionID, request.firstPartyForCookies(), SameSiteInfo::create(request), request.url(), WTF::nullopt, WTF::nullopt, request.url().protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No).first;
+    return cookieJar->cookieRequestHeaderFieldValue(request.firstPartyForCookies(), SameSiteInfo::create(request), request.url(), WTF::nullopt, WTF::nullopt, request.url().protocolIs("https") ? IncludeSecureCookies::Yes : IncludeSecureCookies::No).first;
 }
 
 static String headerValueForVary(const ResourceRequest& request, const String& headerName, Function<String()>&& cookieRequestHeaderFieldValueFunction)
@@ -379,11 +379,11 @@ Vector<std::pair<String, String>> collectVaryingRequestHeaders(NetworkStorageSes
     });
 }
 
-Vector<std::pair<String, String>> collectVaryingRequestHeaders(const CookieJar* cookieJar, const ResourceRequest& request, const ResourceResponse& response, const PAL::SessionID& sessionID)
+Vector<std::pair<String, String>> collectVaryingRequestHeaders(const CookieJar* cookieJar, const ResourceRequest& request, const ResourceResponse& response)
 {
     return collectVaryingRequestHeadersInternal(response, [&] (const String& headerName) {
         return headerValueForVary(request, headerName, [&] {
-            return cookieRequestHeaderFieldValue(cookieJar, sessionID, request);
+            return cookieRequestHeaderFieldValue(cookieJar, request);
         });
     });
 }
@@ -411,11 +411,11 @@ bool verifyVaryingRequestHeaders(NetworkStorageSession* storageSession, const Ve
     });
 }
 
-bool verifyVaryingRequestHeaders(const CookieJar* cookieJar, const Vector<std::pair<String, String>>& varyingRequestHeaders, const ResourceRequest& request, const PAL::SessionID& sessionID)
+bool verifyVaryingRequestHeaders(const CookieJar* cookieJar, const Vector<std::pair<String, String>>& varyingRequestHeaders, const ResourceRequest& request)
 {
     return verifyVaryingRequestHeadersInternal(varyingRequestHeaders, [&] (const String& headerName) {
         return headerValueForVary(request, headerName, [&] {
-            return cookieRequestHeaderFieldValue(cookieJar, sessionID, request);
+            return cookieRequestHeaderFieldValue(cookieJar, request);
         });
     });
 }
index 4c2feb7..aa7ad7f 100644 (file)
@@ -77,9 +77,9 @@ struct CacheControlDirectives {
 WEBCORE_EXPORT CacheControlDirectives parseCacheControlDirectives(const HTTPHeaderMap&);
 
 WEBCORE_EXPORT Vector<std::pair<String, String>> collectVaryingRequestHeaders(NetworkStorageSession*, const ResourceRequest&, const ResourceResponse&);
-WEBCORE_EXPORT Vector<std::pair<String, String>> collectVaryingRequestHeaders(const CookieJar*, const ResourceRequest&, const ResourceResponse&, const PAL::SessionID&);
+WEBCORE_EXPORT Vector<std::pair<String, String>> collectVaryingRequestHeaders(const CookieJar*, const ResourceRequest&, const ResourceResponse&);
 WEBCORE_EXPORT bool verifyVaryingRequestHeaders(NetworkStorageSession*, const Vector<std::pair<String, String>>& varyingRequestHeaders, const ResourceRequest&);
-WEBCORE_EXPORT bool verifyVaryingRequestHeaders(const CookieJar*, const Vector<std::pair<String, String>>& varyingRequestHeaders, const ResourceRequest&, const PAL::SessionID&);
+WEBCORE_EXPORT bool verifyVaryingRequestHeaders(const CookieJar*, const Vector<std::pair<String, String>>& varyingRequestHeaders, const ResourceRequest&);
 
 WEBCORE_EXPORT bool isStatusCodeCacheableByDefault(int statusCode);
 WEBCORE_EXPORT bool isStatusCodePotentiallyCacheable(int statusCode);
index d4dc94b..6d2f086 100644 (file)
@@ -30,8 +30,8 @@ namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(SVGDocument);
 
-SVGDocument::SVGDocument(PAL::SessionID sessionID, Frame* frame, const URL& url)
-    : XMLDocument(sessionID, frame, url, SVGDocumentClass)
+SVGDocument::SVGDocument(Frame* frame, const URL& url)
+    : XMLDocument(frame, url, SVGDocumentClass)
 {
 }
 
@@ -69,7 +69,7 @@ void SVGDocument::updatePan(const FloatPoint& position) const
 
 Ref<Document> SVGDocument::cloneDocumentWithoutChildren() const
 {
-    return create(sessionID(), nullptr, url());
+    return create(nullptr, url());
 }
 
 }
index 0903460..767771c 100644 (file)
@@ -30,7 +30,7 @@ class SVGSVGElement;
 class SVGDocument final : public XMLDocument {
     WTF_MAKE_ISO_ALLOCATED(SVGDocument);
 public:
-    static Ref<SVGDocument> create(PAL::SessionID, Frame*, const URL&);
+    static Ref<SVGDocument> create(Frame*, const URL&);
 
     static RefPtr<SVGSVGElement> rootElement(const Document&);
 
@@ -39,16 +39,16 @@ public:
     void updatePan(const FloatPoint& position) const;
 
 private:
-    SVGDocument(PAL::SessionID, Frame*, const URL&);
+    SVGDocument(Frame*, const URL&);
 
     Ref<Document> cloneDocumentWithoutChildren() const override;
 
     FloatSize m_panningOffset;
 };
 
-inline Ref<SVGDocument> SVGDocument::create(PAL::SessionID sessionID, Frame* frame, const URL& url)
+inline Ref<SVGDocument> SVGDocument::create(Frame* frame, const URL& url)
 {
-    return adoptRef(*new SVGDocument(sessionID, frame, url));
+    return adoptRef(*new SVGDocument(frame, url));
 }
 
 } // namespace WebCore
index 03e8a1a..b2654d0 100644 (file)
@@ -621,8 +621,10 @@ bool ServiceWorkerContainer::isAlwaysOnLoggingAllowed() const
     if (!context)
         return false;
 
-    if (is<Document>(*context))
-        return downcast<Document>(*context).sessionID().isAlwaysOnLoggingAllowed();
+    if (is<Document>(*context)) {
+        auto sessionID = downcast<Document>(*context).sessionID();
+        return sessionID && sessionID->isAlwaysOnLoggingAllowed();
+    }
 
     // FIXME: No logging inside service workers for now.
     return false;
index cef82f7..a5d7e61 100644 (file)
@@ -48,7 +48,6 @@ WTF_MAKE_ISO_ALLOCATED_IMPL(WorkletGlobalScope);
 
 WorkletGlobalScope::WorkletGlobalScope(Document& document, ScriptSourceCode&& code)
     : m_document(makeWeakPtr(document))
-    , m_sessionID(m_document->sessionID())
     , m_script(makeUnique<WorkletScriptController>(this))
     , m_topOrigin(SecurityOrigin::createUnique())
     , m_eventQueue(*this)
index 4da20a8..2d03c72 100644 (file)
@@ -120,14 +120,12 @@ private:
     bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) final { RELEASE_ASSERT_NOT_REACHED(); return false; }
 #endif
     URL completeURL(const String&) const final;
-    PAL::SessionID sessionID() const { return m_sessionID; }
     String userAgent(const URL&) const final;
     void disableEval(const String&) final;
     void disableWebAssembly(const String&) final;
 
     WeakPtr<Document> m_document;
 
-    PAL::SessionID m_sessionID;
     std::unique_ptr<WorkletScriptController> m_script;
 
     Ref<SecurityOrigin> m_topOrigin;
index b714796..c3856d4 100644 (file)
@@ -34,11 +34,11 @@ Ref<DOMParser> DOMParser::create(Document& contextDocument)
     return adoptRef(*new DOMParser(contextDocument));
 }
 
-ExceptionOr<Ref<Document>> DOMParser::parseFromString(Document& callingDocument, const String& string, const String& contentType)
+ExceptionOr<Ref<Document>> DOMParser::parseFromString(const String& string, const String& contentType)
 {
     if (contentType != "text/html" && contentType != "text/xml" && contentType != "application/xml" && contentType != "application/xhtml+xml" && contentType != "image/svg+xml")
         return Exception { TypeError };
-    auto document = DOMImplementation::createDocument(callingDocument.sessionID(), contentType, nullptr, URL { });
+    auto document = DOMImplementation::createDocument(contentType, nullptr, URL { });
     if (m_contextDocument)
         document->setContextDocument(*m_contextDocument.get());
     document->setContent(string);
index 5524068..42ceeb9 100644 (file)
@@ -28,7 +28,7 @@ class Document;
 class DOMParser : public RefCounted<DOMParser> {
 public:
     static Ref<DOMParser> create(Document& contextDocument);
-    ExceptionOr<Ref<Document>> parseFromString(Document&, const String&, const String& contentType);
+    ExceptionOr<Ref<Document>> parseFromString(const String&, const String& contentType);
 
 private:
     explicit DOMParser(Document& contextDocument);
index 9d52565..964e4ad 100644 (file)
@@ -22,5 +22,5 @@
     ConstructorCallWith=Document,
     ImplementationLacksVTable,
 ] interface DOMParser {
-    [MayThrowException, NewObject, CallWith=Document] Document parseFromString(DOMString string, DOMString contentType);
+    [MayThrowException, NewObject] Document parseFromString(DOMString string, DOMString contentType);
 };
index d0b4243..5535d7b 100644 (file)
@@ -185,9 +185,9 @@ ExceptionOr<Document*> XMLHttpRequest::responseXML()
             m_responseDocument = nullptr;
         } else {
             if (isHTML)
-                m_responseDocument = HTMLDocument::create(context.sessionID(), nullptr, m_url);
+                m_responseDocument = HTMLDocument::create(nullptr, m_url);
             else
-                m_responseDocument = XMLDocument::create(context.sessionID(), nullptr, m_url);
+                m_responseDocument = XMLDocument::create(nullptr, m_url);
             m_responseDocument->overrideLastModified(m_response.lastModified());
             m_responseDocument->setContent(m_responseBuilder.toStringPreserveCapacity());
             m_responseDocument->setContextDocument(context);
index d48cdeb..a68acd7 100644 (file)
@@ -72,10 +72,10 @@ Ref<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString
 
     RefPtr<Document> result;
     if (sourceMIMEType == "text/plain") {
-        result = XMLDocument::createXHTML(ownerDocument->sessionID(), frame, sourceIsDocument ? ownerDocument->url() : URL());
+        result = XMLDocument::createXHTML(frame, sourceIsDocument ? ownerDocument->url() : URL());
         transformTextStringToXHTMLDocumentString(documentSource);
     } else
-        result = DOMImplementation::createDocument(ownerDocument->sessionID(), sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL());
+        result = DOMImplementation::createDocument(sourceMIMEType, frame, sourceIsDocument ? ownerDocument->url() : URL());
 
     // Before parsing, we need to save & detach the old document and get the new document
     // in place. We have to do this only if we're rendering the result document.
index 4c10b6e..e05ca47 100644 (file)
@@ -1,5 +1,19 @@
 2019-09-20  Chris Dumez  <cdumez@apple.com>
 
+        Document no longer needs to store a SessionID
+        https://bugs.webkit.org/show_bug.cgi?id=202024
+
+        Reviewed by Geoffrey Garen.
+
+        Document no longer needs to store a SessionID, now that we have a single
+        session per WebProcess. It can simply get its sessionID from its Page.
+
+        * WebProcess/WebPage/WebCookieJar.cpp:
+        (WebKit::WebCookieJar::cookieRequestHeaderFieldValue const):
+        * WebProcess/WebPage/WebCookieJar.h:
+
+2019-09-20  Chris Dumez  <cdumez@apple.com>
+
         [iOS] ASSERTION FAILED: Unsafe to ref/deref of ShareableBitmap from different threads
         https://bugs.webkit.org/show_bug.cgi?id=201712
         <rdar://problem/55289916>
index 3ab78e5..7382fd9 100644 (file)
@@ -85,7 +85,7 @@ bool WebCookieJar::cookiesEnabled(const WebCore::Document& document) const
     return result;
 }
 
-std::pair<String, WebCore::SecureCookiesAccessed> WebCookieJar::cookieRequestHeaderFieldValue(const PAL::SessionID&, const URL& firstParty, const WebCore::SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, WebCore::IncludeSecureCookies includeSecureCookies) const
+std::pair<String, WebCore::SecureCookiesAccessed> WebCookieJar::cookieRequestHeaderFieldValue(const URL& firstParty, const WebCore::SameSiteInfo& sameSiteInfo, const URL& url, Optional<FrameIdentifier> frameID, Optional<PageIdentifier> pageID, WebCore::IncludeSecureCookies includeSecureCookies) const
 {
     String cookieString;
     bool secureCookiesAccessed = false;
index 5dcacdd..52948a9 100644 (file)
@@ -36,7 +36,7 @@ public:
     String cookies(WebCore::Document&, const URL&) const final;
     void setCookies(WebCore::Document&, const URL&, const String& cookieString) final;
     bool cookiesEnabled(const WebCore::Document&) const final;
-    std::pair<String, WebCore::SecureCookiesAccessed> cookieRequestHeaderFieldValue(const PAL::SessionID&, const URL& firstParty, const WebCore::SameSiteInfo&, const URL&, Optional<WebCore::FrameIdentifier>, Optional<WebCore::PageIdentifier>, WebCore::IncludeSecureCookies) const final;
+    std::pair<String, WebCore::SecureCookiesAccessed> cookieRequestHeaderFieldValue(const URL& firstParty, const WebCore::SameSiteInfo&, const URL&, Optional<WebCore::FrameIdentifier>, Optional<WebCore::PageIdentifier>, WebCore::IncludeSecureCookies) const final;
     bool getRawCookies(const WebCore::Document&, const URL&, Vector<WebCore::Cookie>&) const final;
     void deleteCookie(const WebCore::Document&, const URL&, const String& cookieName) final;
 private: