Skip to content

Commit

Permalink
Cherry-pick 262240@main (9f57750). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=254500.

    Remove smart pointer violation in NetworkContentRuleListManager, LegacyCustomProtocolManager.
    https://bugs.webkit.org/show_bug.cgi?id=254500.
    rdar://107255403.

    Reviewed by Chris Dumez.

    m_process is using raw references, this changes uses WTF:: Ref.

    * Source/WebKit/NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.cpp:
    (WebKit::LegacyCustomProtocolManager::LegacyCustomProtocolManager):
    (WebKit::LegacyCustomProtocolManager::startLoading):
    (WebKit::LegacyCustomProtocolManager::stopLoading):
    * Source/WebKit/NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.h:
    * Source/WebKit/NetworkProcess/NetworkContentRuleListManager.cpp:
    (WebKit::NetworkContentRuleListManager::contentExtensionsBackend):
    * Source/WebKit/NetworkProcess/NetworkContentRuleListManager.h:

    Canonical link: https://commits.webkit.org/262240@main
  • Loading branch information
arunsundarapple authored and aperezdc committed Apr 27, 2023
1 parent 6cbd974 commit cabee89
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
Expand Up @@ -44,7 +44,7 @@ const char* LegacyCustomProtocolManager::supplementName()
LegacyCustomProtocolManager::LegacyCustomProtocolManager(NetworkProcess& networkProcess)
: m_networkProcess(networkProcess)
{
m_networkProcess.addMessageReceiver(Messages::LegacyCustomProtocolManager::messageReceiverName(), *this);
m_networkProcess->addMessageReceiver(Messages::LegacyCustomProtocolManager::messageReceiverName(), *this);
}

void LegacyCustomProtocolManager::initialize(const NetworkProcessCreationParameters& parameters)
Expand All @@ -71,12 +71,12 @@ void LegacyCustomProtocolManager::removeCustomProtocol(LegacyCustomProtocolID cu

void LegacyCustomProtocolManager::startLoading(LegacyCustomProtocolID customProtocolID, const WebCore::ResourceRequest& request)
{
m_networkProcess.send(Messages::LegacyCustomProtocolManagerProxy::StartLoading(customProtocolID, request));
m_networkProcess->send(Messages::LegacyCustomProtocolManagerProxy::StartLoading(customProtocolID, request));
}

void LegacyCustomProtocolManager::stopLoading(LegacyCustomProtocolID customProtocolID)
{
m_networkProcess.send(Messages::LegacyCustomProtocolManagerProxy::StopLoading(customProtocolID), 0);
m_networkProcess->send(Messages::LegacyCustomProtocolManagerProxy::StopLoading(customProtocolID), 0);
}

} // namespace WebKit
Expand Up @@ -29,6 +29,7 @@
#include "LegacyCustomProtocolID.h"
#include "MessageReceiver.h"
#include "NetworkProcessSupplement.h"
#include <wtf/CheckedRef.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Lock.h>
Expand Down Expand Up @@ -94,7 +95,7 @@ class LegacyCustomProtocolManager : public NetworkProcessSupplement, public IPC:

void registerProtocolClass();

NetworkProcess& m_networkProcess;
CheckedRef<NetworkProcess> m_networkProcess;

typedef HashMap<LegacyCustomProtocolID, CustomProtocol> CustomProtocolMap;
CustomProtocolMap m_customProtocolMap WTF_GUARDED_BY_LOCK(m_customProtocolMapLock);
Expand Down
Expand Up @@ -63,7 +63,7 @@ void NetworkContentRuleListManager::contentExtensionsBackend(UserContentControll
m_pendingCallbacks.ensure(identifier, [] {
return Vector<BackendCallback> { };
}).iterator->value.append(WTFMove(callback));
m_networkProcess.parentProcessConnection()->send(Messages::NetworkProcessProxy::ContentExtensionRules { identifier }, 0);
m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::ContentExtensionRules { identifier }, 0);
}

void NetworkContentRuleListManager::addContentRuleLists(UserContentControllerIdentifier identifier, Vector<std::pair<WebCompiledContentRuleListData, URL>>&& contentRuleLists)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/NetworkProcess/NetworkContentRuleListManager.h
Expand Up @@ -30,6 +30,7 @@
#include "UserContentControllerIdentifier.h"
#include "WebCompiledContentRuleListData.h"
#include <WebCore/ContentExtensionsBackend.h>
#include <wtf/CheckedRef.h>

namespace IPC {
class Connection;
Expand Down Expand Up @@ -58,7 +59,7 @@ class NetworkContentRuleListManager {

HashMap<UserContentControllerIdentifier, std::unique_ptr<WebCore::ContentExtensions::ContentExtensionsBackend>> m_contentExtensionBackends;
HashMap<UserContentControllerIdentifier, Vector<BackendCallback>> m_pendingCallbacks;
NetworkProcess& m_networkProcess;
CheckedRef<NetworkProcess> m_networkProcess;
};

} // namespace WebKit
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/NetworkProcess/NetworkProcess.h
Expand Up @@ -53,6 +53,7 @@
#include <WebCore/ServiceWorkerIdentifier.h>
#include <WebCore/ServiceWorkerTypes.h>
#include <memory>
#include <wtf/CheckedRef.h>
#include <wtf/CrossThreadTask.h>
#include <wtf/Function.h>
#include <wtf/HashSet.h>
Expand Down Expand Up @@ -125,7 +126,7 @@ class Cache;
enum class CacheOption : uint8_t;
}

class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client, public ThreadSafeRefCounted<NetworkProcess>
class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client, public ThreadSafeRefCounted<NetworkProcess>, public CanMakeCheckedPtr
{
WTF_MAKE_NONCOPYABLE(NetworkProcess);
public:
Expand Down

0 comments on commit cabee89

Please sign in to comment.