Web Inspector: Network: replace CFNetwork SPI with new API where able
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jun 2019 00:13:59 +0000 (00:13 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jun 2019 00:13:59 +0000 (00:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198762

Reviewed by Timothy Hatcher.

Source/WebCore:

* platform/network/NetworkLoadMetrics.h:

Source/WebCore/PAL:

* pal/spi/cf/CFNetworkSPI.h:

Source/WebKit:

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

Source/WTF:

* wtf/Platform.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246616 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/spi/cf/CFNetworkSPI.h
Source/WebCore/platform/network/NetworkLoadMetrics.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

index 816967d..17a1288 100644 (file)
@@ -1,3 +1,12 @@
+2019-06-19  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Network: replace CFNetwork SPI with new API where able
+        https://bugs.webkit.org/show_bug.cgi?id=198762
+
+        Reviewed by Timothy Hatcher.
+
+        * wtf/Platform.h:
+
 2019-06-19  Alex Christensen  <achristensen@webkit.org>
 
         Add a unit test for client certificate authentication
index f6e99d8..5d236e0 100644 (file)
 #define HAVE_CFNETWORK_NSURLSESSION_STRICTRUSTEVALUATE 1
 #endif
 
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+#define HAVE_CFNETWORK_NSURLSESSIONTASKTRANSACTIONMETRICS_SPI 1
+#endif
+
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
 #define HAVE_CFNETWORK_NEGOTIATED_SSL_PROTOCOL_CIPHER 1
+#define HAVE_CFNETWORK_NSURLSESSIONTASKTRANSACTIONMETRICS_ADDITIONS 1
 #endif
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
index 37e2317..b7435ef 100644 (file)
@@ -1,3 +1,12 @@
+2019-06-19  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Network: replace CFNetwork SPI with new API where able
+        https://bugs.webkit.org/show_bug.cgi?id=198762
+
+        Reviewed by Timothy Hatcher.
+
+        * platform/network/NetworkLoadMetrics.h:
+
 2019-06-19  Jer Noble  <jer.noble@apple.com>
 
         iOS 12.2 Drawing portrait video to canvas is sideways
index db5091a..a289d0d 100644 (file)
@@ -1,3 +1,12 @@
+2019-06-19  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Network: replace CFNetwork SPI with new API where able
+        https://bugs.webkit.org/show_bug.cgi?id=198762
+
+        Reviewed by Timothy Hatcher.
+
+        * pal/spi/cf/CFNetworkSPI.h:
+
 2019-06-18  Dean Jackson  <dino@apple.com>
 
         UIContextMenuInteraction implementation for WKContentView
index 4557085..0857d45 100644 (file)
@@ -214,7 +214,7 @@ typedef NS_ENUM(NSInteger, NSURLSessionCompanionProxyPreference) {
 #endif
 @end
 
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+#if HAVE(CFNETWORK_NSURLSESSIONTASKTRANSACTIONMETRICS_SPI)
 @interface NSURLSessionTaskTransactionMetrics ()
 @property (copy, readonly) NSString* _remoteAddressAndPort;
 @property (copy, readonly) NSUUID* _connectionIdentifier;
index 156f223..03c18b6 100644 (file)
@@ -176,8 +176,8 @@ public:
 
     HTTPHeaderMap requestHeaders;
 
-    uint32_t requestHeaderBytesSent;
-    uint32_t responseHeaderBytesReceived;
+    uint64_t requestHeaderBytesSent;
+    uint64_t responseHeaderBytesReceived;
     uint64_t requestBodyBytesSent;
     uint64_t responseBodyBytesReceived;
     uint64_t responseBodyDecodedSize;
index e49c117..2b7e6df 100644 (file)
@@ -1,3 +1,13 @@
+2019-06-19  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Network: replace CFNetwork SPI with new API where able
+        https://bugs.webkit.org/show_bug.cgi?id=198762
+
+        Reviewed by Timothy Hatcher.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:task:didFinishCollectingMetrics:]):
+
 2019-06-19  Alex Christensen  <achristensen@webkit.org>
 
         DownloadMonitor::measuredThroughputRate should approach zero with no throughput
index bdbf9b4..0aa6045 100644 (file)
@@ -682,7 +682,7 @@ static inline void processServerTrustEvaluation(NetworkSessionCocoa *session, NS
         if (networkDataTask->shouldCaptureExtraNetworkLoadMetrics()) {
             networkLoadMetrics.priority = toNetworkLoadPriority(task.priority);
 
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+#if HAVE(CFNETWORK_NSURLSESSIONTASKTRANSACTIONMETRICS_SPI)
             networkLoadMetrics.remoteAddress = String(m._remoteAddressAndPort);
             networkLoadMetrics.connectionIdentifier = String([m._connectionIdentifier UUIDString]);
 #endif
@@ -698,7 +698,21 @@ static inline void processServerTrustEvaluation(NetworkSessionCocoa *session, NS
             }];
             networkLoadMetrics.requestHeaders = WTFMove(requestHeaders);
 
-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000)
+#if HAVE(CFNETWORK_NSURLSESSIONTASKTRANSACTIONMETRICS_ADDITIONS)
+            networkLoadMetrics.requestHeaderBytesSent = 0;
+            networkLoadMetrics.requestBodyBytesSent = 0;
+            networkLoadMetrics.responseHeaderBytesReceived = 0;
+            networkLoadMetrics.responseBodyBytesReceived = 0;
+            networkLoadMetrics.responseBodyDecodedSize = 0;
+
+            for (NSURLSessionTaskTransactionMetrics *transactionMetrics in metrics.transactionMetrics) {
+                networkLoadMetrics.requestHeaderBytesSent += transactionMetrics.countOfRequestHeaderBytesSent;
+                networkLoadMetrics.requestBodyBytesSent += transactionMetrics.countOfRequestBodyBytesSent;
+                networkLoadMetrics.responseHeaderBytesReceived += transactionMetrics.countOfResponseHeaderBytesReceived;
+                networkLoadMetrics.responseBodyBytesReceived += transactionMetrics.countOfResponseBodyBytesReceived;
+                networkLoadMetrics.responseBodyDecodedSize += transactionMetrics.countOfResponseBodyBytesAfterDecoding;
+            }
+#elif HAVE(CFNETWORK_NSURLSESSIONTASKTRANSACTIONMETRICS_SPI)
             uint64_t requestHeaderBytesSent = 0;
             uint64_t responseHeaderBytesReceived = 0;
             uint64_t responseBodyBytesReceived = 0;