Diff
Modified: trunk/Source/WebKit/ChangeLog (271286 => 271287)
--- trunk/Source/WebKit/ChangeLog 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/ChangeLog 2021-01-08 07:34:45 UTC (rev 271287)
@@ -1,3 +1,42 @@
+2021-01-07 Alex Christensen <[email protected]>
+
+ Use WeakHashSet instead of HashSet<T*>
+ https://bugs.webkit.org/show_bug.cgi?id=220455
+
+ Reviewed by Geoffrey Garen.
+
+ * NetworkProcess/NetworkSession.cpp:
+ (WebKit::NetworkSession::invalidateAndCancel):
+ (WebKit::NetworkSession::registerNetworkDataTask):
+ (WebKit::NetworkSession::unregisterNetworkDataTask):
+ * NetworkProcess/NetworkSession.h:
+ (WebKit::NetworkSession::registerNetworkDataTask): Deleted.
+ (WebKit::NetworkSession::unregisterNetworkDataTask): Deleted.
+ * UIProcess/WebPageGroup.cpp:
+ (WebKit::WebPageGroup::addPage):
+ (WebKit::WebPageGroup::removePage):
+ (WebKit::WebPageGroup::setPreferences):
+ * UIProcess/WebPageGroup.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::m_limitsNavigationsToAppBoundDomains):
+ (WebKit::WebPageProxy::~WebPageProxy):
+ * UIProcess/WebPreferences.cpp:
+ (WebKit::WebPreferences::~WebPreferences):
+ (WebKit::WebPreferences::addPage):
+ (WebKit::WebPreferences::removePage):
+ (WebKit::WebPreferences::update):
+ (WebKit::WebPreferences::updateBoolValueForInternalDebugFeatureKey):
+ * UIProcess/WebPreferences.h:
+ * WebProcess/Geolocation/WebGeolocationManager.cpp:
+ (WebKit::WebGeolocationManager::registerWebPage):
+ (WebKit::WebGeolocationManager::unregisterWebPage):
+ (WebKit::WebGeolocationManager::setEnableHighAccuracyForPage):
+ (WebKit::WebGeolocationManager::isUpdating const):
+ (WebKit::WebGeolocationManager::isHighAccuracyEnabled const):
+ * WebProcess/Geolocation/WebGeolocationManager.h:
+ (WebKit::WebGeolocationManager::isUpdating const): Deleted.
+ (WebKit::WebGeolocationManager::isHighAccuracyEnabled const): Deleted.
+
2021-01-07 Per Arne Vollan <[email protected]>
[iOS] Silence diagnostics sandbox violations
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (271286 => 271287)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp 2021-01-08 07:34:45 UTC (rev 271287)
@@ -151,8 +151,8 @@
void NetworkSession::invalidateAndCancel()
{
- for (auto* task : m_dataTaskSet)
- task->invalidateAndCancel();
+ for (auto& task : m_dataTaskSet)
+ task.invalidateAndCancel();
#if ENABLE(RESOURCE_LOAD_STATISTICS)
if (m_resourceLoadStatistics)
m_resourceLoadStatistics->invalidateAndCancel();
@@ -372,4 +372,14 @@
return nullptr;
}
+void NetworkSession::registerNetworkDataTask(NetworkDataTask& task)
+{
+ m_dataTaskSet.add(task);
+}
+
+void NetworkSession::unregisterNetworkDataTask(NetworkDataTask& task)
+{
+ m_dataTaskSet.remove(task);
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (271286 => 271287)
--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h 2021-01-08 07:34:45 UTC (rev 271287)
@@ -83,8 +83,8 @@
NetworkProcess& networkProcess() { return m_networkProcess; }
WebCore::NetworkStorageSession* networkStorageSession() const;
- void registerNetworkDataTask(NetworkDataTask& task) { m_dataTaskSet.add(&task); }
- void unregisterNetworkDataTask(NetworkDataTask& task) { m_dataTaskSet.remove(&task); }
+ void registerNetworkDataTask(NetworkDataTask&);
+ void unregisterNetworkDataTask(NetworkDataTask&);
#if ENABLE(RESOURCE_LOAD_STATISTICS)
WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
@@ -159,7 +159,7 @@
PAL::SessionID m_sessionID;
Ref<NetworkProcess> m_networkProcess;
- HashSet<NetworkDataTask*> m_dataTaskSet;
+ WeakHashSet<NetworkDataTask> m_dataTaskSet;
#if ENABLE(RESOURCE_LOAD_STATISTICS)
String m_resourceLoadStatisticsDirectory;
RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
Modified: trunk/Source/WebKit/UIProcess/WebPageGroup.cpp (271286 => 271287)
--- trunk/Source/WebKit/UIProcess/WebPageGroup.cpp 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/UIProcess/WebPageGroup.cpp 2021-01-08 07:34:45 UTC (rev 271287)
@@ -93,12 +93,12 @@
webPageGroupMap().remove(pageGroupID());
}
-void WebPageGroup::addPage(WebPageProxy* page)
+void WebPageGroup::addPage(WebPageProxy& page)
{
m_pages.add(page);
}
-void WebPageGroup::removePage(WebPageProxy* page)
+void WebPageGroup::removePage(WebPageProxy& page)
{
m_pages.remove(page);
}
@@ -111,7 +111,7 @@
m_preferences = preferences;
for (auto& webPageProxy : m_pages)
- webPageProxy->setPreferences(*m_preferences);
+ webPageProxy.setPreferences(*m_preferences);
}
WebPreferences& WebPageGroup::preferences() const
Modified: trunk/Source/WebKit/UIProcess/WebPageGroup.h (271286 => 271287)
--- trunk/Source/WebKit/UIProcess/WebPageGroup.h 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/UIProcess/WebPageGroup.h 2021-01-08 07:34:45 UTC (rev 271287)
@@ -31,6 +31,7 @@
#include <WebCore/UserStyleSheetTypes.h>
#include <wtf/Forward.h>
#include <wtf/HashSet.h>
+#include <wtf/WeakHashSet.h>
#include <wtf/text/WTFString.h>
namespace WebKit {
@@ -48,8 +49,8 @@
virtual ~WebPageGroup();
- void addPage(WebPageProxy*);
- void removePage(WebPageProxy*);
+ void addPage(WebPageProxy&);
+ void removePage(WebPageProxy&);
uint64_t pageGroupID() const { return m_data.pageGroupID; }
@@ -64,7 +65,7 @@
WebPageGroupData m_data;
RefPtr<WebPreferences> m_preferences;
Ref<WebUserContentControllerProxy> m_userContentController;
- HashSet<WebPageProxy*> m_pages;
+ WeakHashSet<WebPageProxy> m_pages;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (271286 => 271287)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-01-08 07:34:45 UTC (rev 271287)
@@ -548,7 +548,7 @@
WebProcessPool::statistics().wkPageCount++;
m_preferences->addPage(*this);
- m_pageGroup->addPage(this);
+ m_pageGroup->addPage(*this);
m_inspector = WebInspectorProxy::create(*this);
@@ -604,7 +604,7 @@
TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag.value());
m_preferences->removePage(*this);
- m_pageGroup->removePage(this);
+ m_pageGroup->removePage(*this);
#ifndef NDEBUG
webPageProxyCounter.decrement();
Modified: trunk/Source/WebKit/UIProcess/WebPreferences.cpp (271286 => 271287)
--- trunk/Source/WebKit/UIProcess/WebPreferences.cpp 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/UIProcess/WebPreferences.cpp 2021-01-08 07:34:45 UTC (rev 271287)
@@ -76,7 +76,7 @@
WebPreferences::~WebPreferences()
{
- ASSERT(m_pages.isEmpty());
+ ASSERT(m_pages.computesEmpty());
}
Ref<WebPreferences> WebPreferences::copy() const
@@ -86,14 +86,14 @@
void WebPreferences::addPage(WebPageProxy& webPageProxy)
{
- ASSERT(!m_pages.contains(&webPageProxy));
- m_pages.add(&webPageProxy);
+ ASSERT(!m_pages.contains(webPageProxy));
+ m_pages.add(webPageProxy);
}
void WebPreferences::removePage(WebPageProxy& webPageProxy)
{
- ASSERT(m_pages.contains(&webPageProxy));
- m_pages.remove(&webPageProxy);
+ ASSERT(m_pages.contains(webPageProxy));
+ m_pages.remove(webPageProxy);
}
void WebPreferences::update()
@@ -104,7 +104,7 @@
}
for (auto& webPageProxy : m_pages)
- webPageProxy->preferencesDidChange();
+ webPageProxy.preferencesDidChange();
}
void WebPreferences::startBatchingUpdates()
@@ -166,8 +166,8 @@
void WebPreferences::updateBoolValueForInternalDebugFeatureKey(const String& key, bool value)
{
if (key == WebPreferencesKey::processSwapOnCrossSiteNavigationEnabledKey()) {
- for (auto* page : m_pages)
- page->process().processPool().configuration().setProcessSwapsOnNavigation(value);
+ for (auto& page : m_pages)
+ page.process().processPool().configuration().setProcessSwapsOnNavigation(value);
return;
}
Modified: trunk/Source/WebKit/UIProcess/WebPreferences.h (271286 => 271287)
--- trunk/Source/WebKit/UIProcess/WebPreferences.h 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/UIProcess/WebPreferences.h 2021-01-08 07:34:45 UTC (rev 271287)
@@ -32,6 +32,7 @@
#include "WebPreferencesStore.h"
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
+#include <wtf/WeakHashSet.h>
#define DECLARE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue, HumanReadableName, HumanReadableDescription) \
void set##KeyUpper(const Type& value); \
@@ -138,7 +139,7 @@
const String m_globalDebugKeyPrefix;
WebPreferencesStore m_store;
- HashSet<WebPageProxy*> m_pages;
+ WeakHashSet<WebPageProxy> m_pages;
unsigned m_updateBatchCount { 0 };
bool m_needUpdateAfterBatch { false };
};
Modified: trunk/Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp (271286 => 271287)
--- trunk/Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.cpp 2021-01-08 07:34:45 UTC (rev 271287)
@@ -54,7 +54,7 @@
{
bool wasUpdating = isUpdating();
- m_pageSet.add(&page);
+ m_pageSet.add(page);
if (!wasUpdating)
m_process.parentProcessConnection()->send(Messages::WebGeolocationManagerProxy::StartUpdating(page.webPageProxyIdentifier(), authorizationToken), 0);
@@ -64,8 +64,8 @@
{
bool highAccuracyWasEnabled = isHighAccuracyEnabled();
- m_pageSet.remove(&page);
- m_highAccuracyPageSet.remove(&page);
+ m_pageSet.remove(page);
+ m_highAccuracyPageSet.remove(page);
if (!isUpdating())
m_process.parentProcessConnection()->send(Messages::WebGeolocationManagerProxy::StopUpdating(), 0);
@@ -81,9 +81,9 @@
bool highAccuracyWasEnabled = isHighAccuracyEnabled();
if (enabled)
- m_highAccuracyPageSet.add(&page);
+ m_highAccuracyPageSet.add(page);
else
- m_highAccuracyPageSet.remove(&page);
+ m_highAccuracyPageSet.remove(page);
bool highAccuracyShouldBeEnabled = isHighAccuracyEnabled();
if (highAccuracyWasEnabled != highAccuracyShouldBeEnabled)
@@ -124,4 +124,14 @@
}
#endif // PLATFORM(IOS_FAMILY)
+bool WebGeolocationManager::isUpdating() const
+{
+ return !m_pageSet.computesEmpty();
+}
+
+bool WebGeolocationManager::isHighAccuracyEnabled() const
+{
+ return !m_highAccuracyPageSet.computesEmpty();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.h (271286 => 271287)
--- trunk/Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.h 2021-01-08 07:12:09 UTC (rev 271286)
+++ trunk/Source/WebKit/WebProcess/Geolocation/WebGeolocationManager.h 2021-01-08 07:34:45 UTC (rev 271287)
@@ -32,6 +32,7 @@
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
+#include <wtf/WeakHashSet.h>
namespace WebCore {
class Geolocation;
@@ -61,8 +62,8 @@
// IPC::MessageReceiver
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
- bool isUpdating() const { return !m_pageSet.isEmpty(); }
- bool isHighAccuracyEnabled() const { return !m_highAccuracyPageSet.isEmpty(); }
+ bool isUpdating() const;
+ bool isHighAccuracyEnabled() const;
void didChangePosition(const WebCore::GeolocationPositionData&);
void didFailToDeterminePosition(const String& errorMessage);
@@ -71,8 +72,8 @@
#endif // PLATFORM(IOS_FAMILY)
WebProcess& m_process;
- HashSet<WebPage*> m_pageSet;
- HashSet<WebPage*> m_highAccuracyPageSet;
+ WeakHashSet<WebPage> m_pageSet;
+ WeakHashSet<WebPage> m_highAccuracyPageSet;
};
} // namespace WebKit