Title: [168231] trunk/Source/WebKit2
Revision
168231
Author
psola...@apple.com
Date
2014-05-03 17:13:11 -0700 (Sat, 03 May 2014)

Log Message

Reduce calls to CFURLCacheCopySharedURLCache
https://bugs.webkit.org/show_bug.cgi?id=132464
<rdar://problem/16806694>

Reviewed by Alexey Proskuryakov.

CFURLCacheCopySharedURLCache grabs a mutex and can sometimes block. Avoid that by stashing
the cache reference in a static.

* NetworkProcess/NetworkResourceLoader.h: Coalesce ifdef'd code.
* NetworkProcess/mac/NetworkResourceLoaderMac.mm:
(WebKit::NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer):
(WebKit::NetworkResourceLoader::willCacheResponseAsync): Use more correct ifdef for
Foundation based callback.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (168230 => 168231)


--- trunk/Source/WebKit2/ChangeLog	2014-05-03 22:16:53 UTC (rev 168230)
+++ trunk/Source/WebKit2/ChangeLog	2014-05-04 00:13:11 UTC (rev 168231)
@@ -1,3 +1,20 @@
+2014-05-02  Pratik Solanki  <psola...@apple.com>
+
+        Reduce calls to CFURLCacheCopySharedURLCache
+        https://bugs.webkit.org/show_bug.cgi?id=132464
+        <rdar://problem/16806694>
+
+        Reviewed by Alexey Proskuryakov.
+
+        CFURLCacheCopySharedURLCache grabs a mutex and can sometimes block. Avoid that by stashing
+        the cache reference in a static.
+
+        * NetworkProcess/NetworkResourceLoader.h: Coalesce ifdef'd code.
+        * NetworkProcess/mac/NetworkResourceLoaderMac.mm:
+        (WebKit::NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer):
+        (WebKit::NetworkResourceLoader::willCacheResponseAsync): Use more correct ifdef for
+        Foundation based callback.
+
 2014-05-03  Sam Weinig  <s...@webkit.org>
 
         [Cocoa WebKit2] Add basic _WKWebsiteDataStore implementation

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h (168230 => 168231)


--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h	2014-05-03 22:16:53 UTC (rev 168230)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h	2014-05-04 00:13:11 UTC (rev 168231)
@@ -124,6 +124,7 @@
 
 #if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
     static void tryGetShareableHandleFromCFURLCachedResponse(ShareableResource::Handle&, CFCachedURLResponseRef);
+    static void tryGetShareableHandleFromSharedBuffer(ShareableResource::Handle&, WebCore::SharedBuffer*);
 #endif
 
     bool isSynchronous() const;
@@ -141,16 +142,11 @@
         return result;
     }
 
-
 #if USE(PROTECTION_SPACE_AUTH_CALLBACK)
     void continueCanAuthenticateAgainstProtectionSpace(bool);
 #endif
     void continueWillSendRequest(const WebCore::ResourceRequest& newRequest);
 
-#if PLATFORM(IOS) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
-    static void tryGetShareableHandleFromSharedBuffer(ShareableResource::Handle&, WebCore::SharedBuffer*);
-#endif
-
 private:
     NetworkResourceLoader(const NetworkResourceLoadParameters&, NetworkConnectionToWebProcess*, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>);
 

Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkResourceLoaderMac.mm (168230 => 168231)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkResourceLoaderMac.mm	2014-05-03 22:16:53 UTC (rev 168230)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkResourceLoaderMac.mm	2014-05-04 00:13:11 UTC (rev 168231)
@@ -86,12 +86,18 @@
 
 void NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer(ShareableResource::Handle& handle, SharedBuffer* buffer)
 {
-    RetainPtr<CFURLCacheRef> cache = adoptCF(CFURLCacheCopySharedURLCache());
+    static CFURLCacheRef cache = CFURLCacheCopySharedURLCache();
+#if !ASSERT_DISABLED
+    ASSERT(isMainThread());
+    RetainPtr<CFURLCacheRef> currentCache = adoptCF(CFURLCacheCopySharedURLCache());
+    ASSERT(cache == currentCache.get());
+#endif
+
     if (!cache)
         return;
 
     RetainPtr<CFDataRef> data = ""
-    if (_CFURLCacheIsResponseDataMemMapped(cache.get(), data.get()) == kCFBooleanFalse)
+    if (_CFURLCacheIsResponseDataMemMapped(cache, data.get()) == kCFBooleanFalse)
         return;
 
     tryGetShareableHandleFromCFData(handle, data.get());
@@ -113,9 +119,9 @@
 
     m_handle->continueWillCacheResponse(cfResponse);
 }
-#endif
 
-#if !PLATFORM(IOS)
+#else
+
 void NetworkResourceLoader::willCacheResponseAsync(ResourceHandle* handle, NSCachedURLResponse *nsResponse)
 {
     ASSERT_UNUSED(handle, handle == m_handle);
@@ -127,7 +133,7 @@
 
     m_handle->continueWillCacheResponse(nsResponse);
 }
-#endif // !PLATFORM(IOS)
+#endif // !USE(CFNETWORK)
 
 } // namespace WebKit
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to