Title: [278649] trunk/Source
Revision
278649
Author
[email protected]
Date
2021-06-08 22:08:25 -0700 (Tue, 08 Jun 2021)

Log Message

Move PrivacyStance code from WebKitAdditions
https://bugs.webkit.org/show_bug.cgi?id=226774

Patch by Alex Christensen <[email protected]> on 2021-06-08
Reviewed by Jer Noble.

Source/WebCore:

* platform/network/NetworkLoadMetrics.h:
(WebCore::NetworkLoadMetrics::isolatedCopy const):
(WebCore::NetworkLoadMetrics::operator== const):
(WebCore::NetworkLoadMetrics::encode const):
(WebCore::NetworkLoadMetrics::decode):
* platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSessionTaskTransactionMetrics _privacyStance]):

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:

Source/WebKit:

* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toPrivacyStance):
(-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):

Source/WTF:

* wtf/PlatformHave.h:

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (278648 => 278649)


--- trunk/Source/WTF/ChangeLog	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WTF/ChangeLog	2021-06-09 05:08:25 UTC (rev 278649)
@@ -1,3 +1,12 @@
+2021-06-08  Alex Christensen  <[email protected]>
+
+        Move PrivacyStance code from WebKitAdditions
+        https://bugs.webkit.org/show_bug.cgi?id=226774
+
+        Reviewed by Jer Noble.
+
+        * wtf/PlatformHave.h:
+
 2021-06-08  Ben Nham  <[email protected]>
 
         Use access instead of stat in some filesystem functions

Modified: trunk/Source/WTF/wtf/PlatformHave.h (278648 => 278649)


--- trunk/Source/WTF/wtf/PlatformHave.h	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2021-06-09 05:08:25 UTC (rev 278649)
@@ -332,6 +332,13 @@
 #define HAVE_IOSURFACE_SET_OWNERSHIP_IDENTITY 1
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000) \
+    || ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150000) \
+    || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 80000) \
+    || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 150000)
+#define HAVE_NETWORK_CONNECTION_PRIVACY_STANCE 1
+#endif
+
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 110300) \
     || (((PLATFORM(IOS) && !PLATFORM(IOS_FAMILY_SIMULATOR)) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140500) \
     || (PLATFORM(WATCHOS) && !PLATFORM(IOS_FAMILY_SIMULATOR) && __WATCH_OS_VERSION_MAX_ALLOWED >= 70500) \

Modified: trunk/Source/WebCore/ChangeLog (278648 => 278649)


--- trunk/Source/WebCore/ChangeLog	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WebCore/ChangeLog	2021-06-09 05:08:25 UTC (rev 278649)
@@ -1,3 +1,18 @@
+2021-06-08  Alex Christensen  <[email protected]>
+
+        Move PrivacyStance code from WebKitAdditions
+        https://bugs.webkit.org/show_bug.cgi?id=226774
+
+        Reviewed by Jer Noble.
+
+        * platform/network/NetworkLoadMetrics.h:
+        (WebCore::NetworkLoadMetrics::isolatedCopy const):
+        (WebCore::NetworkLoadMetrics::operator== const):
+        (WebCore::NetworkLoadMetrics::encode const):
+        (WebCore::NetworkLoadMetrics::decode):
+        * platform/network/cocoa/WebCoreNSURLSession.mm:
+        (-[WebCoreNSURLSessionTaskTransactionMetrics _privacyStance]):
+
 2021-06-08  Rob Buis  <[email protected]>
 
         CSSOM test for serializing counter() fails

Modified: trunk/Source/WebCore/PAL/ChangeLog (278648 => 278649)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-06-09 05:08:25 UTC (rev 278649)
@@ -1,3 +1,12 @@
+2021-06-08  Alex Christensen  <[email protected]>
+
+        Move PrivacyStance code from WebKitAdditions
+        https://bugs.webkit.org/show_bug.cgi?id=226774
+
+        Reviewed by Jer Noble.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+
 2021-06-08  Devin Rousso  <[email protected]>
 
         [Payment Request] upstream new features

Modified: trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h (278648 => 278649)


--- trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h	2021-06-09 05:08:25 UTC (rev 278649)
@@ -286,6 +286,9 @@
 @property (assign, readonly) NSInteger _responseHeaderBytesReceived;
 @property (assign, readonly) int64_t _responseBodyBytesReceived;
 @property (assign, readonly) int64_t _responseBodyBytesDecoded;
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+@property (assign, readonly) nw_connection_privacy_stance_t _privacyStance;
+#endif
 @end
 
 #if HAVE(CFNETWORK_NEGOTIATED_SSL_PROTOCOL_CIPHER)

Modified: trunk/Source/WebCore/platform/network/NetworkLoadMetrics.h (278648 => 278649)


--- trunk/Source/WebCore/platform/network/NetworkLoadMetrics.h	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WebCore/platform/network/NetworkLoadMetrics.h	2021-06-09 05:08:25 UTC (rev 278649)
@@ -32,18 +32,6 @@
 #include <wtf/persistence/PersistentCoder.h>
 #include <wtf/text/WTFString.h>
 
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/NetworkLoadMetricsAdditions.h>
-#else
-#define NETWORK_LOAD_METRICS_ADDITIONS_1
-#define NETWORK_LOAD_METRICS_ADDITIONS_2
-#define NETWORK_LOAD_METRICS_ADDITIONS_3
-#define NETWORK_LOAD_METRICS_ADDITIONS_4
-#define NETWORK_LOAD_METRICS_ADDITIONS_5
-#define NETWORK_LOAD_METRICS_ADDITIONS_6
-#define NETWORK_LOAD_METRICS_ADDITIONS_7
-#endif
-
 #if PLATFORM(COCOA)
 OBJC_CLASS NSURLConnection;
 OBJC_CLASS NSURLResponse;
@@ -61,7 +49,13 @@
     Unknown,
 };
 
-NETWORK_LOAD_METRICS_ADDITIONS_1;
+enum class PrivacyStance : uint8_t {
+    Unknown,
+    NotEligible,
+    Proxied,
+    Failed,
+    Direct,
+};
 
 constexpr MonotonicTime reusedTLSConnectionSentinel { MonotonicTime::fromRawSeconds(-1) };
 
@@ -135,7 +129,7 @@
         copy.tlsProtocol = tlsProtocol.isolatedCopy();
         copy.tlsCipher = tlsCipher.isolatedCopy();
         copy.priority = priority;
-        NETWORK_LOAD_METRICS_ADDITIONS_2;
+        copy.privacyStance = privacyStance;
         copy.requestHeaders = requestHeaders.isolatedCopy();
 
         copy.requestHeaderBytesSent = requestHeaderBytesSent;
@@ -173,7 +167,7 @@
             && tlsProtocol == other.tlsProtocol
             && tlsCipher == other.tlsCipher
             && priority == other.priority
-            NETWORK_LOAD_METRICS_ADDITIONS_3
+            && privacyStance == other.privacyStance
             && requestHeaders == other.requestHeaders
             && requestHeaderBytesSent == other.requestHeaderBytesSent
             && requestBodyBytesSent == other.requestBodyBytesSent
@@ -197,7 +191,7 @@
     String tlsCipher;
 
     NetworkLoadPriority priority { NetworkLoadPriority::Unknown };
-    NETWORK_LOAD_METRICS_ADDITIONS_4;
+    PrivacyStance privacyStance { PrivacyStance::Unknown };
 
     HTTPHeaderMap requestHeaders;
 
@@ -242,7 +236,7 @@
     encoder << tlsProtocol;
     encoder << tlsCipher;
     encoder << priority;
-    NETWORK_LOAD_METRICS_ADDITIONS_5;
+    encoder << privacyStance;
     encoder << requestHeaders;
     encoder << requestHeaderBytesSent;
     encoder << requestBodyBytesSent;
@@ -280,7 +274,7 @@
         && decoder.decode(metrics.tlsProtocol)
         && decoder.decode(metrics.tlsCipher)
         && decoder.decode(metrics.priority)
-        NETWORK_LOAD_METRICS_ADDITIONS_6
+        && decoder.decode(metrics.privacyStance)
         && decoder.decode(metrics.requestHeaders)
         && decoder.decode(metrics.requestHeaderBytesSent)
         && decoder.decode(metrics.requestBodyBytesSent)
@@ -291,4 +285,17 @@
 
 } // namespace WebCore
 
-NETWORK_LOAD_METRICS_ADDITIONS_7
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::PrivacyStance> {
+    using values = EnumValues<
+        WebCore::PrivacyStance,
+        WebCore::PrivacyStance::Unknown,
+        WebCore::PrivacyStance::NotEligible,
+        WebCore::PrivacyStance::Proxied,
+        WebCore::PrivacyStance::Failed,
+        WebCore::PrivacyStance::Direct
+    >;
+};
+
+}

Modified: trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm (278648 => 278649)


--- trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm	2021-06-09 05:08:25 UTC (rev 278649)
@@ -37,13 +37,6 @@
 #import <wtf/WeakObjCPtr.h>
 #import <wtf/cocoa/VectorCocoa.h>
 
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/WebCoreNSURLSessionAdditions.h>
-#else
-#define WEBCORE_SESSION_ADDITIONS_1
-#define WEBCORE_SESSION_ADDITIONS_2
-#endif
-
 using namespace WebCore;
 
 #pragma mark - Private declarations
@@ -77,7 +70,9 @@
 @property (readonly, getter=isExpensive) BOOL expensive;
 @property (readonly, getter=isConstrained) BOOL constrained;
 @property (readonly, getter=isMultipath) BOOL multipath;
-WEBCORE_SESSION_ADDITIONS_1;
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+@property (assign, readonly) nw_connection_privacy_stance_t _privacyStance;
+#endif
 @end
 
 @implementation WebCoreNSURLSessionTaskTransactionMetrics {
@@ -160,7 +155,29 @@
     return _metrics.isReusedConnection;
 }
 
-WEBCORE_SESSION_ADDITIONS_2
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+@dynamic _privacyStance;
+- (nw_connection_privacy_stance_t)_privacyStance
+{
+    auto toConnectionPrivacyStance = [] (WebCore::PrivacyStance privacyStance) {
+        switch (privacyStance) {
+        case WebCore::PrivacyStance::Unknown:
+            return nw_connection_privacy_stance_unknown;
+        case WebCore::PrivacyStance::NotEligible:
+            return nw_connection_privacy_stance_not_eligible;
+        case WebCore::PrivacyStance::Proxied:
+            return nw_connection_privacy_stance_proxied;
+        case WebCore::PrivacyStance::Failed:
+            return nw_connection_privacy_stance_failed;
+        case WebCore::PrivacyStance::Direct:
+            return nw_connection_privacy_stance_direct;
+        }
+        ASSERT_NOT_REACHED();
+        return nw_connection_privacy_stance_unknown;
+    };
+    return toConnectionPrivacyStance(_metrics.privacyStance);
+}
+#endif
 
 @dynamic cellular;
 - (BOOL)cellular

Modified: trunk/Source/WebKit/ChangeLog (278648 => 278649)


--- trunk/Source/WebKit/ChangeLog	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WebKit/ChangeLog	2021-06-09 05:08:25 UTC (rev 278649)
@@ -1,3 +1,14 @@
+2021-06-08  Alex Christensen  <[email protected]>
+
+        Move PrivacyStance code from WebKitAdditions
+        https://bugs.webkit.org/show_bug.cgi?id=226774
+
+        Reviewed by Jer Noble.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (toPrivacyStance):
+        (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):
+
 2021-06-08  Sam Weinig  <[email protected]>
 
         Adopt WTF::Span in SQLiteStatement

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (278648 => 278649)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-06-09 05:07:27 UTC (rev 278648)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-06-09 05:08:25 UTC (rev 278649)
@@ -65,8 +65,6 @@
 #import <WebKitAdditions/NetworkSessionCocoaAdditions.h>
 #else
 #define NETWORK_SESSION_COCOA_ADDITIONS_1
-#define NETWORK_SESSION_COCOA_ADDITIONS_2
-#define NETWORK_SESSION_COCOA_ADDITIONS_3
 void WebKit::NetworkSessionCocoa::removeNetworkWebsiteData(std::optional<WallTime>, std::optional<HashSet<WebCore::RegistrableDomain>>&&, CompletionHandler<void()>&& completionHandler) { completionHandler(); }
 #endif
 
@@ -123,7 +121,25 @@
     return WebCore::NetworkLoadPriority::Medium;
 }
 
-NETWORK_SESSION_COCOA_ADDITIONS_2
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+static WebCore::PrivacyStance toPrivacyStance(nw_connection_privacy_stance_t stance)
+{
+    switch (stance) {
+    case nw_connection_privacy_stance_unknown:
+        return WebCore::PrivacyStance::Unknown;
+    case nw_connection_privacy_stance_not_eligible:
+        return WebCore::PrivacyStance::NotEligible;
+    case nw_connection_privacy_stance_proxied:
+        return WebCore::PrivacyStance::Proxied;
+    case nw_connection_privacy_stance_failed:
+        return WebCore::PrivacyStance::Failed;
+    case nw_connection_privacy_stance_direct:
+        return WebCore::PrivacyStance::Direct;
+    }
+    ASSERT_NOT_REACHED();
+    return WebCore::PrivacyStance::Unknown;
+}
+#endif
 
 #if HAVE(CFNETWORK_NEGOTIATED_SSL_PROTOCOL_CIPHER)
 #if HAVE(CFNETWORK_METRICS_APIS_V4)
@@ -809,7 +825,9 @@
 #endif
         networkLoadMetrics.isReusedConnection = m.isReusedConnection;
 
-        NETWORK_SESSION_COCOA_ADDITIONS_3
+#if HAVE(NETWORK_CONNECTION_PRIVACY_STANCE)
+        networkLoadMetrics.privacyStance = toPrivacyStance(m._privacyStance);
+#endif
 
         if (networkDataTask->shouldCaptureExtraNetworkLoadMetrics()) {
             networkLoadMetrics.priority = toNetworkLoadPriority(task.priority);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to