Title: [273923] trunk/Source/WebKit
Revision
273923
Author
cdu...@apple.com
Date
2021-03-04 15:14:54 -0800 (Thu, 04 Mar 2021)

Log Message

Clean up API::ResourceLoadStatisticsThirdParty / API::ResourceLoadStatisticsFirstParty
https://bugs.webkit.org/show_bug.cgi?id=222701

Reviewed by Geoffrey Garen.

Clean up API::ResourceLoadStatisticsThirdParty / API::ResourceLoadStatisticsFirstParty:
1. Make constructors private since there is a create() factory function.
2. Mark constructor as explicit since they take a single parameter.
3. Update ResourceLoadStatisticsFirstParty constructor to take parameter as a const
   reference instead of passing it by value.
4. Add assertions to make sure those are constructed and destroyed on the main thread.

* UIProcess/API/APIResourceLoadStatisticsFirstParty.h:
* UIProcess/API/APIResourceLoadStatisticsThirdParty.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (273922 => 273923)


--- trunk/Source/WebKit/ChangeLog	2021-03-04 23:06:39 UTC (rev 273922)
+++ trunk/Source/WebKit/ChangeLog	2021-03-04 23:14:54 UTC (rev 273923)
@@ -1,3 +1,20 @@
+2021-03-04  Chris Dumez  <cdu...@apple.com>
+
+        Clean up API::ResourceLoadStatisticsThirdParty / API::ResourceLoadStatisticsFirstParty
+        https://bugs.webkit.org/show_bug.cgi?id=222701
+
+        Reviewed by Geoffrey Garen.
+
+        Clean up API::ResourceLoadStatisticsThirdParty / API::ResourceLoadStatisticsFirstParty:
+        1. Make constructors private since there is a create() factory function.
+        2. Mark constructor as explicit since they take a single parameter.
+        3. Update ResourceLoadStatisticsFirstParty constructor to take parameter as a const
+           reference instead of passing it by value.
+        4. Add assertions to make sure those are constructed and destroyed on the main thread.
+
+        * UIProcess/API/APIResourceLoadStatisticsFirstParty.h:
+        * UIProcess/API/APIResourceLoadStatisticsThirdParty.h:
+
 2021-03-04  Alex Christensen  <achristen...@webkit.org>
 
         Remove the HTTPSUpgradeEnabled experimental feature

Modified: trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsFirstParty.h (273922 => 273923)


--- trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsFirstParty.h	2021-03-04 23:06:39 UTC (rev 273922)
+++ trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsFirstParty.h	2021-03-04 23:14:54 UTC (rev 273923)
@@ -33,14 +33,15 @@
 
 class ResourceLoadStatisticsFirstParty final : public ObjectImpl<Object::Type::ResourceLoadStatisticsFirstParty> {
 public:
-    static Ref<ResourceLoadStatisticsFirstParty> create(const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty firstPartyData)
+    static Ref<ResourceLoadStatisticsFirstParty> create(const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty& firstPartyData)
     {
+        RELEASE_ASSERT(RunLoop::isMain());
         return adoptRef(*new ResourceLoadStatisticsFirstParty(firstPartyData));
     }
 
-    ResourceLoadStatisticsFirstParty(const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty firstPartyData)
-        : m_firstPartyData(firstPartyData)
+    ~ResourceLoadStatisticsFirstParty()
     {
+        RELEASE_ASSERT(RunLoop::isMain());
     }
 
     const WTF::String& firstPartyDomain() const { return m_firstPartyData.firstPartyDomain.string(); }
@@ -48,8 +49,12 @@
     double timeLastUpdated() const { return m_firstPartyData.timeLastUpdated.value(); }
 
 private:
+    explicit ResourceLoadStatisticsFirstParty(const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty& firstPartyData)
+        : m_firstPartyData(firstPartyData)
+    {
+    }
+
     const WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty m_firstPartyData;
-
 };
 
 } // namespace API

Modified: trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsThirdParty.h (273922 => 273923)


--- trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsThirdParty.h	2021-03-04 23:06:39 UTC (rev 273922)
+++ trunk/Source/WebKit/UIProcess/API/APIResourceLoadStatisticsThirdParty.h	2021-03-04 23:14:54 UTC (rev 273923)
@@ -35,12 +35,13 @@
 public:
     static Ref<ResourceLoadStatisticsThirdParty> create(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData&& thirdPartyData)
     {
+        RELEASE_ASSERT(RunLoop::isMain());
         return adoptRef(*new ResourceLoadStatisticsThirdParty(WTFMove(thirdPartyData)));
     }
 
-    ResourceLoadStatisticsThirdParty(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData&& thirdPartyData)
-        : m_thirdPartyData(WTFMove(thirdPartyData))
+    ~ResourceLoadStatisticsThirdParty()
     {
+        RELEASE_ASSERT(RunLoop::isMain());
     }
 
     const WTF::String& thirdPartyDomain() const { return m_thirdPartyData.thirdPartyDomain.string(); }
@@ -47,6 +48,11 @@
     const Vector<WebKit::WebResourceLoadStatisticsStore::ThirdPartyDataForSpecificFirstParty>& underFirstParties() const { return m_thirdPartyData.underFirstParties; }
 
 private:
+    explicit ResourceLoadStatisticsThirdParty(WebKit::WebResourceLoadStatisticsStore::ThirdPartyData&& thirdPartyData)
+        : m_thirdPartyData(WTFMove(thirdPartyData))
+    {
+    }
+
     const WebKit::WebResourceLoadStatisticsStore::ThirdPartyData m_thirdPartyData;
 };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to