Cached file backed resources don't make it to the Web Process when NETWORK_CFDATA_ARR...
authorpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 22:50:40 +0000 (22:50 +0000)
committerpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Aug 2014 22:50:40 +0000 (22:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135727
<rdar://problem/17947880>

Reviewed by Darin Adler.

Source/WebCore:

Add SharedBuffer::existingCFData() which returns CFDataRef if it has one. Refactor
this code out of createCFData().

* WebCore.exp.in:
* platform/SharedBuffer.h:
* platform/mac/SharedBufferMac.mm:
(WebCore::SharedBuffer::existingCFData): Added.
(WebCore::SharedBuffer::createCFData):

Source/WebKit2:

tryGetShareableHandleFromSharedBuffer() assumed that we have a file backed resource only if
we had a CFDataRef (platformData()) in SharedBuffer. This is wrong when we use the data
array callbacks since the file backed buffer could be in the data array. Instead of relying
on hasPlatformData(), explicitly ask the SharedBuffer to give us a CFDataRef if it has one
so that SharedBuffer can take care of the data array case.

* NetworkProcess/mac/NetworkResourceLoaderMac.mm:
(WebKit::NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer):

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/SharedBuffer.h
Source/WebCore/platform/mac/SharedBufferMac.mm
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/mac/NetworkResourceLoaderMac.mm

index 5eac550..dfc59f1 100644 (file)
@@ -1,3 +1,20 @@
+2014-08-12  Pratik Solanki  <psolanki@apple.com>
+
+        Cached file backed resources don't make it to the Web Process when NETWORK_CFDATA_ARRAY_CALLBACK is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=135727
+        <rdar://problem/17947880>
+
+        Reviewed by Darin Adler.
+
+        Add SharedBuffer::existingCFData() which returns CFDataRef if it has one. Refactor
+        this code out of createCFData().
+
+        * WebCore.exp.in:
+        * platform/SharedBuffer.h:
+        * platform/mac/SharedBufferMac.mm:
+        (WebCore::SharedBuffer::existingCFData): Added.
+        (WebCore::SharedBuffer::createCFData):
+
 2014-08-12  Tim Horton  <timothy_horton@apple.com>
 
         Small region (~1px tall) where you get the selection button instead of the phone number overlay
index d98d825..37ed37e 100644 (file)
@@ -242,6 +242,7 @@ __ZN7WebCore12SharedBuffer10wrapNSDataEP6NSData
 __ZN7WebCore12SharedBuffer11adoptVectorERN3WTF6VectorIcLm0ENS1_15CrashOnOverflowEEE
 __ZN7WebCore12SharedBuffer12createCFDataEv
 __ZN7WebCore12SharedBuffer12createNSDataEv
+__ZN7WebCore12SharedBuffer14existingCFDataEv
 __ZN7WebCore12SharedBuffer24createWithContentsOfFileERKN3WTF6StringE
 __ZN7WebCore12SharedBuffer6appendEPKcj
 __ZN7WebCore12SharedBuffer6appendEPS0_
index f4db960..c70c8ad 100644 (file)
@@ -74,6 +74,7 @@ public:
 #endif
 #if USE(CF)
     RetainPtr<CFDataRef> createCFData();
+    CFDataRef existingCFData();
     static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef);
 #endif
 
index f97328f..43874e9 100644 (file)
@@ -128,16 +128,24 @@ RetainPtr<NSData> SharedBuffer::createNSData()
     return adoptNS((NSData *)createCFData().leakRef());
 }
 
-RetainPtr<CFDataRef> SharedBuffer::createCFData()
+CFDataRef SharedBuffer::existingCFData()
 {
     if (m_cfData)
-        return m_cfData;
+        return m_cfData.get();
 
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
     if (m_dataArray.size() == 1)
-        return m_dataArray.at(0);
+        return m_dataArray.at(0).get();
 #endif
 
+    return nullptr;
+}
+
+RetainPtr<CFDataRef> SharedBuffer::createCFData()
+{
+    if (CFDataRef cfData = existingCFData())
+        return cfData;
+
 #if ENABLE(DISK_IMAGE_CACHE)
     if (isMemoryMapped())
         return adoptCF((CFDataRef)adoptNS([[WebCoreSharedBufferData alloc] initWithMemoryMappedSharedBuffer:*this]).leakRef());
index be5586f..dd6160c 100644 (file)
@@ -1,3 +1,20 @@
+2014-08-12  Pratik Solanki  <psolanki@apple.com>
+
+        Cached file backed resources don't make it to the Web Process when NETWORK_CFDATA_ARRAY_CALLBACK is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=135727
+        <rdar://problem/17947880>
+
+        Reviewed by Darin Adler.
+
+        tryGetShareableHandleFromSharedBuffer() assumed that we have a file backed resource only if
+        we had a CFDataRef (platformData()) in SharedBuffer. This is wrong when we use the data
+        array callbacks since the file backed buffer could be in the data array. Instead of relying
+        on hasPlatformData(), explicitly ask the SharedBuffer to give us a CFDataRef if it has one
+        so that SharedBuffer can take care of the data array case.
+
+        * NetworkProcess/mac/NetworkResourceLoaderMac.mm:
+        (WebKit::NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer):
+
 2014-08-12  Alexey Proskuryakov  <ap@apple.com>
 
         REGRESSION: WebContent process has a sandbox extension for the entirety of user's temp directory
index 63048b1..db8d999 100644 (file)
@@ -93,14 +93,14 @@ void NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer(ShareableResou
     if (!cache)
         return;
 
-    if (!buffer->hasPlatformData())
+    CFDataRef data = buffer->existingCFData();
+    if (!data)
         return;
 
-    RetainPtr<CFDataRef> data = buffer->createCFData();
-    if (_CFURLCacheIsResponseDataMemMapped(cache, data.get()) == kCFBooleanFalse)
+    if (_CFURLCacheIsResponseDataMemMapped(cache, data) == kCFBooleanFalse)
         return;
 
-    tryGetShareableHandleFromCFData(handle, data.get());
+    tryGetShareableHandleFromCFData(handle, data);
 }
 #endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090