Title: [172811] trunk/Source
Revision
172811
Author
[email protected]
Date
2014-08-20 14:07:36 -0700 (Wed, 20 Aug 2014)

Log Message

Move DiskCacheMonitor to WebCore so that WebKit1 clients can use it as well
https://bugs.webkit.org/show_bug.cgi?id=135896

Reviewed by Andreas Kling.

Source/WebCore:

Refactor code and move it to WebCore.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* loader/ResourceLoader.h:
    Make willCacheResponse protected so that SubresourceLoader can override it.
* loader/SubresourceLoader.h:
* loader/cocoa/DiskCacheMonitorCocoa.h: Added.
    Mostly the same as the existing NetworkDiskCacheMonitor class in WebKit2. In the
    CFNetwork callback block, it calls a virtual function that is overridden by
    NetworkDiskCacheMonitor to send a message to WebContent process.
(WebCore::DiskCacheMonitor::~DiskCacheMonitor):
(WebCore::DiskCacheMonitor::resourceRequest):
(WebCore::DiskCacheMonitor::sessionID):
* loader/cocoa/DiskCacheMonitorCocoa.mm:
(WebCore::DiskCacheMonitor::tryGetFileBackedSharedBufferFromCFURLCachedResponse):
    Copied from NetworkResourceLoader::tryGetFileBackedSharedBufferFromCFURLCachedResponse.
(WebCore::DiskCacheMonitor::monitorFileBackingStoreCreation):
(WebCore::DiskCacheMonitor::DiskCacheMonitor):
(WebCore::DiskCacheMonitor::resourceBecameFileBacked):
    Replace the cached resource data with the contents of the file backed buffer. This is
    used in WebKit1 (and also for any resource loads that happen from the WebContent
    process).
* loader/cocoa/SubresourceLoaderCocoa.mm: Added.
(WebCore::SubresourceLoader::willCacheResponse):
    Override willCacheresponse from ResourceLoader to listen for disk cache notifications.

Source/WebKit2:

* NetworkProcess/mac/NetworkDiskCacheMonitor.h:
    Inherit from WebCore::DiskCacheMonitor which has the bulk of the functionality now.
(WebKit::NetworkDiskCacheMonitor::~NetworkDiskCacheMonitor):
* NetworkProcess/mac/NetworkDiskCacheMonitor.mm:
(WebKit::NetworkDiskCacheMonitor::monitorFileBackingStoreCreation):
(WebKit::NetworkDiskCacheMonitor::NetworkDiskCacheMonitor):
(WebKit::NetworkDiskCacheMonitor::resourceBecameFileBacked):
    Override virtual method and send the data to the WebContent process as before.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (172810 => 172811)


--- trunk/Source/WebCore/ChangeLog	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebCore/ChangeLog	2014-08-20 21:07:36 UTC (rev 172811)
@@ -1,3 +1,37 @@
+2014-08-20  Pratik Solanki  <[email protected]>
+
+        Move DiskCacheMonitor to WebCore so that WebKit1 clients can use it as well
+        https://bugs.webkit.org/show_bug.cgi?id=135896
+
+        Reviewed by Andreas Kling.
+
+        Refactor code and move it to WebCore.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/ResourceLoader.h:
+            Make willCacheResponse protected so that SubresourceLoader can override it.
+        * loader/SubresourceLoader.h:
+        * loader/cocoa/DiskCacheMonitorCocoa.h: Added.
+            Mostly the same as the existing NetworkDiskCacheMonitor class in WebKit2. In the
+            CFNetwork callback block, it calls a virtual function that is overridden by
+            NetworkDiskCacheMonitor to send a message to WebContent process.
+        (WebCore::DiskCacheMonitor::~DiskCacheMonitor):
+        (WebCore::DiskCacheMonitor::resourceRequest):
+        (WebCore::DiskCacheMonitor::sessionID):
+        * loader/cocoa/DiskCacheMonitorCocoa.mm:
+        (WebCore::DiskCacheMonitor::tryGetFileBackedSharedBufferFromCFURLCachedResponse):
+            Copied from NetworkResourceLoader::tryGetFileBackedSharedBufferFromCFURLCachedResponse.
+        (WebCore::DiskCacheMonitor::monitorFileBackingStoreCreation):
+        (WebCore::DiskCacheMonitor::DiskCacheMonitor):
+        (WebCore::DiskCacheMonitor::resourceBecameFileBacked):
+            Replace the cached resource data with the contents of the file backed buffer. This is
+            used in WebKit1 (and also for any resource loads that happen from the WebContent
+            process).
+        * loader/cocoa/SubresourceLoaderCocoa.mm: Added.
+        (WebCore::SubresourceLoader::willCacheResponse):
+            Override willCacheresponse from ResourceLoader to listen for disk cache notifications.
+
 2014-08-20  Eric Carlson  <[email protected]>
 
         Cleanup MediaSession

Modified: trunk/Source/WebCore/WebCore.exp.in (172810 => 172811)


--- trunk/Source/WebCore/WebCore.exp.in	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-08-20 21:07:36 UTC (rev 172811)
@@ -2834,9 +2834,11 @@
 
 #if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
 __ZN7WebCore15ProtectionSpace28encodingRequiresPlatformDataEP20NSURLProtectionSpace
+__ZN7WebCore16DiskCacheMonitorC2ERKNS_15ResourceRequestENS_9SessionIDEPK20_CFCachedURLResponse
 __ZN7WebCore23wrapSerializedCryptoKeyERKN3WTF6VectorIhLm0ENS0_15CrashOnOverflowEEES5_RS3_
 __ZN7WebCore25unwrapSerializedCryptoKeyERKN3WTF6VectorIhLm0ENS0_15CrashOnOverflowEEES5_RS3_
 __ZN7WebCore28getDefaultWebCryptoMasterKeyERN3WTF6VectorIhLm0ENS0_15CrashOnOverflowEEE
+__ZTVN7WebCore16DiskCacheMonitorE
 _wkCTFontTransformGlyphs
 #endif
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (172810 => 172811)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-08-20 21:07:36 UTC (rev 172811)
@@ -2438,6 +2438,7 @@
 		7E474E1E12494DC900235364 /* SQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E474E1B12494DC900235364 /* SQLiteDatabaseTrackerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7E474E1F12494DC900235364 /* SQLiteDatabaseTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E474E1C12494DC900235364 /* SQLiteDatabaseTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7E474E2012494DC900235364 /* SQLiteDatabaseTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */; };
+		7E4DE10D198B10B60051CB02 /* DiskCacheMonitorCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */; };
 		7E5D7A76161D3F8F00896C34 /* OESElementIndexUint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */; };
 		7E5D7A77161D3F8F00896C34 /* OESElementIndexUint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E5D7A74161D3F8F00896C34 /* OESElementIndexUint.h */; };
 		7E66E23316D6EB6C00F7E7FF /* WebGLCompressedTextureATC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E66E23116D6EB6C00F7E7FF /* WebGLCompressedTextureATC.cpp */; };
@@ -2446,12 +2447,14 @@
 		7E66E23417E6EB6C00F7E7FF /* WebGLCompressedTexturePVRTC.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E66E23217E6EB6C00F7E7FF /* WebGLCompressedTexturePVRTC.h */; };
 		7E7DE1FD195CEF260035363B /* ResourceRequestCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E7DE1FC195CEF260035363B /* ResourceRequestCocoa.mm */; };
 		7E7DE202195CEFCD0035363B /* ResourceRequestIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E7DE201195CEFCD0035363B /* ResourceRequestIOS.mm */; };
+		7E8FADC4199A95B100714968 /* SubresourceLoaderCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E8FADC3199A95B100714968 /* SubresourceLoaderCocoa.mm */; };
 		7E99AF510B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E99AF520B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp */; };
 		7E99AF530B13846468FB01A5 /* WindowFocusAllowedIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E99AF540B13846468FB01A5 /* WindowFocusAllowedIndicator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7EA30F6916DFFE7500257D0B /* JSWebGLCompressedTextureATC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EA30F6716DFFE7500257D0B /* JSWebGLCompressedTextureATC.cpp */; };
 		7EA30F6917EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EA30F6717EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.cpp */; };
 		7EA30F6A16DFFE7500257D0B /* JSWebGLCompressedTextureATC.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EA30F6816DFFE7500257D0B /* JSWebGLCompressedTextureATC.h */; };
 		7EA30F6A17EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EA30F6817EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.h */; };
+		7EDAAFC919A2CCDC0034DFD1 /* DiskCacheMonitorCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EDAAFC819A2CBD10034DFD1 /* DiskCacheMonitorCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7EE6845F12D26E3800E79415 /* AuthenticationCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EE6844C12D26E3800E79415 /* AuthenticationCF.cpp */; };
 		7EE6846012D26E3800E79415 /* AuthenticationCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6844D12D26E3800E79415 /* AuthenticationCF.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		7EE6846112D26E3800E79415 /* AuthenticationChallenge.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6844E12D26E3800E79415 /* AuthenticationChallenge.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7795,7 +7798,7 @@
 		1AC69592161A1E53003732CB /* GraphicsLayerFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerFactory.h; sourceTree = "<group>"; };
 		1AC900BF1943AF3D008625B5 /* HTTPHeaderNames.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = HTTPHeaderNames.in; sourceTree = "<group>"; };
 		1AC900C01943C0A0008625B5 /* HTTPHeaderNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPHeaderNames.cpp; sourceTree = "<group>"; };
-		1AC900C11943C0A0008625B5 /* HTTPHeaderNames.gperf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file; path = HTTPHeaderNames.gperf; sourceTree = "<group>"; };
+		1AC900C11943C0A0008625B5 /* HTTPHeaderNames.gperf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTTPHeaderNames.gperf; sourceTree = "<group>"; };
 		1AC900C21943C0A0008625B5 /* HTTPHeaderNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTTPHeaderNames.h; sourceTree = "<group>"; };
 		1ACADD781880D91C00D8B71D /* ProgressTrackerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProgressTrackerClient.h; sourceTree = "<group>"; };
 		1ACE53DD0A8D18810022947D /* JSDOMParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMParser.cpp; sourceTree = "<group>"; };
@@ -9592,6 +9595,7 @@
 		7E474E1B12494DC900235364 /* SQLiteDatabaseTrackerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLiteDatabaseTrackerClient.h; path = sql/SQLiteDatabaseTrackerClient.h; sourceTree = "<group>"; };
 		7E474E1C12494DC900235364 /* SQLiteDatabaseTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SQLiteDatabaseTracker.h; path = sql/SQLiteDatabaseTracker.h; sourceTree = "<group>"; };
 		7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SQLiteDatabaseTracker.cpp; path = sql/SQLiteDatabaseTracker.cpp; sourceTree = "<group>"; };
+		7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DiskCacheMonitorCocoa.mm; path = cocoa/DiskCacheMonitorCocoa.mm; sourceTree = "<group>"; };
 		7E5D7A73161D3F8F00896C34 /* OESElementIndexUint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OESElementIndexUint.cpp; path = canvas/OESElementIndexUint.cpp; sourceTree = "<group>"; };
 		7E5D7A74161D3F8F00896C34 /* OESElementIndexUint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OESElementIndexUint.h; path = canvas/OESElementIndexUint.h; sourceTree = "<group>"; };
 		7E66E23116D6EB6C00F7E7FF /* WebGLCompressedTextureATC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLCompressedTextureATC.cpp; path = canvas/WebGLCompressedTextureATC.cpp; sourceTree = "<group>"; };
@@ -9600,6 +9604,7 @@
 		7E66E23217E6EB6C00F7E7FF /* WebGLCompressedTexturePVRTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLCompressedTexturePVRTC.h; path = canvas/WebGLCompressedTexturePVRTC.h; sourceTree = "<group>"; };
 		7E7DE1FC195CEF260035363B /* ResourceRequestCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ResourceRequestCocoa.mm; path = cocoa/ResourceRequestCocoa.mm; sourceTree = "<group>"; };
 		7E7DE201195CEFCD0035363B /* ResourceRequestIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceRequestIOS.mm; sourceTree = "<group>"; };
+		7E8FADC3199A95B100714968 /* SubresourceLoaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SubresourceLoaderCocoa.mm; path = cocoa/SubresourceLoaderCocoa.mm; sourceTree = "<group>"; };
 		7E99AF520B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowFocusAllowedIndicator.cpp; sourceTree = "<group>"; };
 		7E99AF540B13846468FB01A5 /* WindowFocusAllowedIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowFocusAllowedIndicator.h; sourceTree = "<group>"; };
 		7EA30F6216DFD62700257D0B /* WebGLCompressedTextureATC.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLCompressedTextureATC.idl; path = canvas/WebGLCompressedTextureATC.idl; sourceTree = "<group>"; };
@@ -9608,6 +9613,7 @@
 		7EA30F6717EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLCompressedTexturePVRTC.cpp; sourceTree = "<group>"; };
 		7EA30F6816DFFE7500257D0B /* JSWebGLCompressedTextureATC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLCompressedTextureATC.h; sourceTree = "<group>"; };
 		7EA30F6817EFFE7500257D0B /* JSWebGLCompressedTexturePVRTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLCompressedTexturePVRTC.h; sourceTree = "<group>"; };
+		7EDAAFC819A2CBD10034DFD1 /* DiskCacheMonitorCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DiskCacheMonitorCocoa.h; path = cocoa/DiskCacheMonitorCocoa.h; sourceTree = "<group>"; };
 		7EE6844C12D26E3800E79415 /* AuthenticationCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticationCF.cpp; sourceTree = "<group>"; };
 		7EE6844D12D26E3800E79415 /* AuthenticationCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthenticationCF.h; sourceTree = "<group>"; };
 		7EE6844E12D26E3800E79415 /* AuthenticationChallenge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthenticationChallenge.h; sourceTree = "<group>"; };
@@ -16757,6 +16763,16 @@
 			path = icu;
 			sourceTree = "<group>";
 		};
+		7E4DE10B198B10810051CB02 /* cocoa */ = {
+			isa = PBXGroup;
+			children = (
+				7EDAAFC819A2CBD10034DFD1 /* DiskCacheMonitorCocoa.h */,
+				7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */,
+				7E8FADC3199A95B100714968 /* SubresourceLoaderCocoa.mm */,
+			);
+			name = cocoa;
+			sourceTree = "<group>";
+		};
 		7E7DE1FE195CEF2D0035363B /* cocoa */ = {
 			isa = PBXGroup;
 			children = (
@@ -21155,6 +21171,7 @@
 				512DD8E80D91E691000F89EE /* archive */,
 				A8D2B2521287A56000AF4DDA /* cache */,
 				7EE6847312D26E5500E79415 /* cf */,
+				7E4DE10B198B10810051CB02 /* cocoa */,
 				5126E6B60A2E3AEF005C29FA /* icon */,
 				CE79D68617F220ED00815C00 /* ios */,
 				93A1EAA20A5634D8006960A0 /* mac */,
@@ -25880,6 +25897,7 @@
 				93C38BFF164473C700091EB2 /* ScrollingStateFixedNode.h in Headers */,
 				931CBD0D161A44E900E4C874 /* ScrollingStateNode.h in Headers */,
 				931CBD0F161A44E900E4C874 /* ScrollingStateScrollingNode.h in Headers */,
+				7EDAAFC919A2CCDC0034DFD1 /* DiskCacheMonitorCocoa.h in Headers */,
 				0FB8890F167D30160010CDA5 /* ScrollingStateStickyNode.h in Headers */,
 				931CBD11161A44E900E4C874 /* ScrollingStateTree.h in Headers */,
 				1AF62F2614DAFEA10041556C /* ScrollingThread.h in Headers */,
@@ -28200,6 +28218,7 @@
 				659DDC8209E198BA001BF3C6 /* JSDocument.cpp in Sources */,
 				49C7BA8D1042F5B10009D447 /* JSDocumentCustom.cpp in Sources */,
 				1A494EDE0A123F4C00FDAFC1 /* JSDocumentFragment.cpp in Sources */,
+				7E4DE10D198B10B60051CB02 /* DiskCacheMonitorCocoa.mm in Sources */,
 				65DF31F509D1CC60000BE325 /* JSDocumentType.cpp in Sources */,
 				1AC2260C0DB69F190089B669 /* JSDOMApplicationCache.cpp in Sources */,
 				93B70D6309EB0C7C009D8468 /* JSDOMBinding.cpp in Sources */,
@@ -28864,6 +28883,7 @@
 				FD6F252C13F5EF0E0065165F /* MediaElementAudioSourceNode.cpp in Sources */,
 				4E1959210A39DABA00220FE5 /* MediaFeatureNames.cpp in Sources */,
 				07A6D1EB1491137700051D0C /* MediaFragmentURIParser.cpp in Sources */,
+				7E8FADC4199A95B100714968 /* SubresourceLoaderCocoa.mm in Sources */,
 				CDB859F7160D48A400E5B07F /* MediaKeyEvent.cpp in Sources */,
 				CDA98DD816025BEF00FEA3B1 /* MediaKeyMessageEvent.cpp in Sources */,
 				CD1B4A65160786AE00282DF9 /* MediaKeyNeededEvent.cpp in Sources */,

Modified: trunk/Source/WebCore/loader/ResourceLoader.h (172810 => 172811)


--- trunk/Source/WebCore/loader/ResourceLoader.h	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebCore/loader/ResourceLoader.h	2014-08-20 21:07:36 UTC (rev 172811)
@@ -155,6 +155,13 @@
 
     const ResourceLoaderOptions& options() { return m_options; }
 
+#if PLATFORM(COCOA) && !USE(CFNETWORK)
+    virtual NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
+#endif
+#if PLATFORM(COCOA) && USE(CFNETWORK)
+    virtual CFCachedURLResponseRef willCacheResponse(ResourceHandle*, CFCachedURLResponseRef) override;
+#endif
+
     RefPtr<ResourceHandle> m_handle;
     RefPtr<Frame> m_frame;
     RefPtr<DocumentLoader> m_documentLoader;
@@ -186,12 +193,6 @@
     virtual bool canAuthenticateAgainstProtectionSpace(ResourceHandle*, const ProtectionSpace& protectionSpace) override { return canAuthenticateAgainstProtectionSpace(protectionSpace); }
 #endif
     virtual void receivedCancellation(ResourceHandle*, const AuthenticationChallenge& challenge) override { receivedCancellation(challenge); }
-#if PLATFORM(COCOA) && !USE(CFNETWORK)
-    virtual NSCachedURLResponse* willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
-#endif
-#if PLATFORM(COCOA) && USE(CFNETWORK)
-    virtual CFCachedURLResponseRef willCacheResponse(ResourceHandle*, CFCachedURLResponseRef) override;
-#endif
 #if PLATFORM(IOS)
     virtual RetainPtr<CFDictionaryRef> connectionProperties(ResourceHandle*) override;
 #endif

Modified: trunk/Source/WebCore/loader/SubresourceLoader.h (172810 => 172811)


--- trunk/Source/WebCore/loader/SubresourceLoader.h	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebCore/loader/SubresourceLoader.h	2014-08-20 21:07:36 UTC (rev 172811)
@@ -74,6 +74,13 @@
     virtual void willCancel(const ResourceError&) override;
     virtual void didCancel(const ResourceError&) override;
 
+#if PLATFORM(COCOA) && !USE(CFNETWORK)
+    virtual NSCachedURLResponse *willCacheResponse(ResourceHandle*, NSCachedURLResponse*) override;
+#endif
+#if PLATFORM(COCOA) && USE(CFNETWORK)
+    virtual CFCachedURLResponseRef willCacheResponse(ResourceHandle*, CFCachedURLResponseRef) override;
+#endif
+
 #if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
     virtual bool supportsDataArray() override { return true; }
     virtual void didReceiveDataArray(CFArrayRef) override;

Copied: trunk/Source/WebCore/loader/cocoa/DiskCacheMonitor.h (from rev 172809, trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.h) (0 => 172811)


--- trunk/Source/WebCore/loader/cocoa/DiskCacheMonitor.h	                        (rev 0)
+++ trunk/Source/WebCore/loader/cocoa/DiskCacheMonitor.h	2014-08-20 21:07:36 UTC (rev 172811)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DiskCacheMonitor_h
+#define DiskCacheMonitor_h
+
+#include "ResourceRequest.h"
+#include "SessionID.h"
+#include <wtf/PassRefPtr.h>
+
+typedef const struct _CFCachedURLResponse* CFCachedURLResponseRef;
+
+namespace WebCore {
+
+class SharedBuffer;
+
+class DiskCacheMonitor {
+public:
+    static void monitorFileBackingStoreCreation(const ResourceRequest&, SessionID, CFCachedURLResponseRef);
+    static PassRefPtr<SharedBuffer> tryGetFileBackedSharedBufferFromCFURLCachedResponse(CFCachedURLResponseRef);
+    virtual ~DiskCacheMonitor() { }
+
+protected:
+    DiskCacheMonitor(const ResourceRequest&, SessionID, CFCachedURLResponseRef);
+
+    virtual void resourceBecameFileBacked(PassRefPtr<SharedBuffer>);
+
+    const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
+    SessionID sessionID() const { return m_sessionID; }
+
+private:
+    ResourceRequest m_resourceRequest;
+    SessionID m_sessionID;
+};
+
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090)
+
+void DiskCacheMonitor::monitorFileBackingStoreCreation(const ResourceRequest&, SessionID, CFCachedURLResponseRef) { }
+PassRefPtr<SharedBuffer> DiskCacheMonitor::tryGetFileBackedSharedBufferFromCFURLCachedResponse(CFCachedURLResponseRef) { return nullptr; }
+
+#endif
+} // namespace WebKit
+
+#endif // DiskCacheMonitor_h

Copied: trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.h (from rev 172809, trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.h) (0 => 172811)


--- trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.h	                        (rev 0)
+++ trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.h	2014-08-20 21:07:36 UTC (rev 172811)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DiskCacheMonitorCocoa_h
+#define DiskCacheMonitorCocoa_h
+
+#include "ResourceRequest.h"
+#include "SessionID.h"
+#include <wtf/PassRefPtr.h>
+
+typedef const struct _CFCachedURLResponse* CFCachedURLResponseRef;
+
+namespace WebCore {
+
+class SharedBuffer;
+
+class DiskCacheMonitor {
+public:
+    static void monitorFileBackingStoreCreation(const ResourceRequest&, SessionID, CFCachedURLResponseRef);
+    static PassRefPtr<SharedBuffer> tryGetFileBackedSharedBufferFromCFURLCachedResponse(CFCachedURLResponseRef);
+    virtual ~DiskCacheMonitor() { }
+
+protected:
+    DiskCacheMonitor(const ResourceRequest&, SessionID, CFCachedURLResponseRef);
+
+    virtual void resourceBecameFileBacked(PassRefPtr<SharedBuffer>);
+
+    const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
+    SessionID sessionID() const { return m_sessionID; }
+
+private:
+    ResourceRequest m_resourceRequest;
+    SessionID m_sessionID;
+};
+
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED < 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090)
+
+inline void DiskCacheMonitor::monitorFileBackingStoreCreation(const ResourceRequest&, SessionID, CFCachedURLResponseRef)
+{
+}
+
+inline PassRefPtr<SharedBuffer> DiskCacheMonitor::tryGetFileBackedSharedBufferFromCFURLCachedResponse(CFCachedURLResponseRef)
+{
+    return nullptr;
+}
+
+#endif
+
+} // namespace WebKit
+
+#endif // DiskCacheMonitorCocoa_h

Copied: trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.mm (from rev 172809, trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.mm) (0 => 172811)


--- trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/loader/cocoa/DiskCacheMonitorCocoa.mm	2014-08-20 21:07:36 UTC (rev 172811)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "DiskCacheMonitorCocoa.h"
+
+#import "CachedResource.h"
+#import "MemoryCache.h"
+#import "ResourceRequest.h"
+#import "SessionID.h"
+#import "SharedBuffer.h"
+#import <wtf/MainThread.h>
+#import <wtf/OwnPtr.h>
+#import <wtf/PassOwnPtr.h>
+#import <wtf/PassRefPtr.h>
+#import <wtf/RefPtr.h>
+
+#ifdef __has_include
+#if __has_include(<CFNetwork/CFURLCachePriv.h>)
+#include <CFNetwork/CFURLCachePriv.h>
+#endif
+#endif
+
+#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
+
+typedef void (^CFCachedURLResponseCallBackBlock)(CFCachedURLResponseRef);
+extern "C" void _CFCachedURLResponseSetBecameFileBackedCallBackBlock(CFCachedURLResponseRef, CFCachedURLResponseCallBackBlock, dispatch_queue_t);
+extern "C" CFDataRef _CFCachedURLResponseGetMemMappedData(CFCachedURLResponseRef);
+
+namespace WebCore {
+
+// The maximum number of seconds we'll try to wait for a resource to be disk cached before we forget the request.
+static const double diskCacheMonitorTimeout = 20;
+
+PassRefPtr<SharedBuffer> DiskCacheMonitor::tryGetFileBackedSharedBufferFromCFURLCachedResponse(CFCachedURLResponseRef cachedResponse)
+{
+    CFDataRef data = ""
+    if (!data)
+        return nullptr;
+
+    return SharedBuffer::wrapCFData(data);
+}
+
+void DiskCacheMonitor::monitorFileBackingStoreCreation(const ResourceRequest& request, SessionID sessionID, CFCachedURLResponseRef cachedResponse)
+{
+    if (!cachedResponse)
+        return;
+
+    new DiskCacheMonitor(request, sessionID, cachedResponse); // Balanced by adoptPtr in the blocks setup in the constructor, one of which is guaranteed to run.
+}
+
+DiskCacheMonitor::DiskCacheMonitor(const ResourceRequest& request, SessionID sessionID, CFCachedURLResponseRef cachedResponse)
+    : m_resourceRequest(request)
+    , m_sessionID(sessionID)
+{
+    ASSERT(isMainThread());
+
+    // Set up a delayed callback to cancel this monitor if the resource hasn't been cached yet.
+    __block DiskCacheMonitor* rawMonitor = this;
+
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * diskCacheMonitorTimeout), dispatch_get_main_queue(), ^{
+        adoptPtr(rawMonitor); // Balanced by `new DiskCacheMonitor` in monitorFileBackingStoreCreation.
+        rawMonitor = 0;
+    });
+
+    // Set up the disk caching callback to create the ShareableResource and send it to the WebProcess.
+    CFCachedURLResponseCallBackBlock block = ^(CFCachedURLResponseRef cachedResponse)
+    {
+        // If the monitor isn't there then it timed out before this resource was cached to disk.
+        if (!rawMonitor)
+            return;
+
+        OwnPtr<DiskCacheMonitor> monitor = adoptPtr(rawMonitor); // Balanced by `new DiskCacheMonitor` in monitorFileBackingStoreCreation.
+        rawMonitor = 0;
+
+        RefPtr<SharedBuffer> fileBackedBuffer = DiskCacheMonitor::tryGetFileBackedSharedBufferFromCFURLCachedResponse(cachedResponse);
+        if (!fileBackedBuffer)
+            return;
+
+        monitor->resourceBecameFileBacked(fileBackedBuffer);
+    };
+
+    _CFCachedURLResponseSetBecameFileBackedCallBackBlock(cachedResponse, block, dispatch_get_main_queue());
+}
+
+void DiskCacheMonitor::resourceBecameFileBacked(PassRefPtr<SharedBuffer> fileBackedBuffer)
+{
+    CachedResource* resource = memoryCache()->resourceForRequest(m_resourceRequest, m_sessionID);
+    if (!resource)
+        return;
+
+    resource->tryReplaceEncodedData(fileBackedBuffer);
+}
+
+
+} // namespace WebCore
+
+#endif // (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)

Copied: trunk/Source/WebCore/loader/cocoa/SubresourceLoaderCocoa.mm (from rev 172809, trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.h) (0 => 172811)


--- trunk/Source/WebCore/loader/cocoa/SubresourceLoaderCocoa.mm	                        (rev 0)
+++ trunk/Source/WebCore/loader/cocoa/SubresourceLoaderCocoa.mm	2014-08-20 21:07:36 UTC (rev 172811)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SubresourceLoader.h"
+
+#include "CachedResource.h"
+#include "DiskCacheMonitorCocoa.h"
+#include "ResourceHandle.h"
+#include "ResourceLoader.h"
+#include "SharedBuffer.h"
+
+@interface NSCachedURLResponse (Details)
+-(CFCachedURLResponseRef)_CFCachedURLResponse;
+@end
+
+namespace WebCore {
+
+#if USE(CFNETWORK)
+
+CFCachedURLResponseRef SubresourceLoader::willCacheResponse(ResourceHandle* handle, CFCachedURLResponseRef cachedResponse)
+{
+    DiskCacheMonitor::monitorFileBackingStoreCreation(request(), m_resource->sessionID(), cachedResponse);
+    return ResourceLoader::willCacheResponse(handle, cachedResponse);
+}
+
+#else
+
+NSCachedURLResponse* SubresourceLoader::willCacheResponse(ResourceHandle* handle, NSCachedURLResponse* response)
+{
+    DiskCacheMonitor::monitorFileBackingStoreCreation(request(), m_resource->sessionID(), [response _CFCachedURLResponse]);
+    return ResourceLoader::willCacheResponse(handle, response);
+}
+
+#endif
+
+}

Modified: trunk/Source/WebKit2/ChangeLog (172810 => 172811)


--- trunk/Source/WebKit2/ChangeLog	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebKit2/ChangeLog	2014-08-20 21:07:36 UTC (rev 172811)
@@ -1,3 +1,19 @@
+2014-08-20  Pratik Solanki  <[email protected]>
+
+        Move DiskCacheMonitor to WebCore so that WebKit1 clients can use it as well
+        https://bugs.webkit.org/show_bug.cgi?id=135896
+
+        Reviewed by Andreas Kling.
+
+        * NetworkProcess/mac/NetworkDiskCacheMonitor.h:
+            Inherit from WebCore::DiskCacheMonitor which has the bulk of the functionality now.
+        (WebKit::NetworkDiskCacheMonitor::~NetworkDiskCacheMonitor):
+        * NetworkProcess/mac/NetworkDiskCacheMonitor.mm:
+        (WebKit::NetworkDiskCacheMonitor::monitorFileBackingStoreCreation):
+        (WebKit::NetworkDiskCacheMonitor::NetworkDiskCacheMonitor):
+        (WebKit::NetworkDiskCacheMonitor::resourceBecameFileBacked):
+            Override virtual method and send the data to the WebContent process as before.
+
 2014-08-19  Pratik Solanki  <[email protected]>
 
         Remove PurgeableBuffer since it is not very useful any more

Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.h (172810 => 172811)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.h	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.h	2014-08-20 21:07:36 UTC (rev 172811)
@@ -27,8 +27,10 @@
 #define NetworkDiskCacheMonitor_h
 
 #include "MessageSender.h"
+#include <WebCore/DiskCacheMonitorCocoa.h>
 #include <WebCore/ResourceRequest.h>
 #include <WebCore/SessionID.h>
+#include <WebCore/SharedBuffer.h>
 #include <wtf/RunLoop.h>
 
 typedef const struct _CFCachedURLResponse* CFCachedURLResponseRef;
@@ -38,22 +40,21 @@
 class NetworkConnectionToWebProcess;
 class NetworkResourceLoader;
 
-class NetworkDiskCacheMonitor : public IPC::MessageSender {
+class NetworkDiskCacheMonitor final : public WebCore::DiskCacheMonitor, private IPC::MessageSender {
 public:
     static void monitorFileBackingStoreCreation(CFCachedURLResponseRef, NetworkResourceLoader*);
 
-    const WebCore::ResourceRequest& resourceRequest() const { return m_resourceRequest; }
-
 private:
     NetworkDiskCacheMonitor(CFCachedURLResponseRef, NetworkResourceLoader*);
 
+    // WebCore::DiskCacheMonitor
+    virtual void resourceBecameFileBacked(PassRefPtr<WebCore::SharedBuffer>) override;
+
     // IPC::MessageSender
     virtual IPC::Connection* messageSenderConnection() override;
     virtual uint64_t messageSenderDestinationID() override;
 
     RefPtr<NetworkConnectionToWebProcess> m_connectionToWebProcess;
-    WebCore::ResourceRequest m_resourceRequest;
-    WebCore::SessionID m_sessionID;
 };
 
 

Modified: trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.mm (172810 => 172811)


--- trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.mm	2014-08-20 21:04:34 UTC (rev 172810)
+++ trunk/Source/WebKit2/NetworkProcess/mac/NetworkDiskCacheMonitor.mm	2014-08-20 21:07:36 UTC (rev 172811)
@@ -30,7 +30,6 @@
 #import "NetworkProcessConnectionMessages.h"
 #import "NetworkResourceLoader.h"
 #import "WebCoreArgumentCoders.h"
-#import <wtf/PassOwnPtr.h>
 
 #ifdef __has_include
 #if __has_include(<CFNetwork/CFURLCachePriv.h>)
@@ -40,16 +39,10 @@
 
 #if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
 
-typedef void (^CFCachedURLResponseCallBackBlock)(CFCachedURLResponseRef);
-extern "C" void _CFCachedURLResponseSetBecameFileBackedCallBackBlock(CFCachedURLResponseRef, CFCachedURLResponseCallBackBlock, dispatch_queue_t);
-
 using namespace WebCore;
 
 namespace WebKit {
 
-// The maximum number of seconds we'll try to wait for a resource to be disk cached before we forget the request.
-static const double diskCacheMonitorTimeout = 20;
-
 void NetworkDiskCacheMonitor::monitorFileBackingStoreCreation(CFCachedURLResponseRef cachedResponse, NetworkResourceLoader* loader)
 {
     if (!cachedResponse)
@@ -57,43 +50,23 @@
 
     ASSERT(loader);
 
-    new NetworkDiskCacheMonitor(cachedResponse, loader); // Balanced by adoptPtr in the blocks setup in the constructor, one of which is guaranteed to run.
+    new NetworkDiskCacheMonitor(cachedResponse, loader); // Balanced by adoptPtr in the blocks set up in the DiskCacheMonitor constructor, one of which is guaranteed to run.
 }
 
 NetworkDiskCacheMonitor::NetworkDiskCacheMonitor(CFCachedURLResponseRef cachedResponse, NetworkResourceLoader* loader)
-    : m_connectionToWebProcess(loader->connectionToWebProcess())
-    , m_resourceRequest(loader->request())
-    , m_sessionID(loader->sessionID())
+    : DiskCacheMonitor(loader->request(), loader->sessionID(), cachedResponse)
+    , m_connectionToWebProcess(loader->connectionToWebProcess())
 {
-    ASSERT(RunLoop::isMain());
+}
 
-    // Set up a delayed callback to cancel this monitor if the resource hasn't been cached yet.
-    __block NetworkDiskCacheMonitor* rawMonitor = this;
+void NetworkDiskCacheMonitor::resourceBecameFileBacked(PassRefPtr<SharedBuffer> fileBackedBuffer)
+{
+    ShareableResource::Handle handle;
+    NetworkResourceLoader::tryGetShareableHandleFromSharedBuffer(handle, fileBackedBuffer.get());
+    if (handle.isNull())
+        return;
 
-    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * diskCacheMonitorTimeout), dispatch_get_main_queue(), ^{
-        adoptPtr(rawMonitor); // Balanced by `new NetworkDiskCacheMonitor` in monitorFileBackingStoreCreation.
-        rawMonitor = 0;
-    });
-
-    // Set up the disk caching callback to create the ShareableResource and send it to the WebProcess.
-    CFCachedURLResponseCallBackBlock block = ^(CFCachedURLResponseRef cachedResponse)
-    {
-        // If the monitor isn't there then it timed out before this resource was cached to disk.
-        if (!rawMonitor)
-            return;
-
-        OwnPtr<NetworkDiskCacheMonitor> monitor = adoptPtr(rawMonitor); // Balanced by `new NetworkDiskCacheMonitor` in monitorFileBackingStoreCreation.
-        rawMonitor = 0;
-
-        ShareableResource::Handle handle;
-        NetworkResourceLoader::tryGetShareableHandleFromCFURLCachedResponse(handle, cachedResponse);
-        if (handle.isNull())
-            return;
-
-        monitor->send(Messages::NetworkProcessConnection::DidCacheResource(monitor->resourceRequest(), handle, m_sessionID));
-    };
-
-    _CFCachedURLResponseSetBecameFileBackedCallBackBlock(cachedResponse, block, dispatch_get_main_queue());
+    send(Messages::NetworkProcessConnection::DidCacheResource(resourceRequest(), handle, sessionID()));
 }
 
 IPC::Connection* NetworkDiskCacheMonitor::messageSenderConnection()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to