Unreviewed, rolling out r252260.

Breaks half of API tests

Reverted changeset:

"Make DownloadID an ObjectIdentifier"
https://bugs.webkit.org/show_bug.cgi?id=203962
https://trac.webkit.org/changeset/252260


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@252274 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index 57bf83b..0b2ea2c 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,15 @@
+2019-11-08  Jonathan Bedard  <jbedard@apple.com>
+
+        Unreviewed, rolling out r252260.
+
+        Breaks half of API tests
+
+        Reverted changeset:
+
+        "Make DownloadID an ObjectIdentifier"
+        https://bugs.webkit.org/show_bug.cgi?id=203962
+        https://trac.webkit.org/changeset/252260
+
 2019-11-08  Antti Koivisto  <antti@apple.com>
 
         Use separate cache directory for development WebKit on Mac
diff --git a/Source/WebKit/NetworkProcess/Downloads/Download.cpp b/Source/WebKit/NetworkProcess/Downloads/Download.cpp
index 9d033e8..abc461e 100644
--- a/Source/WebKit/NetworkProcess/Downloads/Download.cpp
+++ b/Source/WebKit/NetworkProcess/Downloads/Download.cpp
@@ -59,7 +59,7 @@
     , m_suggestedName(suggestedName)
     , m_testSpeedMultiplier(session.testSpeedMultiplier())
 {
-    ASSERT(m_downloadID);
+    ASSERT(m_downloadID.downloadID());
 
     m_downloadManager.didCreateDownload();
 }
@@ -74,7 +74,7 @@
     , m_suggestedName(suggestedName)
     , m_testSpeedMultiplier(session.testSpeedMultiplier())
 {
-    ASSERT(m_downloadID);
+    ASSERT(m_downloadID.downloadID());
 
     m_downloadManager.didCreateDownload();
 }
@@ -120,7 +120,7 @@
 void Download::didReceiveData(uint64_t length)
 {
     if (!m_hasReceivedData) {
-        RELEASE_LOG_IF_ALLOWED("didReceiveData: Started receiving data (id = %" PRIu64 ")", downloadID().toUInt64());
+        RELEASE_LOG_IF_ALLOWED("didReceiveData: Started receiving data (id = %" PRIu64 ")", downloadID().downloadID());
         m_hasReceivedData = true;
     }
     
@@ -131,7 +131,7 @@
 
 void Download::didFinish()
 {
-    RELEASE_LOG_IF_ALLOWED("didFinish: (id = %" PRIu64 ")", downloadID().toUInt64());
+    RELEASE_LOG_IF_ALLOWED("didFinish: (id = %" PRIu64 ")", downloadID().downloadID());
 
     send(Messages::DownloadProxy::DidFinish());
 
@@ -146,7 +146,7 @@
 void Download::didFail(const ResourceError& error, const IPC::DataReference& resumeData)
 {
     RELEASE_LOG_IF_ALLOWED("didFail: (id = %" PRIu64 ", isTimeout = %d, isCancellation = %d, errCode = %d)",
-        downloadID().toUInt64(), error.isTimeout(), error.isCancellation(), error.errorCode());
+        downloadID().downloadID(), error.isTimeout(), error.isCancellation(), error.errorCode());
 
     send(Messages::DownloadProxy::DidFail(error, resumeData));
 
@@ -159,7 +159,7 @@
 
 void Download::didCancel(const IPC::DataReference& resumeData)
 {
-    RELEASE_LOG_IF_ALLOWED("didCancel: (id = %" PRIu64 ")", downloadID().toUInt64());
+    RELEASE_LOG_IF_ALLOWED("didCancel: (id = %" PRIu64 ")", downloadID().downloadID());
 
     send(Messages::DownloadProxy::DidCancel(resumeData));
 
@@ -177,7 +177,7 @@
 
 uint64_t Download::messageSenderDestinationID() const
 {
-    return m_downloadID.toUInt64();
+    return m_downloadID.downloadID();
 }
 
 bool Download::isAlwaysOnLoggingAllowed() const
diff --git a/Source/WebKit/NetworkProcess/Downloads/DownloadID.h b/Source/WebKit/NetworkProcess/Downloads/DownloadID.h
index 151f9ce..04df707 100644
--- a/Source/WebKit/NetworkProcess/Downloads/DownloadID.h
+++ b/Source/WebKit/NetworkProcess/Downloads/DownloadID.h
@@ -23,13 +23,74 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#pragma once
+#ifndef DownloadID_h
+#define DownloadID_h
 
-#include <wtf/ObjectIdentifier.h>
+#include "ArgumentCoder.h"
+#include "Decoder.h"
+#include "Encoder.h"
+#include <wtf/HashTraits.h>
 
 namespace WebKit {
 
-enum DownloadIdentifierType { };
-using DownloadID = ObjectIdentifier<DownloadIdentifierType>;
+class DownloadID {
+public:
+    DownloadID()
+    {
+    }
+
+    explicit DownloadID(uint64_t downloadID)
+        : m_downloadID(downloadID)
+    {
+    }
+
+    bool operator==(DownloadID other) const { return m_downloadID == other.m_downloadID; }
+    bool operator!=(DownloadID other) const { return m_downloadID != other.m_downloadID; }
+
+    uint64_t downloadID() const { return m_downloadID; }
+private:
+    uint64_t m_downloadID { 0 };
+};
 
 }
+
+namespace IPC {
+    
+template<> struct ArgumentCoder<WebKit::DownloadID> {
+    static void encode(Encoder& encoder, const WebKit::DownloadID& downloadID)
+    {
+        encoder << downloadID.downloadID();
+    }
+    static bool decode(Decoder& decoder, WebKit::DownloadID& downloadID)
+    {
+        uint64_t id;
+        if (!decoder.decode(id))
+            return false;
+
+        downloadID = WebKit::DownloadID(id);
+        
+        return true;
+    }
+};
+
+}
+
+namespace WTF {
+    
+struct DownloadIDHash {
+    static unsigned hash(const WebKit::DownloadID& d) { return intHash(d.downloadID()); }
+    static bool equal(const WebKit::DownloadID& a, const WebKit::DownloadID& b) { return a.downloadID() == b.downloadID(); }
+    static const bool safeToCompareToEmptyOrDeleted = true;
+};
+template<> struct HashTraits<WebKit::DownloadID> : GenericHashTraits<WebKit::DownloadID> {
+    static WebKit::DownloadID emptyValue() { return { }; }
+    
+    static void constructDeletedValue(WebKit::DownloadID& slot) { slot = WebKit::DownloadID(std::numeric_limits<uint64_t>::max()); }
+    static bool isDeletedValue(const WebKit::DownloadID& slot) { return slot.downloadID() == std::numeric_limits<uint64_t>::max(); }
+};
+template<> struct DefaultHash<WebKit::DownloadID> {
+    typedef DownloadIDHash Hash;
+};
+
+}
+#endif /* DownloadID_h */
diff --git a/Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp b/Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp
index 9bd99d1..4958b86 100644
--- a/Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp
+++ b/Source/WebKit/NetworkProcess/Downloads/DownloadMonitor.cpp
@@ -93,14 +93,14 @@
 
 void DownloadMonitor::applicationWillEnterForeground()
 {
-    RELEASE_LOG_IF_ALLOWED("applicationWillEnterForeground (id = %" PRIu64 ")", m_download.downloadID().toUInt64());
+    RELEASE_LOG_IF_ALLOWED("applicationWillEnterForeground (id = %" PRIu64 ")", m_download.downloadID().downloadID());
     m_timer.stop();
     m_interval = 0;
 }
 
 void DownloadMonitor::applicationDidEnterBackground()
 {
-    RELEASE_LOG_IF_ALLOWED("applicationDidEnterBackground (id = %" PRIu64 ")", m_download.downloadID().toUInt64());
+    RELEASE_LOG_IF_ALLOWED("applicationDidEnterBackground (id = %" PRIu64 ")", m_download.downloadID().downloadID());
     ASSERT(!m_timer.isActive());
     ASSERT(!m_interval);
     m_timer.startOneShot(throughputIntervals[0].time / testSpeedMultiplier());
@@ -117,13 +117,13 @@
 
     RELEASE_ASSERT(m_interval < WTF_ARRAY_LENGTH(throughputIntervals));
     if (measuredThroughputRate() < throughputIntervals[m_interval].bytesPerSecond) {
-        RELEASE_LOG_IF_ALLOWED("timerFired: cancelling download (id = %" PRIu64 ")", m_download.downloadID().toUInt64());
+        RELEASE_LOG_IF_ALLOWED("timerFired: cancelling download (id = %" PRIu64 ")", m_download.downloadID().downloadID());
         m_download.cancel();
     } else if (m_interval + 1 < WTF_ARRAY_LENGTH(throughputIntervals)) {
-        RELEASE_LOG_IF_ALLOWED("timerFired: sufficient throughput rate (id = %" PRIu64 ")", m_download.downloadID().toUInt64());
+        RELEASE_LOG_IF_ALLOWED("timerFired: sufficient throughput rate (id = %" PRIu64 ")", m_download.downloadID().downloadID());
         m_timer.startOneShot(timeUntilNextInterval(m_interval++) / testSpeedMultiplier());
     } else
-        RELEASE_LOG_IF_ALLOWED("timerFired: Download reached threshold to not be terminated (id = %" PRIu64 ")", m_download.downloadID().toUInt64());
+        RELEASE_LOG_IF_ALLOWED("timerFired: Download reached threshold to not be terminated (id = %" PRIu64 ")", m_download.downloadID().downloadID());
 }
 
 } // namespace WebKit
diff --git a/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp b/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp
index 23e194e..59123f2 100644
--- a/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp
+++ b/Source/WebKit/NetworkProcess/Downloads/PendingDownload.cpp
@@ -110,7 +110,7 @@
 
 uint64_t PendingDownload::messageSenderDestinationID() const
 {
-    return m_networkLoad->pendingDownloadID().toUInt64();
+    return m_networkLoad->pendingDownloadID().downloadID();
 }
     
 }
diff --git a/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h b/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h
index ee8774f..f4b014e 100644
--- a/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h
+++ b/Source/WebKit/NetworkProcess/Downloads/PendingDownload.h
@@ -25,7 +25,6 @@
 
 #pragma once
 
-#include "DownloadID.h"
 #include "MessageSender.h"
 #include "NetworkLoadClient.h"
 #include "SandboxExtension.h"
@@ -42,6 +41,7 @@
 namespace WebKit {
 
 class Download;
+class DownloadID;
 class NetworkLoad;
 class NetworkLoadParameters;
 class NetworkSession;
diff --git a/Source/WebKit/NetworkProcess/NetworkDataTask.h b/Source/WebKit/NetworkProcess/NetworkDataTask.h
index e6276d1..94f9820 100644
--- a/Source/WebKit/NetworkProcess/NetworkDataTask.h
+++ b/Source/WebKit/NetworkProcess/NetworkDataTask.h
@@ -108,8 +108,8 @@
     PendingDownload* pendingDownload() const { return m_pendingDownload; }
     void setPendingDownloadID(DownloadID downloadID)
     {
-        ASSERT(!m_pendingDownloadID);
-        ASSERT(downloadID);
+        ASSERT(!m_pendingDownloadID.downloadID());
+        ASSERT(downloadID.downloadID());
         m_pendingDownloadID = downloadID;
     }
     void setPendingDownload(PendingDownload& pendingDownload)
@@ -120,7 +120,7 @@
 
     virtual void setPendingDownloadLocation(const String& filename, SandboxExtension::Handle&&, bool /*allowOverwrite*/) { m_pendingDownloadLocation = filename; }
     const String& pendingDownloadLocation() const { return m_pendingDownloadLocation; }
-    bool isDownload() const { return !!m_pendingDownloadID; }
+    bool isDownload() const { return !!m_pendingDownloadID.downloadID(); }
 
     const WebCore::ResourceRequest& firstRequest() const { return m_firstRequest; }
     virtual String suggestedFilename() const { return String(); }
diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp
index a08074e..5f23cc6 100644
--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp
+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp
@@ -1967,12 +1967,12 @@
 
 void NetworkProcess::pendingDownloadCanceled(DownloadID downloadID)
 {
-    downloadProxyConnection()->send(Messages::DownloadProxy::DidCancel({ }), downloadID);
+    downloadProxyConnection()->send(Messages::DownloadProxy::DidCancel({ }), downloadID.downloadID());
 }
 
 void NetworkProcess::findPendingDownloadLocation(NetworkDataTask& networkDataTask, ResponseCompletionHandler&& completionHandler, const ResourceResponse& response)
 {
-    auto destinationID = networkDataTask.pendingDownloadID();
+    uint64_t destinationID = networkDataTask.pendingDownloadID().downloadID();
     downloadProxyConnection()->send(Messages::DownloadProxy::DidReceiveResponse(response), destinationID);
 
     downloadManager().willDecidePendingDownloadDestination(networkDataTask, WTFMove(completionHandler));
diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h
index d533935..7c48b18 100644
--- a/Source/WebKit/NetworkProcess/NetworkProcess.h
+++ b/Source/WebKit/NetworkProcess/NetworkProcess.h
@@ -27,7 +27,6 @@
 
 #include "AuxiliaryProcess.h"
 #include "CacheModel.h"
-#include "DownloadID.h"
 #include "DownloadManager.h"
 #include "LocalStorageDatabaseTracker.h"
 #include "NetworkContentRuleListManager.h"
@@ -76,6 +75,7 @@
 namespace WebCore {
 class CertificateInfo;
 class CurlProxySettings;
+class DownloadID;
 class ProtectionSpace;
 class StorageQuotaManager;
 class NetworkStorageSession;
diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
index cecac71..8613087 100644
--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
@@ -356,7 +356,7 @@
 
 void NetworkResourceLoader::convertToDownload(DownloadID downloadID, const ResourceRequest& request, const ResourceResponse& response)
 {
-    RELEASE_LOG(Loading, "Converting NetworkResourceLoader %p to download %" PRIu64 " (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", this, downloadID.toUInt64(), m_parameters.webPageID.toUInt64(), m_parameters.webFrameID.toUInt64(), m_parameters.identifier);
+    RELEASE_LOG(Loading, "Converting NetworkResourceLoader %p to download %" PRIu64 " (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", this, downloadID.downloadID(), m_parameters.webPageID.toUInt64(), m_parameters.webFrameID.toUInt64(), m_parameters.identifier);
     
     // This can happen if the resource came from the disk cache.
     if (!m_networkLoad) {
diff --git a/Source/WebKit/NetworkProcess/WebSocketTask.h b/Source/WebKit/NetworkProcess/WebSocketTask.h
index 0bd1588..0479920 100644
--- a/Source/WebKit/NetworkProcess/WebSocketTask.h
+++ b/Source/WebKit/NetworkProcess/WebSocketTask.h
@@ -31,10 +31,6 @@
 #include "WebSocketTaskSoup.h"
 #else
 
-namespace IPC {
-class DataReference;
-}
-
 namespace WebKit {
 
 class WebSocketTask {
diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
index 9040af3..05cf516 100644
--- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
@@ -687,7 +687,7 @@
         if (!_sessionWrapper)
             return;
         auto downloadID = _sessionWrapper->downloadMap.take(task.taskIdentifier);
-        if (!downloadID)
+        if (!downloadID.downloadID())
             return;
         if (!_session)
             return;
@@ -850,7 +850,7 @@
     if (!_sessionWrapper)
         return;
     auto downloadID = _sessionWrapper->downloadMap.take([downloadTask taskIdentifier]);
-    if (!downloadID)
+    if (!downloadID.downloadID())
         return;
     if (!_session)
         return;
@@ -867,7 +867,7 @@
     if (!_sessionWrapper)
         return;
     auto downloadID = _sessionWrapper->downloadMap.get([downloadTask taskIdentifier]);
-    if (!downloadID)
+    if (!downloadID.downloadID())
         return;
     if (!_session)
         return;
@@ -1305,7 +1305,7 @@
         }
 #endif
         auto downloadID = sessionWrapper.downloadMap.get(taskIdentifier);
-        if (downloadID) {
+        if (downloadID.downloadID()) {
             if (auto* download = networkProcess().downloadManager().download(downloadID)) {
                 WebCore::AuthenticationChallenge authenticationChallenge { challenge };
                 // Received an authentication challenge for a download being resumed.
diff --git a/Source/WebKit/Scripts/webkit/messages.py b/Source/WebKit/Scripts/webkit/messages.py
index 637d49b..21de685 100644
--- a/Source/WebKit/Scripts/webkit/messages.py
+++ b/Source/WebKit/Scripts/webkit/messages.py
@@ -217,7 +217,6 @@
         'WebCore::ServiceWorkerRegistrationIdentifier',
         'WebCore::SWServerConnectionIdentifier',
         'WebKit::ActivityStateChangeID',
-        'WebKit::DownloadID',
         'WebKit::LayerHostingContextID',
         'WebKit::TransactionID',
         'WebKit::StorageAreaIdentifier',
diff --git a/Source/WebKit/Shared/Authentication/AuthenticationManager.h b/Source/WebKit/Shared/Authentication/AuthenticationManager.h
index c4474dfe..07438bd 100644
--- a/Source/WebKit/Shared/Authentication/AuthenticationManager.h
+++ b/Source/WebKit/Shared/Authentication/AuthenticationManager.h
@@ -25,7 +25,6 @@
 
 #pragma once
 
-#include "DownloadID.h"
 #include "MessageReceiver.h"
 #include "NetworkProcessSupplement.h"
 #include "WebPageProxyIdentifier.h"
@@ -54,6 +53,8 @@
 
 namespace WebKit {
 
+class Download;
+class DownloadID;
 class NetworkProcess;
 class WebFrame;
 
diff --git a/Source/WebKit/UIProcess/API/C/WKDownload.cpp b/Source/WebKit/UIProcess/API/C/WKDownload.cpp
index 0ebab3e..48d8b82 100644
--- a/Source/WebKit/UIProcess/API/C/WKDownload.cpp
+++ b/Source/WebKit/UIProcess/API/C/WKDownload.cpp
@@ -40,9 +40,9 @@
     return toAPI(DownloadProxy::APIType);
 }
 
-uint64_t WKDownloadGetID(WKDownloadRef)
+uint64_t WKDownloadGetID(WKDownloadRef download)
 {
-    return 0;
+    return toImpl(download)->downloadID().downloadID();
 }
 
 WKURLRequestRef WKDownloadCopyRequest(WKDownloadRef download)
diff --git a/Source/WebKit/UIProcess/API/C/WKDownload.h b/Source/WebKit/UIProcess/API/C/WKDownload.h
index 43f7202..004e46c 100644
--- a/Source/WebKit/UIProcess/API/C/WKDownload.h
+++ b/Source/WebKit/UIProcess/API/C/WKDownload.h
@@ -27,7 +27,6 @@
 #define WKDownload_h
 
 #include <WebKit/WKBase.h>
-#include <WebKit/WKDeprecated.h>
 
 #ifndef __cplusplus
 #include <stdbool.h>
@@ -39,7 +38,7 @@
 
 WK_EXPORT WKTypeID WKDownloadGetTypeID();
 
-WK_EXPORT uint64_t WKDownloadGetID(WKDownloadRef download) WK_C_API_DEPRECATED;
+WK_EXPORT uint64_t WKDownloadGetID(WKDownloadRef download);
 WK_EXPORT WKURLRequestRef WKDownloadCopyRequest(WKDownloadRef download);
 WK_EXPORT WKDataRef WKDownloadGetResumeData(WKDownloadRef download);
 WK_EXPORT void WKDownloadCancel(WKDownloadRef download);
diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
index b4d7049..663ea52 100644
--- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
+++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
@@ -44,6 +44,12 @@
 
 namespace WebKit {
 using namespace WebCore;
+
+static uint64_t generateDownloadID()
+{
+    static uint64_t uniqueDownloadID = 0;
+    return ++uniqueDownloadID;
+}
     
 Ref<DownloadProxy> DownloadProxy::create(DownloadProxyMap& downloadProxyMap, WebsiteDataStore& dataStore, WebProcessPool& processPool, const ResourceRequest& resourceRequest)
 {
@@ -54,7 +60,7 @@
     : m_downloadProxyMap(downloadProxyMap)
     , m_dataStore(&dataStore)
     , m_processPool(&processPool)
-    , m_downloadID(DownloadID::generate())
+    , m_downloadID(generateDownloadID())
     , m_request(resourceRequest)
 {
 }
diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxy.h b/Source/WebKit/UIProcess/Downloads/DownloadProxy.h
index 5301842..cd0b00e 100644
--- a/Source/WebKit/UIProcess/Downloads/DownloadProxy.h
+++ b/Source/WebKit/UIProcess/Downloads/DownloadProxy.h
@@ -48,6 +48,7 @@
 
 namespace WebKit {
 
+class DownloadID;
 class DownloadProxyMap;
 class WebPageProxy;
 class WebProcessPool;
diff --git a/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp b/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp
index 4107be3..492d550 100644
--- a/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp
+++ b/Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp
@@ -85,7 +85,7 @@
     auto downloadProxy = DownloadProxy::create(*this, dataStore, processPool, resourceRequest);
     m_downloads.set(downloadProxy->downloadID(), downloadProxy.copyRef());
 
-    RELEASE_LOG(Loading, "Adding download %" PRIu64 " to UIProcess DownloadProxyMap", downloadProxy->downloadID().toUInt64());
+    RELEASE_LOG(Loading, "Adding download %" PRIu64 " to UIProcess DownloadProxyMap", downloadProxy->downloadID().downloadID());
 
     if (m_downloads.size() == 1 && m_shouldTakeAssertion) {
         ASSERT(!m_downloadUIAssertion);
@@ -98,7 +98,7 @@
         RELEASE_LOG(ProcessSuspension, "UIProcess took 'WebKit downloads' assertions for UIProcess and NetworkProcess");
     }
 
-    m_process->addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID().toUInt64(), downloadProxy.get());
+    m_process->addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID().downloadID(), downloadProxy.get());
 
     return downloadProxy;
 }
@@ -107,14 +107,14 @@
 {
     auto downloadID = downloadProxy.downloadID();
 
-    RELEASE_LOG(Loading, "Removing download %" PRIu64 " from UIProcess DownloadProxyMap", downloadID.toUInt64());
+    RELEASE_LOG(Loading, "Removing download %" PRIu64 " from UIProcess DownloadProxyMap", downloadID.downloadID());
 
     // The DownloadProxy may be holding the last reference to the process pool.
     auto protectedProcessPool = makeRefPtr(m_process->processPool());
 
     ASSERT(m_downloads.contains(downloadID));
 
-    m_process->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadID.toUInt64());
+    m_process->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadID.downloadID());
     downloadProxy.invalidate();
     m_downloads.remove(downloadID);
 
@@ -133,7 +133,7 @@
     for (const auto& download : m_downloads.values()) {
         download->processDidClose();
         download->invalidate();
-        m_process->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), download->downloadID().toUInt64());
+        m_process->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), download->downloadID().downloadID());
     }
 
     m_downloads.clear();
diff --git a/Source/WebKit/WebProcess/WebPage/WebFrame.cpp b/Source/WebKit/WebProcess/WebPage/WebFrame.cpp
index d9e281c..9fbb1fd 100644
--- a/Source/WebKit/WebProcess/WebPage/WebFrame.cpp
+++ b/Source/WebKit/WebProcess/WebPage/WebFrame.cpp
@@ -279,7 +279,7 @@
 
 void WebFrame::startDownload(const WebCore::ResourceRequest& request, const String& suggestedName)
 {
-    ASSERT(m_policyDownloadID);
+    ASSERT(m_policyDownloadID.downloadID());
 
     auto policyDownloadID = m_policyDownloadID;
     m_policyDownloadID = { };
@@ -289,7 +289,7 @@
 
 void WebFrame::convertMainResourceLoadToDownload(DocumentLoader* documentLoader, const ResourceRequest& request, const ResourceResponse& response)
 {
-    ASSERT(m_policyDownloadID);
+    ASSERT(m_policyDownloadID.downloadID());
 
     auto policyDownloadID = m_policyDownloadID;
     m_policyDownloadID = { };
diff --git a/Source/WebKit/WebProcess/WebPage/WebFrame.h b/Source/WebKit/WebProcess/WebPage/WebFrame.h
index 4157ed5..b329ac5 100644
--- a/Source/WebKit/WebProcess/WebPage/WebFrame.h
+++ b/Source/WebKit/WebProcess/WebPage/WebFrame.h
@@ -181,7 +181,7 @@
     WebCore::FramePolicyFunction m_policyFunction;
     ForNavigationAction m_policyFunctionForNavigationAction { ForNavigationAction::No };
     HashMap<uint64_t, CompletionHandler<void()>> m_willSubmitFormCompletionHandlers;
-    DownloadID m_policyDownloadID;
+    DownloadID m_policyDownloadID { 0 };
 
     std::unique_ptr<WebFrameLoaderClient> m_frameLoaderClient;
     LoadListener* m_loadListener { nullptr };
diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h
index b100cca..44c7f48 100644
--- a/Source/WebKit/WebProcess/WebPage/WebPage.h
+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h
@@ -33,7 +33,6 @@
 #include "APIInjectedBundlePageUIClient.h"
 #include "APIObject.h"
 #include "CallbackID.h"
-#include "DownloadID.h"
 #include "DrawingAreaInfo.h"
 #include "EditingRange.h"
 #include "FocusedElementInformation.h"
@@ -210,6 +209,7 @@
 
 class DataReference;
 class DrawingArea;
+class DownloadID;
 class FindController;
 class GamepadData;
 class GeolocationPermissionRequestManager;