Skip to content

Commit

Permalink
Store fewer raw pointers in containers in Source/WebKit
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261933

Reviewed by Brent Fulgham.

* Source/JavaScriptCore/inspector/InspectorTarget.h:
* Source/WebCore/Modules/geolocation/Geolocation.h:
* Source/WebCore/bindings/js/DOMWrapperWorld.h:
* Source/WebCore/css/CSSStyleDeclaration.h:
* Source/WebCore/dom/Range.h:
* Source/WebCore/page/DOMWindowExtension.h:
* Source/WebCore/page/PageOverlay.h:
* Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.cpp:
(WebKit::allWorkers):
(): Deleted.
* Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.h:
* Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServer.h:
* Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.h:
* Source/WebKit/Platform/IPC/Connection.cpp:
(IPC::Connection::connectionMap):
* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Shared/WebBackForwardListItem.cpp:
(WebKit::WebBackForwardListItem::allItems):
(): Deleted.
* Source/WebKit/Shared/WebBackForwardListItem.h:
* Source/WebKit/UIProcess/API/APIContentWorld.cpp:
(API::sharedWorldNameMap):
(API::sharedWorldIdentifierMap):
(API::ContentWorld::sharedWorldWithName):
(API::ContentWorld::~ContentWorld):
(): Deleted.
* Source/WebKit/UIProcess/API/APIContentWorld.h:
* Source/WebKit/UIProcess/API/Cocoa/WKBrowsingContextController.mm:
* Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::webUserContentControllerProxies):
(): Deleted.
* Source/WebKit/UIProcess/UserContent/WebUserContentControllerProxy.h:
* Source/WebKit/UIProcess/ViewGestureController.cpp:
(WebKit::viewGestureControllersForAllPages):
(WebKit::ViewGestureController::controllerForGesture):
* Source/WebKit/UIProcess/ViewGestureController.h:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::allFrames):
(): Deleted.
* Source/WebKit/UIProcess/WebPageGroup.cpp:
(WebKit::WebPageGroup::forEach):
* Source/WebKit/UIProcess/WebPageGroup.h:
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::allDataStores):
(WebKit::WebsiteDataStore::forEachWebsiteDataStore):
(WebKit::WebsiteDataStore::existingDataStoreForIdentifier):
(WebKit::WebsiteDataStore::dataStoreForIdentifier):
(WebKit::networkProcessForSession):
(WebKit::WebsiteDataStore::parametersFromEachWebsiteDataStore):
(WebKit::WebsiteDataStore::forwardAppBoundDomainsToITPIfInitialized):
(WebKit::WebsiteDataStore::forwardManagedDomainsToITPIfInitialized):
* Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h:
* Source/WebKit/WebProcess/Databases/WebDatabaseProvider.cpp:
(WebKit::databaseProviders):
(): Deleted.
* Source/WebKit/WebProcess/Databases/WebDatabaseProvider.h:
* Source/WebKit/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp:
(WebKit::GeolocationPermissionRequestManager::didReceiveGeolocationPermissionDecision):
* Source/WebKit/WebProcess/Geolocation/GeolocationPermissionRequestManager.h:
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.cpp:
(WebKit::InjectedBundleCSSStyleDeclarationHandle::getOrCreate):
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleCSSStyleDeclarationHandle.h:
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::getOrCreate):
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.cpp:
(WebKit::InjectedBundleRangeHandle::getOrCreate):
* Source/WebKit/WebProcess/InjectedBundle/DOM/InjectedBundleRangeHandle.h:
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.cpp:
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundleDOMWindowExtension.h:
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.cpp:
(WebKit::InjectedBundleScriptWorld::getOrCreate):
(WebKit::InjectedBundleScriptWorld::find):
* Source/WebKit/WebProcess/InjectedBundle/InjectedBundleScriptWorld.h:
* Source/WebKit/WebProcess/Inspector/WebPageInspectorTargetController.cpp:
(WebKit::WebPageInspectorTargetController::connectInspector):
(WebKit::WebPageInspectorTargetController::disconnectInspector):
(WebKit::WebPageInspectorTargetController::sendMessageToTargetBackend):
* Source/WebKit/WebProcess/Inspector/WebPageInspectorTargetController.h:
* Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::remove):
* Source/WebKit/WebProcess/Network/WebLoaderStrategy.h:
* Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocket.h:
* Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
(WebKit::LibWebRTCSocketFactory::forSocketInGroup):
* Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::urlSchemeTaskWillPerformRedirection):
(WebKit::WebPage::urlSchemeTaskDidPerformRedirection):
(WebKit::WebPage::urlSchemeTaskDidReceiveResponse):
(WebKit::WebPage::urlSchemeTaskDidReceiveData):
(WebKit::WebPage::urlSchemeTaskDidComplete):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPageOverlay.cpp:
(WebKit::overlayMap):
(): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPageOverlay.h:
* Source/WebKit/WebProcess/WebPage/WebURLSchemeHandlerProxy.h:
* Source/WebKit/WebProcess/WebPage/WebURLSchemeTaskProxy.h:

Canonical link: https://commits.webkit.org/268346@main
  • Loading branch information
cdumez committed Sep 23, 2023
1 parent ba06d5c commit 0a038d9
Show file tree
Hide file tree
Showing 53 changed files with 157 additions and 110 deletions.
3 changes: 2 additions & 1 deletion Source/JavaScriptCore/inspector/InspectorTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma once

#include "InspectorFrontendChannel.h"
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>

namespace Inspector {
Expand All @@ -38,7 +39,7 @@ enum class InspectorTargetType : uint8_t {
ServiceWorker,
};

class JS_EXPORT_PRIVATE InspectorTarget {
class JS_EXPORT_PRIVATE InspectorTarget : public CanMakeWeakPtr<InspectorTarget> {
public:
virtual ~InspectorTarget() = default;

Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/Modules/geolocation/Geolocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "PositionOptions.h"
#include "ScriptWrappable.h"
#include "Timer.h"
#include <wtf/CheckedRef.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>

Expand All @@ -51,7 +52,7 @@ class ScriptExecutionContext;
class SecurityOrigin;
struct PositionOptions;

class Geolocation final : public ScriptWrappable, public RefCounted<Geolocation>, public ActiveDOMObject {
class Geolocation final : public ScriptWrappable, public RefCounted<Geolocation>, public ActiveDOMObject, public CanMakeCheckedPtr {
WTF_MAKE_ISO_ALLOCATED_EXPORT(Geolocation, WEBCORE_EXPORT);
friend class GeoNotifier;
public:
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/bindings/js/DOMWrapperWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#pragma once

#include "JSDOMGlobalObject.h"
#include <wtf/CheckedRef.h>
#include <wtf/Forward.h>

namespace WebCore {
Expand All @@ -30,7 +31,7 @@ class WindowProxy;

typedef HashMap<void*, JSC::Weak<JSC::JSObject>> DOMObjectWrapperMap;

class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
class DOMWrapperWorld : public RefCounted<DOMWrapperWorld>, public CanMakeCheckedPtr {
public:
enum class Type {
Normal, // Main (e.g. Page)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/css/CSSStyleDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "CSSPropertyNames.h"
#include "ExceptionOr.h"
#include "ScriptWrappable.h"
#include <wtf/CheckedRef.h>

namespace WebCore {

Expand All @@ -35,7 +36,7 @@ class MutableStyleProperties;
class StyleProperties;
class StyledElement;

class CSSStyleDeclaration : public ScriptWrappable {
class CSSStyleDeclaration : public ScriptWrappable, public CanMakeCheckedPtr {
WTF_MAKE_NONCOPYABLE(CSSStyleDeclaration);
WTF_MAKE_ISO_ALLOCATED(CSSStyleDeclaration);
public:
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/dom/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "AbstractRange.h"
#include "RangeBoundaryPoint.h"
#include <wtf/CheckedRef.h>
#include <wtf/WeakPtr.h>

namespace WebCore {
Expand All @@ -39,7 +40,7 @@ class Text;

struct SimpleRange;

class Range final : public AbstractRange, public CanMakeWeakPtr<Range> {
class Range final : public AbstractRange, public CanMakeWeakPtr<Range>, public CanMakeCheckedPtr {
WTF_MAKE_ISO_ALLOCATED(Range);
public:
WEBCORE_EXPORT static Ref<Range> create(Document&);
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/page/DOMWindowExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma once

#include "LocalDOMWindow.h"
#include <wtf/CheckedRef.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/WeakPtr.h>
Expand All @@ -35,7 +36,7 @@ namespace WebCore {
class DOMWrapperWorld;
class LocalFrame;

class DOMWindowExtension final : public RefCounted<DOMWindowExtension>, public LocalDOMWindow::Observer {
class DOMWindowExtension final : public RefCounted<DOMWindowExtension>, public LocalDOMWindow::Observer, public CanMakeCheckedPtr {
public:
static Ref<DOMWindowExtension> create(LocalDOMWindow* window, DOMWrapperWorld& world)
{
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/page/PageOverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "FloatPoint.h"
#include "IntRect.h"
#include "Timer.h"
#include <wtf/CheckedRef.h>
#include <wtf/RefCounted.h>
#include <wtf/WallTime.h>
#include <wtf/text/WTFString.h>
Expand All @@ -42,7 +43,7 @@ class Page;
class PageOverlayController;
class PlatformMouseEvent;

class PageOverlay final : public RefCounted<PageOverlay> {
class PageOverlay final : public RefCounted<PageOverlay>, public CanMakeCheckedPtr {
WTF_MAKE_NONCOPYABLE(PageOverlay);
WTF_MAKE_FAST_ALLOCATED;
public:
Expand Down
5 changes: 3 additions & 2 deletions Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@

#include "WebSharedWorkerServer.h"
#include "WebSharedWorkerServerToContextConnection.h"
#include <wtf/CheckedPtr.h>
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/RunLoop.h>

namespace WebKit {

static HashMap<WebCore::SharedWorkerIdentifier, WebSharedWorker*>& allWorkers()
static HashMap<WebCore::SharedWorkerIdentifier, CheckedPtr<WebSharedWorker>>& allWorkers()
{
ASSERT(RunLoop::isMain());
static NeverDestroyed<HashMap<WebCore::SharedWorkerIdentifier, WebSharedWorker*>> allWorkers;
static NeverDestroyed<HashMap<WebCore::SharedWorkerIdentifier, CheckedPtr<WebSharedWorker>>> allWorkers;
return allWorkers;
}

Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <WebCore/WorkerFetchResult.h>
#include <WebCore/WorkerInitializationData.h>
#include <WebCore/WorkerOptions.h>
#include <wtf/CheckedRef.h>
#include <wtf/ListHashSet.h>
#include <wtf/WeakPtr.h>

Expand All @@ -44,7 +45,7 @@ namespace WebKit {
class WebSharedWorkerServer;
class WebSharedWorkerServerToContextConnection;

class WebSharedWorker : public CanMakeWeakPtr<WebSharedWorker> {
class WebSharedWorker : public CanMakeWeakPtr<WebSharedWorker>, public CanMakeCheckedPtr {
WTF_MAKE_FAST_ALLOCATED;
public:
WebSharedWorker(WebSharedWorkerServer&, const WebCore::SharedWorkerKey&, const WebCore::WorkerOptions&);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <WebCore/SharedWorkerKey.h>
#include <WebCore/SharedWorkerObjectIdentifier.h>
#include <WebCore/TransferredMessagePort.h>
#include <wtf/CheckedPtr.h>
#include <wtf/WeakPtr.h>

namespace PAL {
Expand Down Expand Up @@ -84,7 +85,7 @@ class WebSharedWorkerServer : public CanMakeWeakPtr<WebSharedWorkerServer> {

NetworkSession& m_session;
HashMap<WebCore::ProcessIdentifier, std::unique_ptr<WebSharedWorkerServerConnection>> m_connections;
HashMap<WebCore::RegistrableDomain, WebSharedWorkerServerToContextConnection*> m_contextConnections;
HashMap<WebCore::RegistrableDomain, CheckedPtr<WebSharedWorkerServerToContextConnection>> m_contextConnections;
HashSet<WebCore::RegistrableDomain> m_pendingContextConnectionDomains;
HashMap<WebCore::SharedWorkerKey, std::unique_ptr<WebSharedWorker>> m_sharedWorkers;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <WebCore/SharedWorkerObjectIdentifier.h>
#include <WebCore/Timer.h>
#include <WebCore/TransferredMessagePort.h>
#include <wtf/CheckedRef.h>

namespace WebCore {
class RegistrableDomain;
Expand All @@ -48,7 +49,7 @@ class NetworkConnectionToWebProcess;
class WebSharedWorker;
class WebSharedWorkerServer;

class WebSharedWorkerServerToContextConnection final : public IPC::MessageSender, public IPC::MessageReceiver {
class WebSharedWorkerServerToContextConnection final : public IPC::MessageSender, public IPC::MessageReceiver, public CanMakeCheckedPtr {
WTF_MAKE_FAST_ALLOCATED;
public:
WebSharedWorkerServerToContextConnection(NetworkConnectionToWebProcess&, const WebCore::RegistrableDomain&, WebSharedWorkerServer&);
Expand Down
6 changes: 3 additions & 3 deletions Source/WebKit/Platform/IPC/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ Ref<Connection> Connection::createClientConnection(Identifier identifier)
return adoptRef(*new Connection(identifier, false));
}

HashMap<IPC::Connection::UniqueID, Connection*>& Connection::connectionMap()
HashMap<IPC::Connection::UniqueID, ThreadSafeWeakPtr<Connection>>& Connection::connectionMap()
{
static NeverDestroyed<HashMap<IPC::Connection::UniqueID, Connection*>> map;
static NeverDestroyed<HashMap<IPC::Connection::UniqueID, ThreadSafeWeakPtr<Connection>>> map;
return map;
}

Expand Down Expand Up @@ -338,7 +338,7 @@ RefPtr<Connection> Connection::connection(UniqueID uniqueID)
{
// FIXME(https://bugs.webkit.org/show_bug.cgi?id=238493): Removing with lock in destructor is not thread-safe.
Locker locker { s_connectionMapLock };
return connectionMap().get(uniqueID);
return connectionMap().get(uniqueID).get();

}

Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/Platform/IPC/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ class Connection : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<Connec

bool isIncomingMessagesThrottlingEnabled() const { return m_incomingMessagesThrottlingLevel.has_value(); }

static HashMap<IPC::Connection::UniqueID, Connection*>& connectionMap() WTF_REQUIRES_LOCK(s_connectionMapLock);
static HashMap<IPC::Connection::UniqueID, ThreadSafeWeakPtr<Connection>>& connectionMap() WTF_REQUIRES_LOCK(s_connectionMapLock);

DecoderOrError waitForMessage(MessageName, uint64_t destinationID, Timeout, OptionSet<WaitForOption>);

Expand Down Expand Up @@ -693,7 +693,7 @@ template<typename T>
Error Connection::send(UniqueID connectionID, T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions, std::optional<Thread::QOS> qos)
{
Locker locker { s_connectionMapLock };
RefPtr connection = connectionMap().get(connectionID);
RefPtr connection = connectionMap().get(connectionID).get();
if (!connection)
return Error::NoConnectionForIdentifier;
return connection->send(std::forward<T>(message), destinationID, sendOptions, qos);
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/Shared/WebBackForwardListItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ WebBackForwardListItem::~WebBackForwardListItem()
removeFromBackForwardCache();
}

HashMap<BackForwardItemIdentifier, WebBackForwardListItem*>& WebBackForwardListItem::allItems()
HashMap<BackForwardItemIdentifier, CheckedPtr<WebBackForwardListItem>>& WebBackForwardListItem::allItems()
{
RELEASE_ASSERT(RunLoop::isMain());
static NeverDestroyed<HashMap<BackForwardItemIdentifier, WebBackForwardListItem*>> items;
static NeverDestroyed<HashMap<BackForwardItemIdentifier, CheckedPtr<WebBackForwardListItem>>> items;
return items;
}

Expand Down
5 changes: 3 additions & 2 deletions Source/WebKit/Shared/WebBackForwardListItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "APIObject.h"
#include "SessionState.h"
#include "WebPageProxyIdentifier.h"
#include <wtf/CheckedPtr.h>
#include <wtf/Ref.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
Expand All @@ -47,13 +48,13 @@ class SuspendedPageProxy;
class WebBackForwardCache;
class WebBackForwardCacheEntry;

class WebBackForwardListItem : public API::ObjectImpl<API::Object::Type::BackForwardListItem>, public CanMakeWeakPtr<WebBackForwardListItem> {
class WebBackForwardListItem : public API::ObjectImpl<API::Object::Type::BackForwardListItem>, public CanMakeWeakPtr<WebBackForwardListItem>, public CanMakeCheckedPtr {
public:
static Ref<WebBackForwardListItem> create(BackForwardListItemState&&, WebPageProxyIdentifier);
virtual ~WebBackForwardListItem();

static WebBackForwardListItem* itemForID(const WebCore::BackForwardItemIdentifier&);
static HashMap<WebCore::BackForwardItemIdentifier, WebBackForwardListItem*>& allItems();
static HashMap<WebCore::BackForwardItemIdentifier, CheckedPtr<WebBackForwardListItem>>& allItems();

const WebCore::BackForwardItemIdentifier& itemID() const { return m_itemState.identifier; }
const BackForwardListItemState& itemState() { return m_itemState; }
Expand Down
19 changes: 10 additions & 9 deletions Source/WebKit/UIProcess/API/APIContentWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,21 @@

#include "ContentWorldShared.h"
#include "WebUserContentControllerProxy.h"
#include <wtf/CheckedPtr.h>
#include <wtf/HashMap.h>
#include <wtf/text/StringHash.h>

namespace API {

static HashMap<WTF::String, ContentWorld*>& sharedWorldNameMap()
static HashMap<WTF::String, CheckedPtr<ContentWorld>>& sharedWorldNameMap()
{
static NeverDestroyed<HashMap<WTF::String, ContentWorld*>> sharedMap;
static NeverDestroyed<HashMap<WTF::String, CheckedPtr<ContentWorld>>> sharedMap;
return sharedMap;
}

static HashMap<WebKit::ContentWorldIdentifier, ContentWorld*>& sharedWorldIdentifierMap()
static HashMap<WebKit::ContentWorldIdentifier, CheckedPtr<ContentWorld>>& sharedWorldIdentifierMap()
{
static NeverDestroyed<HashMap<WebKit::ContentWorldIdentifier, ContentWorld*>> sharedMap;
static NeverDestroyed<HashMap<WebKit::ContentWorldIdentifier, CheckedPtr<ContentWorld>>> sharedMap;
return sharedMap;
}

Expand Down Expand Up @@ -77,7 +78,7 @@ Ref<ContentWorld> ContentWorld::sharedWorldWithName(const WTF::String& name)
auto result = sharedWorldNameMap().add(name, nullptr);
if (result.isNewEntry) {
result.iterator->value = new ContentWorld(name);
return adoptRef(*result.iterator->value);
return adoptRef(*result.iterator->value.get());
}

return *result.iterator->value;
Expand All @@ -100,15 +101,15 @@ ContentWorld::~ContentWorld()
ASSERT(m_identifier != WebKit::pageContentWorldIdentifier());

auto result = sharedWorldIdentifierMap().take(m_identifier);
ASSERT_UNUSED(result, result == this || m_identifier == WebKit::pageContentWorldIdentifier());
ASSERT_UNUSED(result, result.get() == this || m_identifier == WebKit::pageContentWorldIdentifier());

if (!name().isNull()) {
auto taken = sharedWorldNameMap().take(name());
ASSERT_UNUSED(taken, taken == this);
ASSERT_UNUSED(taken, taken.get() == this);
}

for (auto& proxy : m_associatedContentControllerProxies)
Ref { proxy }->contentWorldDestroyed(*this);
for (Ref proxy : m_associatedContentControllerProxies)
proxy->contentWorldDestroyed(*this);
}

void ContentWorld::addAssociatedUserContentControllerProxy(WebKit::WebUserContentControllerProxy& proxy)
Expand Down
3 changes: 2 additions & 1 deletion Source/WebKit/UIProcess/API/APIContentWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "APIObject.h"
#include "ContentWorldShared.h"
#include <wtf/CheckedRef.h>
#include <wtf/WeakHashSet.h>
#include <wtf/text/WTFString.h>

Expand All @@ -36,7 +37,7 @@ class WebUserContentControllerProxy;

namespace API {

class ContentWorld final : public API::ObjectImpl<API::Object::Type::ContentWorld> {
class ContentWorld final : public API::ObjectImpl<API::Object::Type::ContentWorld>, public CanMakeCheckedPtr {
public:
static ContentWorld* worldForIdentifier(WebKit::ContentWorldIdentifier);
static Ref<ContentWorld> sharedWorldWithName(const WTF::String&);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#import <WebCore/Pagination.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <wtf/BlockPtr.h>
#import <wtf/CheckedPtr.h>
#import <wtf/NeverDestroyed.h>
#import <wtf/WeakObjCPtr.h>
#import <wtf/cf/CFURLExtras.h>
Expand All @@ -86,9 +87,9 @@ @implementation WKBrowsingContextController {
}

ALLOW_DEPRECATED_DECLARATIONS_BEGIN
static HashMap<WebKit::WebPageProxy*, __unsafe_unretained WKBrowsingContextController *>& browsingContextControllerMap()
static HashMap<CheckedPtr<WebKit::WebPageProxy>, __unsafe_unretained WKBrowsingContextController *>& browsingContextControllerMap()
{
static NeverDestroyed<HashMap<WebKit::WebPageProxy*, __unsafe_unretained WKBrowsingContextController *>> browsingContextControllerMap;
static NeverDestroyed<HashMap<CheckedPtr<WebKit::WebPageProxy>, __unsafe_unretained WKBrowsingContextController *>> browsingContextControllerMap;
return browsingContextControllerMap;
}
ALLOW_DEPRECATED_DECLARATIONS_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "WebUserContentControllerMessages.h"
#include "WebUserContentControllerProxyMessages.h"
#include <WebCore/SerializedScriptValue.h>
#include <wtf/CheckedPtr.h>

#if ENABLE(CONTENT_EXTENSIONS)
#include "APIContentRuleList.h"
Expand All @@ -52,13 +53,12 @@ namespace WebKit {

using namespace WebCore;

static HashMap<UserContentControllerIdentifier, WebUserContentControllerProxy*>& webUserContentControllerProxies()
static HashMap<UserContentControllerIdentifier, CheckedPtr<WebUserContentControllerProxy>>& webUserContentControllerProxies()
{
static NeverDestroyed<HashMap<UserContentControllerIdentifier, WebUserContentControllerProxy*>> proxies;
static NeverDestroyed<HashMap<UserContentControllerIdentifier, CheckedPtr<WebUserContentControllerProxy>>> proxies;
return proxies;
}


WebUserContentControllerProxy* WebUserContentControllerProxy::get(UserContentControllerIdentifier identifier)
{
return webUserContentControllerProxies().get(identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "WebPageProxyIdentifier.h"
#include "WebUserContentControllerProxyMessages.h"
#include <WebCore/PageIdentifier.h>
#include <wtf/CheckedRef.h>
#include <wtf/Forward.h>
#include <wtf/HashCountedSet.h>
#include <wtf/HashMap.h>
Expand Down Expand Up @@ -66,7 +67,7 @@ struct WebPageCreationParameters;
struct UserContentControllerParameters;
enum class InjectUserScriptImmediately : bool;

class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, public IPC::MessageReceiver {
class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, public IPC::MessageReceiver, public CanMakeCheckedPtr {
public:
static Ref<WebUserContentControllerProxy> create()
{
Expand Down
Loading

0 comments on commit 0a038d9

Please sign in to comment.