Call setCollectsTimingData only once, and before making any {CF,NS}URLConnections
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Sep 2014 00:47:26 +0000 (00:47 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Sep 2014 00:47:26 +0000 (00:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136731
<rdar://problem/18252844>

Reviewed by Simon Fraser.

* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::ResourceHandle::start):
Move setCollectsTimingData to before createCFURLConnection, so the first connection
has timing data associated with it.

* platform/network/mac/ResourceHandleMac.mm:
(WebCore::ResourceHandle::createNSURLConnection):
Move setCollectsTimingData to before we create our NSURLConnection, so the first connection
has timing data associated with it.
Use setCollectsTimingData instead of the NSURLConnection SPI directly.

(WebCore::ResourceHandle::setCollectsTimingData):
Only call _setCollectsTimingData once.

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/mac/ResourceHandleMac.mm

index 83eb46f424435e5e67e38d32250a200547691a10..14009dce4352709337bd28996a0f7272df9b17e9 100644 (file)
@@ -1,3 +1,25 @@
+2014-09-10  Tim Horton  <timothy_horton@apple.com>
+
+        Call setCollectsTimingData only once, and before making any {CF,NS}URLConnections
+        https://bugs.webkit.org/show_bug.cgi?id=136731
+        <rdar://problem/18252844>
+
+        Reviewed by Simon Fraser.
+
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::ResourceHandle::start):
+        Move setCollectsTimingData to before createCFURLConnection, so the first connection
+        has timing data associated with it.
+
+        * platform/network/mac/ResourceHandleMac.mm:
+        (WebCore::ResourceHandle::createNSURLConnection):
+        Move setCollectsTimingData to before we create our NSURLConnection, so the first connection
+        has timing data associated with it.
+        Use setCollectsTimingData instead of the NSURLConnection SPI directly.
+
+        (WebCore::ResourceHandle::setCollectsTimingData):
+        Only call _setCollectsTimingData once.
+
 2014-09-10  Enrica Casucci  <enrica@apple.com>
 
         Remove iOS-only -webkit-composition-fill-color CSS property.
index 0bdaa410b84a641ebee756a1be4b483bedf1960d..6c6fd4a27e76f12e415bdf797dd4af918852a828 100644 (file)
@@ -249,6 +249,10 @@ bool ResourceHandle::start()
 
     bool shouldUseCredentialStorage = !client() || client()->shouldUseCredentialStorage(this);
 
+#if ENABLE(WEB_TIMING)
+    setCollectsTimingData();
+#endif
+
     createCFURLConnection(shouldUseCredentialStorage, d->m_shouldContentSniff, SchedulingBehavior::Asynchronous, client()->connectionProperties(this).get());
 
     d->m_connectionDelegate->setupConnectionScheduling(d->m_connection.get());
@@ -256,10 +260,6 @@ bool ResourceHandle::start()
 
     LOG(Network, "CFNet - Starting URL %s (handle=%p, conn=%p)", firstRequest().url().string().utf8().data(), this, d->m_connection.get());
     
-#if ENABLE(WEB_TIMING)
-    setCollectsTimingData();
-#endif
-    
     return true;
 }
 
index 545bb1e1dcda0e9c23053c77479c58ed3f0241bf..4184abc360665aaf922d0fd864de3afe617e493b 100644 (file)
@@ -144,6 +144,10 @@ void ResourceHandle::createNSURLConnection(id delegate, bool shouldUseCredential
 void ResourceHandle::createNSURLConnection(id delegate, bool shouldUseCredentialStorage, bool shouldContentSniff, SchedulingBehavior schedulingBehavior, NSDictionary *connectionProperties)
 #endif
 {
+#if ENABLE(WEB_TIMING)
+    setCollectsTimingData();
+#endif
+
     // Credentials for ftp can only be passed in URL, the connection:didReceiveAuthenticationChallenge: delegate call won't be made.
     if ((!d->m_user.isEmpty() || !d->m_pass.isEmpty()) && !firstRequest().url().protocolIsInHTTPFamily()) {
         URL urlWithCredentials(firstRequest().url());
@@ -221,9 +225,6 @@ void ResourceHandle::createNSURLConnection(id delegate, bool shouldUseCredential
     const bool usesCache = true;
 #endif
     d->m_connection = adoptNS([[NSURLConnection alloc] _initWithRequest:nsRequest delegate:delegate usesCache:usesCache maxContentLength:0 startImmediately:NO connectionProperties:propertyDictionary]);
-#if ENABLE(WEB_TIMING)
-    [NSURLConnection _setCollectsTimingData:YES];
-#endif
 }
 
 bool ResourceHandle::start()
@@ -758,7 +759,10 @@ void ResourceHandle::getConnectionTimingData(NSDictionary *timingData, ResourceL
     
 void ResourceHandle::setCollectsTimingData()
 {
-    [NSURLConnection _setCollectsTimingData:YES];
+    static dispatch_once_t onceToken;
+    dispatch_once(&onceToken, ^{
+        [NSURLConnection _setCollectsTimingData:YES];
+    });
 }
     
 void ResourceHandle::getConnectionTimingData(CFURLConnectionRef connection, ResourceLoadTiming& timing)