[Windows WebKit2] Use cookies set in WebKit1
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2011 23:49:04 +0000 (23:49 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 May 2011 23:49:04 +0000 (23:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=60274

Reviewed by Steve Falkenburg.

Source/WebCore:

Share the default storage session between the UI and Web Processes.

* platform/network/cf/CookieStorageCFNet.cpp:
(WebCore::defaultSessionCookieStorage):
Keep track of the default storage session cookie storage.
(WebCore::currentCookieStorage):
Call defaultCookieStorage to get the default cookie storage.
(WebCore::defaultCookieStorage):
If there is a default storage session cookie storage, prefer that over getting the default
cookie storage. In the Web Process, asking CFNetwork for the default cookie storage directly
without specifying a storage session will not get the cookie storage being shared by the UI
and Web Processes.

* platform/network/ResourceHandle.h:
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::willSendRequest):
Make sure to set the current storage session on any requests used by the Web
Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
doing anything with the Web Process's default storage session (which is not the one shared
with the UI Process).
(WebCore::makeFinalRequest):
Ditto.
(WebCore::ResourceHandle::willSendRequest):
Ditto.
(WebCore::ResourceHandle::currentStorageSession):
If there is a Private Browsing storage session, return that.
If not, on Windows return the default storage session that is being shared with the UI
Process and on Mac return 0.
(WebCore::defaultCFURLStorageSession):
(WebCore::ResourceHandle::setDefaultStorageSession):
(WebCore::ResourceHandle::defaultStorageSession):

* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::ResourceRequest::doUpdatePlatformRequest):
Make sure to set the current storage session on any requests used by the Web
Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
doing anything with the Web Process's default storage session (which is not the one shared
with the UI Process).

Source/WebKit/win:

* WebView.cpp:
(WebView::setCacheModel):
Pass 0 to wkCopyFoundationCacheDirectory so that it uses the default session.

Source/WebKit2:

Share the default storage session between the UI and Web Processes.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
Only encode the session parameter if it is valid.
(WebKit::WebProcessCreationParameters::decode):
Don't try to decode a null session data.
* Shared/WebProcessCreationParameters.h:
Add a parameter for a serialized default storage session, used only on Windows.

* Shared/win/WebCoreArgumentCodersWin.cpp:
(CoreIPC::decodeResourceRequest):
Make sure to set the current storage session on any requests used by the Web
Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
doing anything with the Web Process's default storage session.

* UIProcess/win/WebContextWin.cpp:
(WebKit::WebContext::platformInitializeWebProcess):
Serialize the default storage session in the UI Process and add it to the
WebProcessCreationParameters.

* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::cachedResponseForURL):
Use the cache associated with the current storage session and make sure the request has the
current storage session set on it before doing anything with it.

* WebProcess/win/WebProcessWin.cpp:
(WebKit::WebProcess::platformSetCacheModel):
Use the default storage session.
(WebKit::WebProcess::platformClearResourceCaches):
Ditto.
(WebKit::WebProcess::platformInitializeWebProcess):
Deserialize the default storage session passed in by the UI Process and hand it to the
ResourceHandle.

WebKitLibraries:

Take 3 after rolling out KB2465367 from my system.

* win/include/WebKitSystemInterface/WebKitSystemInterface.h:
* win/lib/WebKitSystemInterface.lib:

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/Shared/win/WebCoreArgumentCodersWin.cpp
Source/WebKit2/UIProcess/win/WebContextWin.cpp
Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
Source/WebKit2/WebProcess/win/WebProcessWin.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
WebKitLibraries/win/lib/WebKitSystemInterface.lib

index 2c529f9595c55aaaae6088c16228ed211eab04fb..246c4c85d609fc251d0194ba184da9011b4cd70f 100644 (file)
@@ -1,3 +1,49 @@
+2011-05-11  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        Share the default storage session between the UI and Web Processes.
+
+        * platform/network/cf/CookieStorageCFNet.cpp:
+        (WebCore::defaultSessionCookieStorage):
+        Keep track of the default storage session cookie storage.
+        (WebCore::currentCookieStorage):
+        Call defaultCookieStorage to get the default cookie storage.
+        (WebCore::defaultCookieStorage):
+        If there is a default storage session cookie storage, prefer that over getting the default
+        cookie storage. In the Web Process, asking CFNetwork for the default cookie storage directly
+        without specifying a storage session will not get the cookie storage being shared by the UI
+        and Web Processes.
+
+        * platform/network/ResourceHandle.h:
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::willSendRequest):
+        Make sure to set the current storage session on any requests used by the Web
+        Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
+        doing anything with the Web Process's default storage session (which is not the one shared
+        with the UI Process).
+        (WebCore::makeFinalRequest):
+        Ditto.
+        (WebCore::ResourceHandle::willSendRequest):
+        Ditto.
+        (WebCore::ResourceHandle::currentStorageSession):
+        If there is a Private Browsing storage session, return that.
+        If not, on Windows return the default storage session that is being shared with the UI
+        Process and on Mac return 0.
+        (WebCore::defaultCFURLStorageSession):
+        (WebCore::ResourceHandle::setDefaultStorageSession):
+        (WebCore::ResourceHandle::defaultStorageSession):
+
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        Make sure to set the current storage session on any requests used by the Web
+        Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
+        doing anything with the Web Process's default storage session (which is not the one shared
+        with the UI Process).
+
 2011-05-11  Lucas De Marchi  <lucas.demarchi@profusion.mobi>
 
         Reviewed by David Kilzer.
index d82a9e4d759c2ea6382808d6bf0d8b183fdc17fc..6ca150948c82fae0da4a62981661ca4adcd7154d 100644 (file)
@@ -194,7 +194,12 @@ public:
     static void setPrivateBrowsingEnabled(bool);
     static CFURLStorageSessionRef privateBrowsingStorageSession();
     static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
-#endif
+    static CFURLStorageSessionRef currentStorageSession();
+#if PLATFORM(WIN)
+    static void setDefaultStorageSession(CFURLStorageSessionRef);
+    static CFURLStorageSessionRef defaultStorageSession();
+#endif // PLATFORM(WIN)
+#endif // USE(CFURLSTORAGESESSIONS)
 
     using RefCounted<ResourceHandle>::ref;
     using RefCounted<ResourceHandle>::deref;
index 3aa52152164a89e761dd3413b542831723717862..f8d5ee3183c774515b560e20b93695af4cd66aaa 100644 (file)
@@ -62,13 +62,23 @@ RetainPtr<CFHTTPCookieStorageRef>& privateBrowsingCookieStorage()
 
 #if USE(CFNETWORK)
 
+static RetainPtr<CFHTTPCookieStorageRef>& defaultSessionCookieStorage()
+{
+    DEFINE_STATIC_LOCAL(RetainPtr<CFHTTPCookieStorageRef>, cookieStorage, ());
+#if USE(CFURLSTORAGESESSIONS) && PLATFORM(WIN)
+    if (!cookieStorage && ResourceHandle::defaultStorageSession())
+        cookieStorage.adoptCF(wkCopyHTTPCookieStorage(ResourceHandle::defaultStorageSession()));
+#endif
+    return cookieStorage;
+}
+
 CFHTTPCookieStorageRef currentCookieStorage()
 {
     ASSERT(isMainThread());
 
     if (CFHTTPCookieStorageRef cookieStorage = privateBrowsingCookieStorage().get())
         return cookieStorage;
-    return wkGetDefaultHTTPCookieStorage();
+    return defaultCookieStorage();
 }
 
 void setCurrentCookieStorage(CFHTTPCookieStorageRef cookieStorage)
@@ -97,6 +107,8 @@ void setCookieStoragePrivateBrowsingEnabled(bool enabled)
 
 CFHTTPCookieStorageRef defaultCookieStorage()
 {
+    if (CFHTTPCookieStorageRef defaultCookieStorage = defaultSessionCookieStorage().get())
+        return defaultCookieStorage;
     return wkGetDefaultHTTPCookieStorage();
 }
 
index 4678dfe91a4ecba9620b20a5394424da1de92ebb..3f590d184e90ab567a3f675d57b41dc3e9364e1d 100644 (file)
@@ -148,6 +148,9 @@ CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef cfReque
             RetainPtr<CFStringRef> newMethod(AdoptCF, CFURLRequestCopyHTTPRequestMethod(cfRequest));
             if (CFStringCompareWithOptions(lastHTTPMethod.get(), newMethod.get(), CFRangeMake(0, CFStringGetLength(lastHTTPMethod.get())), kCFCompareCaseInsensitive)) {
                 RetainPtr<CFMutableURLRequestRef> mutableRequest(AdoptCF, CFURLRequestCreateMutableCopy(0, cfRequest));
+#if USE(CFURLSTORAGESESSIONS)
+                wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), mutableRequest.get());
+#endif
                 CFURLRequestSetHTTPRequestMethod(mutableRequest.get(), lastHTTPMethod.get());
 
                 FormData* body = handle->firstRequest().httpBody();
@@ -340,10 +343,8 @@ CFArrayRef arrayFromFormData(const FormData& d)
 static CFURLRequestRef makeFinalRequest(const ResourceRequest& request, bool shouldContentSniff)
 {
     CFMutableURLRequestRef newRequest = CFURLRequestCreateMutableCopy(kCFAllocatorDefault, request.cfURLRequest());
-
 #if USE(CFURLSTORAGESESSIONS)
-    if (CFURLStorageSessionRef storageSession = ResourceHandle::privateBrowsingStorageSession())
-        wkSetRequestStorageSession(storageSession, newRequest);
+    wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), newRequest);
 #endif
     
     if (!shouldContentSniff)
@@ -493,8 +494,7 @@ void ResourceHandle::willSendRequest(ResourceRequest& request, const ResourceRes
         request.clearHTTPAuthorization();
 
 #if USE(CFURLSTORAGESESSIONS)
-    if (CFURLStorageSessionRef storageSession = privateBrowsingStorageSession())
-        request.setStorageSession(storageSession);
+     request.setStorageSession(ResourceHandle::currentStorageSession());
 #endif
 
     client()->willSendRequest(this, request, redirectResponse);
@@ -744,7 +744,38 @@ String ResourceHandle::privateBrowsingStorageSessionIdentifierDefaultBase()
     return String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey)));
 }
 
+CFURLStorageSessionRef ResourceHandle::currentStorageSession()
+{
+    if (CFURLStorageSessionRef privateStorageSession = privateBrowsingStorageSession())
+        return privateStorageSession;
+#if PLATFORM(WIN)
+    return defaultStorageSession();
+#else
+    return 0;
 #endif
+}
+
+#if PLATFORM(WIN)
+
+static RetainPtr<CFURLStorageSessionRef>& defaultCFURLStorageSession()
+{
+    DEFINE_STATIC_LOCAL(RetainPtr<CFURLStorageSessionRef>, storageSession, ());
+    return storageSession;
+}
+
+void ResourceHandle::setDefaultStorageSession(CFURLStorageSessionRef storageSession)
+{
+    defaultCFURLStorageSession().adoptCF(storageSession);
+}
+
+CFURLStorageSessionRef ResourceHandle::defaultStorageSession()
+{
+    return defaultCFURLStorageSession().get();
+}
+
+#endif // PLATFORM(WIN)
+
+#endif // USE(CFURLSTORAGESESSIONS)
 
 void WebCoreSynchronousLoaderClient::willSendRequest(ResourceHandle* handle, ResourceRequest& request, const ResourceResponse& /*redirectResponse*/)
 {
index e90ab4fe0c95f3da3aec59c320e4af64d7ada4f7..374ab85c38fd8568e7790199c4a4266aa7901ade 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "ResourceRequestCFNet.h"
 
+#include "ResourceHandle.h"
 #include "ResourceRequest.h"
 
 #if PLATFORM(MAC)
@@ -123,9 +124,11 @@ void ResourceRequest::doUpdatePlatformRequest()
         CFURLRequestSetMainDocumentURL(cfRequest, firstPartyForCookies.get());
         CFURLRequestSetCachePolicy(cfRequest, (CFURLRequestCachePolicy)cachePolicy());
         CFURLRequestSetTimeoutInterval(cfRequest, timeoutInterval());
-    } else {
+    } else
         cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), firstPartyForCookies.get());
-    }
+#if USE(CFURLSTORAGESESSIONS)
+    wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), cfRequest);
+#endif
 
     RetainPtr<CFStringRef> requestMethod(AdoptCF, httpMethod().createCFString());
     CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod.get());
index 122cf29d8da6234798f07e9bf0f1e160872f3fdb..05a80a7830a11e10c76a59371e1120e7b8b50495 100644 (file)
@@ -1,3 +1,14 @@
+2011-05-11  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        * WebView.cpp:
+        (WebView::setCacheModel):
+        Pass 0 to wkCopyFoundationCacheDirectory so that it uses the default session.
+
 2011-05-11  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r86255.
index 89815f9b6699d58efbb83b46a62f36b7fc2e5f5f..41f1ef5a0a2fdb8e30030cc29ea7ce7159af3228 100644 (file)
@@ -452,7 +452,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
         return;
 
     RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
-    RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory());
+    RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory(0));
     if (!cfurlCacheDirectory)
         cfurlCacheDirectory.adoptCF(WebCore::localUserSpecificStorageDirectory().createCFString());
 
index 0fbf5ccbe731ff61cfa3531eb880a7ab6efebd4f..93b46f90f137dfbdbbe5dd59a6aefca05b4ebbea 100644 (file)
@@ -1,3 +1,45 @@
+2011-05-11  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        Share the default storage session between the UI and Web Processes.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        Only encode the session parameter if it is valid.
+        (WebKit::WebProcessCreationParameters::decode):
+        Don't try to decode a null session data. 
+        * Shared/WebProcessCreationParameters.h:
+        Add a parameter for a serialized default storage session, used only on Windows.
+
+        * Shared/win/WebCoreArgumentCodersWin.cpp:
+        (CoreIPC::decodeResourceRequest):
+        Make sure to set the current storage session on any requests used by the Web
+        Process before CFNetwork has to do anything with them, in order for CFNetwork to avoid
+        doing anything with the Web Process's default storage session.
+
+        * UIProcess/win/WebContextWin.cpp:
+        (WebKit::WebContext::platformInitializeWebProcess):
+        Serialize the default storage session in the UI Process and add it to the
+        WebProcessCreationParameters.
+
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::cachedResponseForURL):
+        Use the cache associated with the current storage session and make sure the request has the
+        current storage session set on it before doing anything with it.
+
+        * WebProcess/win/WebProcessWin.cpp:
+        (WebKit::WebProcess::platformSetCacheModel):
+        Use the default storage session.
+        (WebKit::WebProcess::platformClearResourceCaches):
+        Ditto.
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        Deserialize the default storage session passed in by the UI Process and hand it to the
+        ResourceHandle.
+
 2011-05-11  Jia Pu  <jpu@apple.com>
 
         Reviewed by Darin Adler.
index f29ef1ae04e1129287343a7fda6fc84b9745fb9f..5c7fc7032d3ea8f628675727c0d357740d493fec 100644 (file)
@@ -27,6 +27,9 @@
 #include "WebProcessCreationParameters.h"
 
 #include "ArgumentCoders.h"
+#if USE(CFURLSTORAGESESSIONS) && PLATFORM(WIN)
+#include "ArgumentCodersCF.h"
+#endif
 
 namespace WebKit {
 
@@ -79,6 +82,10 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(cfURLCacheDiskCapacity);
     encoder->encode(cfURLCacheMemoryCapacity);
     encoder->encode(initialHTTPCookieAcceptPolicy);
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFDataRef data = serializedDefaultStorageSession.get())
+        CoreIPC::encode(encoder, data);
+#endif // USE(CFURLSTORAGESESSIONS)
 #endif
 }
 
@@ -149,6 +156,10 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         return false;
     if (!decoder->decode(parameters.initialHTTPCookieAcceptPolicy))
         return false;
+#if USE(CFURLSTORAGESESSIONS)
+    if (parameters.serializedDefaultStorageSession && !CoreIPC::decode(decoder, parameters.serializedDefaultStorageSession))
+        return false;
+#endif // USE(CFURLSTORAGESESSIONS)
 #endif
 
     return true;
index 62ceaf9ce0763be9744b447795d4d9cae686bb66..e00ca55690b12add3ea85e8a0ea3932282854c2a 100644 (file)
@@ -29,6 +29,7 @@
 #include "CacheModel.h"
 #include "SandboxExtension.h"
 #include "TextCheckerState.h"
+#include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -103,7 +104,11 @@ struct WebProcessCreationParameters {
     uint32_t initialHTTPCookieAcceptPolicy;
 
     bool shouldPaintNativeControls;
-#endif
+
+#if USE(CFURLSTORAGESESSIONS)
+    RetainPtr<CFDataRef> serializedDefaultStorageSession;
+#endif // USE(CFURLSTORAGESESSIONS)
+#endif // PLATFORM(WIN)
 };
 
 } // namespace WebKit
index d659ac45c80f6a8a8e0bb4dbe25aa88e031d2dce..2d9defd27f5bab869ae4620ebc78b28e0c3e390b 100644 (file)
@@ -29,7 +29,9 @@
 #if USE(CFNETWORK)
 #include "ArgumentCodersCF.h"
 #include "PlatformCertificateInfo.h"
+#include <CFNetwork/CFURLRequestPriv.h>
 #include <WebCore/CertificateCFWin.h>
+#include <WebCore/ResourceHandle.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #endif
 
@@ -70,8 +72,13 @@ bool decodeResourceRequest(ArgumentDecoder* decoder, WebCore::ResourceRequest& r
     CFURLRequestRef cfURLRequest = wkCFURLRequestCreateFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
     if (!cfURLRequest)
         return false;
+    CFMutableURLRequestRef mutableCFURLRequest = CFURLRequestCreateMutableCopy(0, cfURLRequest);
+    CFRelease(cfURLRequest);
+#if USE(CFURLSTORAGESESSIONS)
+    wkSetRequestStorageSession(WebCore::ResourceHandle::currentStorageSession(), mutableCFURLRequest);
+#endif
 
-    resourceRequest = WebCore::ResourceRequest(cfURLRequest);
+    resourceRequest = WebCore::ResourceRequest(mutableCFURLRequest);
     return true;
 #else
     return false;
index c1c2a00e78783d481648eb4bffa994631b3d0338..9964de06c72840e48cadddb2f031f968b5a4cba3 100644 (file)
@@ -60,7 +60,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
     parameters.cfURLCacheDiskCapacity = CFURLCacheDiskCapacity(cfurlCache.get());
     parameters.cfURLCacheMemoryCapacity = CFURLCacheMemoryCapacity(cfurlCache.get());
 
-    RetainPtr<CFStringRef> cfURLCachePath(AdoptCF, wkCopyFoundationCacheDirectory());
+    RetainPtr<CFStringRef> cfURLCachePath(AdoptCF, wkCopyFoundationCacheDirectory(0));
     parameters.cfURLCachePath = String(cfURLCachePath.get());
     // Remove the ending '\' (necessary to have CFNetwork find the Cache file).
     ASSERT(parameters.cfURLCachePath.length());
@@ -69,6 +69,7 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
 
 #if USE(CFURLSTORAGESESSIONS)
     parameters.uiProcessBundleIdentifier = String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey)));
+    parameters.serializedDefaultStorageSession.adoptCF(wkCopySerializedDefaultStorageSession());
 #endif // USE(CFURLSTORAGESESSIONS)
 
     parameters.initialHTTPCookieAcceptPolicy = m_initialHTTPCookieAcceptPolicy;
index dcf748fbfef49f4477d78d55f1cd969413f8c017..33ea9c87c4d8c4338268903e2a3ef93c5e8d122a 100644 (file)
@@ -267,14 +267,17 @@ static RetainPtr<CFCachedURLResponseRef> cachedResponseForURL(WebPage* webPage,
 {
     RetainPtr<CFURLRef> cfURL(AdoptCF, url.createCFURL());
     RetainPtr<CFMutableURLRequestRef> request(AdoptCF, CFURLRequestCreateMutable(0, cfURL.get(), kCFURLRequestCachePolicyReloadIgnoringCache, 60, 0));
+#if USE(CFURLSTORAGESESSIONS)
+    wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), request.get());
+#endif
 
     RetainPtr<CFStringRef> userAgent(AdoptCF, webPage->userAgent().createCFString());
     CFURLRequestSetHTTPHeaderFieldValue(request.get(), CFSTR("User-Agent"), userAgent.get());
 
     RetainPtr<CFURLCacheRef> cache;
 #if USE(CFURLSTORAGESESSIONS)
-    if (CFURLStorageSessionRef storageSession = ResourceHandle::privateBrowsingStorageSession())
-        cache.adoptCF(wkCopyURLCache(storageSession));
+    if (CFURLStorageSessionRef currentStorageSession = ResourceHandle::currentStorageSession())
+        cache.adoptCF(wkCopyURLCache(currentStorageSession));
     else
 #endif
         cache.adoptCF(CFURLCacheCopySharedURLCache());
index d9a4af547363bcfb73cf635d1643f6f2fdfd0c39..b9c36667c947f295630398723ba9009fc750c4f6 100644 (file)
@@ -32,6 +32,7 @@
 #include <WebCore/FileSystem.h>
 #include <WebCore/MemoryCache.h>
 #include <WebCore/PageCache.h>
+#include <WebCore/ResourceHandle.h>
 #include <WebCore/Settings.h>
 #include <wtf/text/WTFString.h>
 
@@ -69,7 +70,14 @@ static uint64_t volumeFreeSize(CFStringRef cfstringPath)
 void WebProcess::platformSetCacheModel(CacheModel cacheModel)
 {
 #if USE(CFNETWORK)
-    RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory());
+    RetainPtr<CFStringRef> cfurlCacheDirectory;
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession())
+        cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(defaultStorageSession));
+    else
+#endif
+        cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(0));
+
     if (!cfurlCacheDirectory)
         cfurlCacheDirectory.adoptCF(WebCore::localUserSpecificStorageDirectory().createCFString());
 
@@ -94,7 +102,14 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
     memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
     pageCache()->setCapacity(pageCacheCapacity);
 
-    RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
+    RetainPtr<CFURLCacheRef> cfurlCache;
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession())
+        cfurlCache.adoptCF(wkCopyURLCache(defaultStorageSession));
+    else
+#endif // USE(CFURLSTORAGESESSIONS)
+        cfurlCache.adoptCF(CFURLCacheCopySharedURLCache());
+
     CFURLCacheSetMemoryCapacity(cfurlCache.get(), urlCacheMemoryCapacity);
     CFURLCacheSetDiskCapacity(cfurlCache.get(), max<unsigned long>(urlCacheDiskCapacity, CFURLCacheDiskCapacity(cfurlCache.get()))); // Don't shrink a big disk cache, since that would cause churn.
 #endif
@@ -105,8 +120,17 @@ void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear
 #if USE(CFNETWORK)
     if (cachesToClear == InMemoryResourceCachesOnly)
         return;
-    CFURLCacheRemoveAllCachedResponses(RetainPtr<CFURLCacheRef>(AdoptCF, CFURLCacheCopySharedURLCache()).get());
-#endif
+
+    RetainPtr<CFURLCacheRef> cache;
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = ResourceHandle::defaultStorageSession())
+        cache.adoptCF(wkCopyURLCache(defaultStorageSession));
+    else
+#endif // USE(CFURLSTORAGESESSIONS)
+        cache.adoptCF(CFURLCacheCopySharedURLCache());
+
+    CFURLCacheRemoveAllCachedResponses(cache.get());
+#endif // USE(CFNETWORK)
 }
 
 void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters& parameters, CoreIPC::ArgumentDecoder*)
@@ -114,6 +138,13 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     setShouldPaintNativeControls(parameters.shouldPaintNativeControls);
 
 #if USE(CFNETWORK)
+#if USE(CFURLSTORAGESESSIONS)
+    if (CFURLStorageSessionRef defaultStorageSession = wkDeserializeStorageSession(parameters.serializedDefaultStorageSession.get())) {
+        ResourceHandle::setDefaultStorageSession(defaultStorageSession);
+        return;
+    }
+#endif // USE(CFURLSTORAGESESSIONS)
+
     RetainPtr<CFStringRef> cachePath(AdoptCF, parameters.cfURLCachePath.createCFString());
     if (!cachePath)
         return;
@@ -122,7 +153,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     CFIndex cacheMemoryCapacity = parameters.cfURLCacheMemoryCapacity;
     RetainPtr<CFURLCacheRef> uiProcessCache(AdoptCF, CFURLCacheCreate(kCFAllocatorDefault, cacheMemoryCapacity, cacheDiskCapacity, cachePath.get()));
     CFURLCacheSetSharedURLCache(uiProcessCache.get());
-#endif
+#endif // USE(CFNETWORK)
 
     WebCookieManager::shared().setHTTPCookieAcceptPolicy(parameters.initialHTTPCookieAcceptPolicy);
 }
index 7346bc98e8d05eaf195f467b6d179fda19f257ee..9966a567e8bd9ec3a580c7e1825da86899c53c4c 100644 (file)
@@ -1,3 +1,15 @@
+2011-05-11  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Steve Falkenburg.
+
+        [Windows WebKit2] Use cookies set in WebKit1
+        https://bugs.webkit.org/show_bug.cgi?id=60274
+
+        Take 3 after rolling out KB2465367 from my system.
+
+        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
+        * win/lib/WebKitSystemInterface.lib:
+
 2011-05-11  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r86255.
index b2cda98a73e8d4f4bf4a82645b713fb795d442a1..6cf90d8237041bfa5b9ea53c0d4b0fac26b0513e 100644 (file)
@@ -93,7 +93,7 @@ void* wkGetSSLCertificateChainContext(CFDictionaryRef);
 CFHTTPCookieStorageRef wkGetDefaultHTTPCookieStorage();
 CFHTTPCookieStorageRef wkCreateInMemoryHTTPCookieStorage();
 void wkSetCFURLRequestShouldContentSniff(CFMutableURLRequestRef, bool);
-CFStringRef wkCopyFoundationCacheDirectory();
+CFStringRef wkCopyFoundationCacheDirectory(CFURLStorageSessionRef);
 void wkSetClientCertificateInSSLProperties(CFMutableDictionaryRef, CFDataRef);
 
 CFArrayRef wkCFURLRequestCopyHTTPRequestBodyParts(CFURLRequestRef);
@@ -103,6 +103,8 @@ CFURLStorageSessionRef wkCreatePrivateStorageSession(CFStringRef identifier);
 void wkSetRequestStorageSession(CFURLStorageSessionRef, CFMutableURLRequestRef);
 CFURLCacheRef wkCopyURLCache(CFURLStorageSessionRef);
 CFHTTPCookieStorageRef wkCopyHTTPCookieStorage(CFURLStorageSessionRef);
+CFDataRef wkCopySerializedDefaultStorageSession();
+CFURLStorageSessionRef wkDeserializeStorageSession(CFDataRef);
 
 CFArrayRef wkCFURLCacheCopyAllHostNamesInPersistentStore();
 void wkCFURLCacheDeleteHostNamesInPersistentStore(CFArrayRef hostNames);
index a33fb2ec0f3ac6a5cc1eab4a21dea2b3f69ac9c2..b1fe6a2a380436b48fc2f6af1b7cd7c44d8f6a96 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface.lib differ