Title: [251142] trunk/Source
Revision
251142
Author
cdu...@apple.com
Date
2019-10-15 09:56:13 -0700 (Tue, 15 Oct 2019)

Log Message

Stop using inheritance for WebBackForwardCacheEntry
https://bugs.webkit.org/show_bug.cgi?id=202989

Reviewed by Alex Christensen.

Source/WebCore:

* history/BackForwardItemIdentifier.h:
(WebCore::BackForwardItemIdentifier::operator bool const):

Source/WebKit:

Stop using inheritance for WebBackForwardCacheEntry. This simplifies the code a bit.

* Sources.txt:
* UIProcess/WebBackForwardCache.cpp:
(WebKit::WebBackForwardCache::addEntry):
(): Deleted.
* UIProcess/WebBackForwardCacheEntry.cpp: Copied from Source/WebKit/UIProcess/WebBackForwardCacheEntry.h.
(WebKit::WebBackForwardCacheEntry::WebBackForwardCacheEntry):
(WebKit::WebBackForwardCacheEntry::~WebBackForwardCacheEntry):
(WebKit::WebBackForwardCacheEntry::takeSuspendedPage):
(WebKit::WebBackForwardCacheEntry::process const):
* UIProcess/WebBackForwardCacheEntry.h:
(WebKit::WebBackForwardCacheEntry::suspendedPage const):
(WebKit::WebBackForwardCacheEntry::processIdentifier const):
(WebKit::WebBackForwardCacheEntry::WebBackForwardCacheEntry): Deleted.
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (251141 => 251142)


--- trunk/Source/WebCore/ChangeLog	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebCore/ChangeLog	2019-10-15 16:56:13 UTC (rev 251142)
@@ -1,3 +1,13 @@
+2019-10-15  Chris Dumez  <cdu...@apple.com>
+
+        Stop using inheritance for WebBackForwardCacheEntry
+        https://bugs.webkit.org/show_bug.cgi?id=202989
+
+        Reviewed by Alex Christensen.
+
+        * history/BackForwardItemIdentifier.h:
+        (WebCore::BackForwardItemIdentifier::operator bool const):
+
 2019-10-15  Alex Christensen  <achristen...@webkit.org>
 
         Pass CORS-enabled schemes through WebProcess instead of having them NetworkProcess-global

Modified: trunk/Source/WebCore/history/BackForwardItemIdentifier.h (251141 => 251142)


--- trunk/Source/WebCore/history/BackForwardItemIdentifier.h	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebCore/history/BackForwardItemIdentifier.h	2019-10-15 16:56:13 UTC (rev 251142)
@@ -38,6 +38,7 @@
     ObjectIdentifier<ItemIdentifierType> itemIdentifier;
 
     unsigned hash() const;
+    explicit operator bool() const { return processIdentifier && itemIdentifier; }
 
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static Optional<BackForwardItemIdentifier> decode(Decoder&);

Modified: trunk/Source/WebKit/ChangeLog (251141 => 251142)


--- trunk/Source/WebKit/ChangeLog	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebKit/ChangeLog	2019-10-15 16:56:13 UTC (rev 251142)
@@ -1,3 +1,27 @@
+2019-10-15  Chris Dumez  <cdu...@apple.com>
+
+        Stop using inheritance for WebBackForwardCacheEntry
+        https://bugs.webkit.org/show_bug.cgi?id=202989
+
+        Reviewed by Alex Christensen.
+
+        Stop using inheritance for WebBackForwardCacheEntry. This simplifies the code a bit.
+
+        * Sources.txt:
+        * UIProcess/WebBackForwardCache.cpp:
+        (WebKit::WebBackForwardCache::addEntry):
+        (): Deleted.
+        * UIProcess/WebBackForwardCacheEntry.cpp: Copied from Source/WebKit/UIProcess/WebBackForwardCacheEntry.h.
+        (WebKit::WebBackForwardCacheEntry::WebBackForwardCacheEntry):
+        (WebKit::WebBackForwardCacheEntry::~WebBackForwardCacheEntry):
+        (WebKit::WebBackForwardCacheEntry::takeSuspendedPage):
+        (WebKit::WebBackForwardCacheEntry::process const):
+        * UIProcess/WebBackForwardCacheEntry.h:
+        (WebKit::WebBackForwardCacheEntry::suspendedPage const):
+        (WebKit::WebBackForwardCacheEntry::processIdentifier const):
+        (WebKit::WebBackForwardCacheEntry::WebBackForwardCacheEntry): Deleted.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-10-15  Alex Christensen  <achristen...@webkit.org>
 
         Pass CORS-enabled schemes through WebProcess instead of having them NetworkProcess-global

Modified: trunk/Source/WebKit/Sources.txt (251141 => 251142)


--- trunk/Source/WebKit/Sources.txt	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebKit/Sources.txt	2019-10-15 16:56:13 UTC (rev 251142)
@@ -262,6 +262,7 @@
 UIProcess/UserMediaProcessManager.cpp
 UIProcess/VisitedLinkStore.cpp
 UIProcess/WebBackForwardCache.cpp
+UIProcess/WebBackForwardCacheEntry.cpp
 UIProcess/WebBackForwardList.cpp
 UIProcess/WebColorPicker.cpp
 UIProcess/WebConnectionToWebProcess.cpp

Modified: trunk/Source/WebKit/UIProcess/WebBackForwardCache.cpp (251141 => 251142)


--- trunk/Source/WebKit/UIProcess/WebBackForwardCache.cpp	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardCache.cpp	2019-10-15 16:56:13 UTC (rev 251142)
@@ -38,54 +38,6 @@
 
 namespace WebKit {
 
-class EntryWithSuspendedPage final : public WebBackForwardCacheEntry {
-public:
-    EntryWithSuspendedPage(WebBackForwardCache& backForwardCache, std::unique_ptr<SuspendedPageProxy>&& suspendedPage)
-        : WebBackForwardCacheEntry(backForwardCache)
-        , m_suspendedPage(WTFMove(suspendedPage))
-    {
-    }
-
-    SuspendedPageProxy* suspendedPage() const final { return m_suspendedPage.get(); }
-    std::unique_ptr<SuspendedPageProxy> takeSuspendedPage() final { return std::exchange(m_suspendedPage, nullptr); }
-    WebCore::ProcessIdentifier processIdentifier() const final { return process().coreProcessIdentifier(); }
-    WebProcessProxy& process() const final { return m_suspendedPage->process(); }
-
-private:
-    std::unique_ptr<SuspendedPageProxy> m_suspendedPage;
-};
-
-class EntryWithoutSuspendedPage final : public WebBackForwardCacheEntry {
-public:
-    EntryWithoutSuspendedPage(WebBackForwardCache& backForwardCache, const WebCore::BackForwardItemIdentifier& backForwardItemID, WebCore::ProcessIdentifier processIdentifier)
-        : WebBackForwardCacheEntry(backForwardCache)
-        , m_processIdentifier(processIdentifier)
-        , m_backForwardItemID(backForwardItemID)
-    {
-    }
-
-    ~EntryWithoutSuspendedPage()
-    {
-        auto& process = this->process();
-        process.sendWithAsyncReply(Messages::WebProcess::ClearCachedPage(m_backForwardItemID), [token = process.throttler().backgroundActivityToken()] { });
-    }
-
-    WebCore::ProcessIdentifier processIdentifier() const final { return m_processIdentifier; }
-    WebProcessProxy& process() const final
-    {
-        auto* process = WebProcessProxy::processForIdentifier(m_processIdentifier);
-        ASSERT(process);
-        return *process;
-    }
-
-private:
-    SuspendedPageProxy* suspendedPage() const final { return nullptr; }
-    std::unique_ptr<SuspendedPageProxy> takeSuspendedPage() final { return nullptr; }
-
-    WebCore::ProcessIdentifier m_processIdentifier;
-    WebCore::BackForwardItemIdentifier m_backForwardItemID;
-};
-
 WebBackForwardCache::WebBackForwardCache(WebProcessPool& processPool)
     : m_processPool(processPool)
 {
@@ -136,12 +88,12 @@
 
 void WebBackForwardCache::addEntry(WebBackForwardListItem& item, std::unique_ptr<SuspendedPageProxy>&& suspendedPage)
 {
-    addEntry(item, makeUnique<EntryWithSuspendedPage>(*this, WTFMove(suspendedPage)));
+    addEntry(item, makeUnique<WebBackForwardCacheEntry>(*this, item.itemID(), suspendedPage->process().coreProcessIdentifier(), WTFMove(suspendedPage)));
 }
 
 void WebBackForwardCache::addEntry(WebBackForwardListItem& item, WebCore::ProcessIdentifier processIdentifier)
 {
-    addEntry(item, makeUnique<EntryWithoutSuspendedPage>(*this, item.itemID(), WTFMove(processIdentifier)));
+    addEntry(item, makeUnique<WebBackForwardCacheEntry>(*this, item.itemID(), WTFMove(processIdentifier)));
 }
 
 void WebBackForwardCache::removeEntry(WebBackForwardListItem& item)

Copied: trunk/Source/WebKit/UIProcess/WebBackForwardCacheEntry.cpp (from rev 251139, trunk/Source/WebKit/UIProcess/WebBackForwardCacheEntry.h) (0 => 251142)


--- trunk/Source/WebKit/UIProcess/WebBackForwardCacheEntry.cpp	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardCacheEntry.cpp	2019-10-15 16:56:13 UTC (rev 251142)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebBackForwardCacheEntry.h"
+
+#include "SuspendedPageProxy.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
+
+namespace WebKit {
+
+WebBackForwardCacheEntry::WebBackForwardCacheEntry(WebBackForwardCache& backForwardCache, WebCore::BackForwardItemIdentifier backForwardItemID, WebCore::ProcessIdentifier processIdentifier, std::unique_ptr<SuspendedPageProxy>&& suspendedPage)
+    : m_backForwardCache(backForwardCache)
+    , m_processIdentifier(processIdentifier)
+    , m_backForwardItemID(backForwardItemID)
+    , m_suspendedPage(WTFMove(suspendedPage))
+{
+}
+
+WebBackForwardCacheEntry::~WebBackForwardCacheEntry()
+{
+    if (m_backForwardItemID && !m_suspendedPage) {
+        auto& process = this->process();
+        process.sendWithAsyncReply(Messages::WebProcess::ClearCachedPage(m_backForwardItemID), [token = process.throttler().backgroundActivityToken()] { });
+    }
+}
+
+std::unique_ptr<SuspendedPageProxy> WebBackForwardCacheEntry::takeSuspendedPage()
+{
+    ASSERT(m_suspendedPage);
+    m_backForwardItemID = { };
+    return std::exchange(m_suspendedPage, nullptr);
+}
+
+WebProcessProxy& WebBackForwardCacheEntry::process() const
+{
+    auto* process = WebProcessProxy::processForIdentifier(m_processIdentifier);
+    ASSERT(process);
+    ASSERT(!m_suspendedPage || process == &m_suspendedPage->process());
+    return *process;
+}
+
+} // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebBackForwardCacheEntry.h (251141 => 251142)


--- trunk/Source/WebKit/UIProcess/WebBackForwardCacheEntry.h	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardCacheEntry.h	2019-10-15 16:56:13 UTC (rev 251142)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <WebCore/BackForwardItemIdentifier.h>
 #include <WebCore/ProcessIdentifier.h>
 #include <wtf/Forward.h>
 
@@ -37,23 +38,21 @@
 class WebBackForwardCacheEntry {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    virtual ~WebBackForwardCacheEntry() = default;
+    WebBackForwardCacheEntry(WebBackForwardCache&, WebCore::BackForwardItemIdentifier, WebCore::ProcessIdentifier, std::unique_ptr<SuspendedPageProxy>&& = nullptr);
+    ~WebBackForwardCacheEntry();
 
     WebBackForwardCache& backForwardCache() const { return m_backForwardCache; }
 
-    virtual SuspendedPageProxy* suspendedPage() const = 0;
-    virtual std::unique_ptr<SuspendedPageProxy> takeSuspendedPage() = 0;
-    virtual WebCore::ProcessIdentifier processIdentifier() const = 0;
-    virtual WebProcessProxy& process() const = 0;
+    SuspendedPageProxy* suspendedPage() const { return m_suspendedPage.get(); }
+    std::unique_ptr<SuspendedPageProxy> takeSuspendedPage();
+    WebCore::ProcessIdentifier processIdentifier() const { return m_processIdentifier; }
+    WebProcessProxy& process() const;
 
-protected:
-    explicit WebBackForwardCacheEntry(WebBackForwardCache& backForwardCache)
-        : m_backForwardCache(backForwardCache)
-    {
-    }
-
 private:
     WebBackForwardCache& m_backForwardCache;
+    WebCore::ProcessIdentifier m_processIdentifier;
+    WebCore::BackForwardItemIdentifier m_backForwardItemID;
+    std::unique_ptr<SuspendedPageProxy> m_suspendedPage;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp (251141 => 251142)


--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp	2019-10-15 16:56:13 UTC (rev 251142)
@@ -33,6 +33,11 @@
 #include <wtf/CompletionHandler.h>
 #include <wtf/NeverDestroyed.h>
 
+#if !PLATFORM(COCOA)
+#include <WebCore/PasteboardCustomData.h>
+#include <WebCore/PasteboardItemInfo.h>
+#endif
+
 namespace WebKit {
 
 WebPasteboardProxy& WebPasteboardProxy::singleton()
@@ -70,17 +75,17 @@
     completionHandler({ });
 }
 
-void WebPasteboardProxy::writeCustomData(const Vector<PasteboardCustomData>&, const String&, CompletionHandler<void(uint64_t)>&& completionHandler)
+void WebPasteboardProxy::writeCustomData(const Vector<WebCore::PasteboardCustomData>&, const String&, CompletionHandler<void(uint64_t)>&& completionHandler)
 {
     completionHandler(0);
 }
 
-void WebPasteboardProxy::allPasteboardItemInfo(const String&, CompletionHandler<void(Vector<PasteboardItemInfo>&&)>&& completionHandler)
+void WebPasteboardProxy::allPasteboardItemInfo(const String&, CompletionHandler<void(Vector<WebCore::PasteboardItemInfo>&&)>&& completionHandler)
 {
     completionHandler({ });
 }
 
-void WebPasteboardProxy::informationForItemAtIndex(size_t, const String&, CompletionHandler<void(PasteboardItemInfo&&)>&& completionHandler)
+void WebPasteboardProxy::informationForItemAtIndex(size_t, const String&, CompletionHandler<void(WebCore::PasteboardItemInfo&&)>&& completionHandler)
 {
     completionHandler({ });
 }

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (251141 => 251142)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-10-15 16:42:55 UTC (rev 251141)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-10-15 16:56:13 UTC (rev 251142)
@@ -3205,6 +3205,7 @@
 		463236842314825C00A48FA7 /* WebRemoteObjectRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebRemoteObjectRegistry.cpp; sourceTree = "<group>"; };
 		463236852314833F00A48FA7 /* UIRemoteObjectRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIRemoteObjectRegistry.h; sourceTree = "<group>"; };
 		463236862314833F00A48FA7 /* UIRemoteObjectRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UIRemoteObjectRegistry.cpp; sourceTree = "<group>"; };
+		463473B623561D2A00BE1A84 /* WebBackForwardCacheEntry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebBackForwardCacheEntry.cpp; sourceTree = "<group>"; };
 		463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKProcessTerminationReason.h; sourceTree = "<group>"; };
 		463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProcessTerminationReason.h; sourceTree = "<group>"; };
 		4651ECE622178A850067EB95 /* WebProcessCacheCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessCacheCocoa.mm; sourceTree = "<group>"; };
@@ -7828,6 +7829,7 @@
 				1A60224918C16B0800C3E8C9 /* VisitedLinkStore.messages.in */,
 				4603011A234BE31D009C8217 /* WebBackForwardCache.cpp */,
 				4603011B234BE31E009C8217 /* WebBackForwardCache.h */,
+				463473B623561D2A00BE1A84 /* WebBackForwardCacheEntry.cpp */,
 				46F9B26223526ED0006FE5FA /* WebBackForwardCacheEntry.h */,
 				BC72BA1B11E64907001EB4EA /* WebBackForwardList.cpp */,
 				BC72BA1C11E64907001EB4EA /* WebBackForwardList.h */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to