Add a separate class for networking related storage
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Dec 2012 02:15:18 +0000 (02:15 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Dec 2012 02:15:18 +0000 (02:15 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=105676

        Reviewed by Sam Weinig.

        NetworkingContext combines a reference to storage (cookies and more) and data that's
        only meaningful when loading. This makes it very ugly to use for cookie manipulation
        when there is no load (e.g. for document.cookie).

        Adding NetworkStorageSession, which encorportes network-related sesion data, such
        as cookies and session HTTP credentials.

        For some ports, refactoring is not finished, NetworkStorageSession being a wrapper
        for NetworkingContext.

        * CMakeLists.txt:
        * GNUmakefile.list.am:
        * Target.pri:
        * WebCore.exp.in:
        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        Updated for new files and functions.

        * platform/network/PlatformCookieJar.h:
        * loader/CookieJar.cpp:
        * platform/CookiesStrategy.h:
        * platform/network/cf/CookieJarCFNet.cpp:
        * platform/network/chromium/CookieJarChromium.cpp:
        * platform/network/curl/CookieJarCurl.cpp:
        * platform/network/mac/CookieJarMac.mm:
        * platform/network/qt/CookieJarQt.cpp:
        * platform/network/soup/CookieJarSoup.cpp:
        * platform/network/win/CookieJarWin.cpp:
        PlatformCookieJar and strategy cookie functions now take a NetworkStorageSession
        instead of NetworkingContext.
        Note that they take a const reference to support creating a temporary session
        wrapper for ports that just wrap a NetworkingContext.

        * loader/ResourceLoader.cpp:
        * loader/cache/CachedResource.h:
        * platform/network/BlobResourceHandle.cpp:
        * platform/network/ResourceHandle.cpp:
        * platform/network/ResourceHandle.h:
        * platform/network/ResourceHandleInternal.h:
        * platform/network/chromium/ResourceHandle.cpp:
        * platform/network/curl/ResourceHandleCurl.cpp:
        * platform/network/mac/ResourceHandleMac.mm:
        * platform/network/qt/QNetworkReplyHandler.cpp:
        * platform/network/soup/DNSSoup.cpp:
        * platform/network/soup/ResourceHandleSoup.cpp:
        * platform/network/win/ResourceHandleWin.cpp:
        ResourceHandle no longer includes unneeded NetworkingContext.h and AuthenticationClient.h.
        This avoids near-world rebuilds on any NetworkingContext change.

        * platform/network/NetworkStorageSession.h: Added.
        * platform/network/NetworkStorageSessionStub.cpp: Added.
        * platform/network/cf/NetworkStorageSessionCFNet.cpp: Added.
        Good new stuff. Stub version just wraps NetworkingContext for platforms that still
        need to finish the refactoring.

        * platform/network/NetworkingContext.h:
        The context now has a NetworkStorageSession, and doesn't expose CFNet level objects directly.

        * platform/network/cf/CookieStorageCFNet.cpp:
        * platform/network/cf/CookieStorageCFNet.h: Removed.
        We no longer have separate free functions to track storage, it's part of NetworkStorageSession now.

        * platform/network/cf/ResourceHandleCFNet.cpp: Updated to use NetworkStorageSession.

        * platform/network/mac/CookieStorageMac.mm: Dont include CookieStorageCFNet.h, it
        was not needed.

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

94 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/CookieJar.cpp
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/platform/CookiesStrategy.h
Source/WebCore/platform/network/BlobResourceHandle.cpp
Source/WebCore/platform/network/NetworkStorageSession.h [new file with mode: 0644]
Source/WebCore/platform/network/NetworkStorageSessionStub.cpp [moved from Source/WebKit2/WebProcess/WebCoreSupport/mac/WebPlatformStrategiesMac.mm with 65% similarity]
Source/WebCore/platform/network/NetworkingContext.h
Source/WebCore/platform/network/PlatformCookieJar.h
Source/WebCore/platform/network/ResourceHandle.cpp
Source/WebCore/platform/network/ResourceHandle.h
Source/WebCore/platform/network/ResourceHandleInternal.h
Source/WebCore/platform/network/cf/CookieJarCFNet.cpp
Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp
Source/WebCore/platform/network/cf/CookieStorageCFNet.h [deleted file]
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp [new file with mode: 0644]
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/chromium/CookieJarChromium.cpp
Source/WebCore/platform/network/chromium/ResourceHandle.cpp
Source/WebCore/platform/network/curl/CookieJarCurl.cpp
Source/WebCore/platform/network/curl/ResourceHandleCurl.cpp
Source/WebCore/platform/network/mac/CookieJarMac.mm
Source/WebCore/platform/network/mac/CookieStorageMac.mm
Source/WebCore/platform/network/mac/ResourceHandleMac.mm
Source/WebCore/platform/network/qt/CookieJarQt.cpp
Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
Source/WebCore/platform/network/soup/CookieJarSoup.cpp
Source/WebCore/platform/network/soup/DNSSoup.cpp
Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp
Source/WebCore/platform/network/win/CookieJarWin.cpp
Source/WebCore/platform/network/win/ResourceHandleWin.cpp
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/PlatformStrategiesEfl.cpp
Source/WebKit/efl/WebCoreSupport/PlatformStrategiesEfl.h
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/PlatformStrategiesGtk.cpp
Source/WebKit/gtk/WebCoreSupport/PlatformStrategiesGtk.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.h
Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.cpp
Source/WebKit/qt/WebCoreSupport/PlatformStrategiesQt.h
Source/WebKit/qt/WebCoreSupport/QWebFrameAdapter.cpp
Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCookieManagerCFNet.cpp
Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp
Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.h
Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit/win/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit/win/WebView.cpp
Source/WebKit/wince/ChangeLog
Source/WebKit/wince/WebCoreSupport/PlatformStrategiesWinCE.cpp
Source/WebKit/wince/WebCoreSupport/PlatformStrategiesWinCE.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/NetworkProcess/mac/NetworkProcessMainMac.mm
Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.h
Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm
Source/WebKit2/Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm
Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp
Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp
Source/WebKit2/WebProcess/Downloads/cfnet/DownloadCFNet.cpp
Source/WebKit2/WebProcess/Downloads/efl/DownloadSoupErrorsEfl.cpp
Source/WebKit2/WebProcess/Downloads/gtk/DownloadSoupErrorsGtk.cpp
Source/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm
Source/WebKit2/WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.h
Source/WebKit2/WebProcess/WebPage/WebFrame.cpp
Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/efl/WebProcessMainEfl.cpp
Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp

index 1745933..a6d63a3 100644 (file)
@@ -2028,6 +2028,7 @@ set(WebCore_SOURCES
     platform/network/HTTPValidation.cpp
     platform/network/MIMEHeader.cpp
     platform/network/NetworkStateNotifier.cpp
+    platform/network/NetworkStorageSessionStub.cpp
     platform/network/ParsedContentType.cpp
     platform/network/ProtectionSpace.cpp
     platform/network/ProxyServer.cpp
index fe624e1..303c25c 100644 (file)
@@ -1,3 +1,78 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        NetworkingContext combines a reference to storage (cookies and more) and data that's
+        only meaningful when loading. This makes it very ugly to use for cookie manipulation
+        when there is no load (e.g. for document.cookie).
+
+        Adding NetworkStorageSession, which encorportes network-related sesion data, such
+        as cookies and session HTTP credentials.
+
+        For some ports, refactoring is not finished, NetworkStorageSession being a wrapper
+        for NetworkingContext.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.exp.in:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        Updated for new files and functions.
+
+        * platform/network/PlatformCookieJar.h:
+        * loader/CookieJar.cpp:
+        * platform/CookiesStrategy.h:
+        * platform/network/cf/CookieJarCFNet.cpp:
+        * platform/network/chromium/CookieJarChromium.cpp:
+        * platform/network/curl/CookieJarCurl.cpp:
+        * platform/network/mac/CookieJarMac.mm:
+        * platform/network/qt/CookieJarQt.cpp:
+        * platform/network/soup/CookieJarSoup.cpp:
+        * platform/network/win/CookieJarWin.cpp:
+        PlatformCookieJar and strategy cookie functions now take a NetworkStorageSession
+        instead of NetworkingContext.
+        Note that they take a const reference to support creating a temporary session
+        wrapper for ports that just wrap a NetworkingContext.
+
+        * loader/ResourceLoader.cpp:
+        * loader/cache/CachedResource.h:
+        * platform/network/BlobResourceHandle.cpp:
+        * platform/network/ResourceHandle.cpp:
+        * platform/network/ResourceHandle.h:
+        * platform/network/ResourceHandleInternal.h:
+        * platform/network/chromium/ResourceHandle.cpp:
+        * platform/network/curl/ResourceHandleCurl.cpp:
+        * platform/network/mac/ResourceHandleMac.mm:
+        * platform/network/qt/QNetworkReplyHandler.cpp:
+        * platform/network/soup/DNSSoup.cpp:
+        * platform/network/soup/ResourceHandleSoup.cpp:
+        * platform/network/win/ResourceHandleWin.cpp:
+        ResourceHandle no longer includes unneeded NetworkingContext.h and AuthenticationClient.h.
+        This avoids near-world rebuilds on any NetworkingContext change.
+
+        * platform/network/NetworkStorageSession.h: Added.
+        * platform/network/NetworkStorageSessionStub.cpp: Added.
+        * platform/network/cf/NetworkStorageSessionCFNet.cpp: Added.
+        Good new stuff. Stub version just wraps NetworkingContext for platforms that still
+        need to finish the refactoring.
+
+        * platform/network/NetworkingContext.h:
+        The context now has a NetworkStorageSession, and doesn't expose CFNet level objects directly.
+
+        * platform/network/cf/CookieStorageCFNet.cpp:
+        * platform/network/cf/CookieStorageCFNet.h: Removed.
+        We no longer have separate free functions to track storage, it's part of NetworkStorageSession now.
+
+        * platform/network/cf/ResourceHandleCFNet.cpp: Updated to use NetworkStorageSession.
+
+        * platform/network/mac/CookieStorageMac.mm: Dont include CookieStorageCFNet.h, it
+        was not needed.
+
 2012-12-22  Nico Weber  <thakis@chromium.org>
 
         InlineTextBox: Remove potentially confusing "} if" pattern.
index 18f0487..740b73f 100644 (file)
@@ -5760,6 +5760,7 @@ webcore_platform_sources += \
        Source/WebCore/platform/network/ProxyServer.h \
        Source/WebCore/platform/network/NetworkStateNotifier.cpp \
        Source/WebCore/platform/network/NetworkStateNotifier.h \
+       Source/WebCore/platform/network/NetworkStorageSessionStub.cpp \
        Source/WebCore/platform/network/ParsedContentType.cpp \
        Source/WebCore/platform/network/ParsedContentType.h \
        Source/WebCore/platform/network/PlatformCookieJar.h \
index b1bb8f3..b665b8a 100644 (file)
@@ -1061,6 +1061,7 @@ SOURCES += \
     platform/network/HTTPValidation.cpp \
     platform/network/MIMEHeader.cpp \
     platform/network/NetworkStateNotifier.cpp \
+    platform/network/NetworkStorageSessionStub.cpp \
     platform/network/ParsedContentType.cpp \
     platform/network/ProtectionSpace.cpp \
     platform/network/ProxyServer.cpp \
@@ -2273,6 +2274,7 @@ HEADERS += \
     platform/network/HTTPValidation.h \
     platform/network/HTTPStatusCodes.h \
     platform/network/MIMESniffing.h \
+    platform/network/NetworkStorageSession.h \
     platform/network/NetworkingContext.h \
     platform/network/NetworkStateNotifier.h \
     platform/network/ParsedContentType.h \
index f56dfec..b8183c8 100644 (file)
@@ -207,7 +207,7 @@ __ZN7WebCore12TextIteratorD1Ev
 __ZN7WebCore12cacheStorageEv
 __ZN7WebCore12createMarkupEPKNS_4NodeENS_13EChildrenOnlyEPN3WTF6VectorIPS0_Lm0EEENS_13EAbsoluteURLsEPNS5_INS_13QualifiedNameELm0EEE
 __ZN7WebCore12createMarkupEPKNS_5RangeEPN3WTF6VectorIPNS_4NodeELm0EEENS_23EAnnotateForInterchangeEbNS_13EAbsoluteURLsE
-__ZN7WebCore12deleteCookieEPNS_17NetworkingContextERKNS_4KURLERKN3WTF6StringE
+__ZN7WebCore12deleteCookieERKNS_21NetworkStorageSessionERKNS_4KURLERKN3WTF6StringE
 __ZN7WebCore12gcControllerEv
 __ZN7WebCore12iconDatabaseEv
 __ZN7WebCore12toUint8ArrayEN3JSC7JSValueE
@@ -236,10 +236,10 @@ __ZN7WebCore13ResourceErrorC1EP7NSError
 __ZN7WebCore13ResourceErrorC1EP9__CFError
 __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDERKN3WTF6StringEb
 __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDEdNS_17CSSPrimitiveValue9UnitTypesEb
-__ZN7WebCore13cookiesForDOMEPNS_17NetworkingContextERKNS_4KURLES4_
+__ZN7WebCore13cookiesForDOMERKNS_21NetworkStorageSessionERKNS_4KURLES5_
 __ZN7WebCore13createWrapperEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_4NodeE
 __ZN7WebCore13directoryNameERKN3WTF6StringE
-__ZN7WebCore13getRawCookiesEPNS_17NetworkingContextERKNS_4KURLES4_RN3WTF6VectorINS_6CookieELm0EEE
+__ZN7WebCore13getRawCookiesERKNS_21NetworkStorageSessionERKNS_4KURLES5_RN3WTF6VectorINS_6CookieELm0EEE
 __ZN7WebCore13toArrayBufferEN3JSC7JSValueE
 __ZN7WebCore13toHTMLElementEPNS_21FormAssociatedElementE
 __ZN7WebCore13toJSDOMWindowEN3JSC7JSValueE
@@ -254,6 +254,10 @@ __ZN7WebCore14DocumentLoader13attachToFrameEv
 __ZN7WebCore14DocumentLoader15detachFromFrameEv
 __ZN7WebCore14DocumentLoader18addArchiveResourceEN3WTF10PassRefPtrINS_15ArchiveResourceEEE
 __ZN7WebCore14ResourceLoader32didCancelAuthenticationChallengeERKNS_23AuthenticationChallengeE
+__ZN7WebCore14cookiesEnabledERKNS_21NetworkStorageSessionERKNS_4KURLES5_
+__ZN7WebCore17setCookiesFromDOMERKNS_21NetworkStorageSessionERKNS_4KURLES5_RKN3WTF6StringE
+__ZN7WebCore21NetworkStorageSession21defaultStorageSessionEv
+__ZN7WebCore21NetworkStorageSession25switchToNewTestingSessionEv
 __ZN7WebCore21SerializedScriptValue11deserializeEPN3JSC9ExecStateEPNS1_14JSGlobalObjectEPN3WTF6VectorINS6_6RefPtrINS_11MessagePortEEELm1EEENS_22SerializationErrorModeE
 __ZN7WebCore21SerializedScriptValue6createEPN3JSC9ExecStateENS1_7JSValueEPN3WTF6VectorINS5_6RefPtrINS_11MessagePortEEELm1EEEPNS6_INS7_INS5_11ArrayBufferEEELm1EEENS_22SerializationErrorModeE
 __ZN7WebCore21SerializedScriptValue6createERKN3WTF6StringE
@@ -284,7 +288,6 @@ __ZN7WebCore14FrameSelection9selectAllEv
 __ZN7WebCore14FrameSelectionC1EPNS_5FrameE
 __ZN7WebCore14LoaderStrategy21resourceLoadSchedulerEv
 __ZN7WebCore14PluginDocument10pluginNodeEv
-__ZN7WebCore14cookiesEnabledEPNS_17NetworkingContextERKNS_4KURLES4_
 __ZNK7WebCore5Frame25trackedRepaintRectsAsTextEv
 __ZN7WebCore9FrameView17setTracksRepaintsEb
 __ZN7WebCore9FrameView20resetTrackedRepaintsEv
@@ -488,7 +491,7 @@ __ZN7WebCore16VisibleSelectionC1ERKNS_15VisiblePositionES3_b
 __ZN7WebCore16VisibleSelectionC1ERKNS_15VisiblePositionEb
 __ZN7WebCore16createFullMarkupEPKNS_4NodeE
 __ZN7WebCore16createFullMarkupEPKNS_5RangeE
-__ZN7WebCore16deleteAllCookiesEPNS_17NetworkingContextE
+__ZN7WebCore16deleteAllCookiesERKNS_21NetworkStorageSessionE
 __ZN7WebCore16enclosingIntRectERKNS_9FloatRectE
 __ZN7WebCore16isEndOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
 __ZN7WebCore16isUserVisibleURLEP8NSString
@@ -511,7 +514,6 @@ __ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15Re
 __ZN7WebCore17ViewportArguments19deprecatedTargetDPIE
 __ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
 __ZN7WebCore17openTemporaryFileERKN3WTF6StringERi
-__ZN7WebCore17setCookiesFromDOMEPNS_17NetworkingContextERKNS_4KURLES4_RKN3WTF6StringE
 __ZN7WebCore17userVisibleStringEP5NSURL
 __ZN7WebCore18DOMWindowExtensionC1EPNS_5FrameEPNS_15DOMWrapperWorldE
 __ZN7WebCore18HTMLContentElement6createEPNS_8DocumentE
@@ -595,6 +597,7 @@ __ZN7WebCore20protocolIsJavaScriptERKN3WTF6StringE
 __ZN7WebCore20SpaceSplitStringDataD1Ev
 __ZN7WebCore21BackForwardController11itemAtIndexEi
 __ZN7WebCore21MemoryPressureHandler7installEv
+__ZN7WebCore21NetworkStorageSession28createPrivateBrowsingSessionERKN3WTF6StringE
 __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS_13PlatformEvent4TypeEb
 __ZN7WebCore21ResourceLoadScheduler19startResourceLoaderEPNS_14ResourceLoaderE
 __ZN7WebCore21ResourceLoadScheduler20servePendingRequestsENS_20ResourceLoadPriorityE
@@ -650,7 +653,7 @@ __ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0
 __ZN7WebCore23dataForURLComponentTypeEP5NSURLl
 __ZN7WebCore23decodeHostNameWithRangeEP8NSString8_NSRange
 __ZN7WebCore23encodeHostNameWithRangeEP8NSString8_NSRange
-__ZN7WebCore23getHostnamesWithCookiesEPNS_17NetworkingContextERN3WTF7HashSetINS2_6StringENS2_10StringHashENS2_10HashTraitsIS4_EEEE
+__ZN7WebCore23getHostnamesWithCookiesERKNS_21NetworkStorageSessionERN3WTF7HashSetINS3_6StringENS3_10StringHashENS3_10HashTraitsIS5_EEEE
 __ZN7WebCore24BinaryPropertyListWriter17writePropertyListEv
 __ZN7WebCore24CachedResourceHandleBase11setResourceEPNS_14CachedResourceE
 __ZN7WebCore24ComposedShadowTreeWalker10firstChildEv
@@ -669,7 +672,7 @@ __ZN7WebCore24FrameDestructionObserverC2EPNS_5FrameE
 __ZN7WebCore24FrameDestructionObserverD2Ev
 __ZN7WebCore24createFragmentFromMarkupEPNS_8DocumentERKN3WTF6StringES5_NS_27FragmentScriptingPermissionE
 __ZN7WebCore24decodeURLEscapeSequencesERKN3WTF6StringE
-__ZN7WebCore24deleteCookiesForHostnameEPNS_17NetworkingContextERKN3WTF6StringE
+__ZN7WebCore24deleteCookiesForHostnameERKNS_21NetworkStorageSessionERKN3WTF6StringE
 __ZN7WebCore24fileSystemRepresentationERKN3WTF6StringE
 __ZN7WebCore24notifyHistoryItemChangedE
 __ZN7WebCore25HistoryPropertyListWriter11releaseDataEv
@@ -696,10 +699,9 @@ __ZN7WebCore27CSSComputedStyleDeclarationC1EN3WTF10PassRefPtrINS_4NodeEEEbRKNS1_
 __ZN7WebCore27DeviceOrientationClientMock14setOrientationEN3WTF10PassRefPtrINS_21DeviceOrientationDataEEE
 __ZN7WebCore27DeviceOrientationClientMockC1Ev
 __ZN7WebCore27startObservingCookieChangesEv
-__ZN7WebCore26defaultCFHTTPCookieStorageEv
 __ZN7WebCore28encodeWithURLEscapeSequencesERKN3WTF6StringE
 __ZN7WebCore28removeLanguageChangeObserverEPv
-__ZN7WebCore29cookieRequestHeaderFieldValueEPNS_17NetworkingContextERKNS_4KURLES4_
+__ZN7WebCore29cookieRequestHeaderFieldValueERKNS_21NetworkStorageSessionERKNS_4KURLES5_
 __ZN7WebCore29isCharacterSmartReplaceExemptEib
 __ZN7WebCore30hostNameNeedsDecodingWithRangeEP8NSString8_NSRange
 __ZN7WebCore30hostNameNeedsEncodingWithRangeEP8NSString8_NSRange
@@ -1330,6 +1332,7 @@ __ZNK7WebCore20ResourceResponseBase6isHTTPEv
 __ZNK7WebCore20ResourceResponseBase8mimeTypeEv
 __ZNK7WebCore21BackForwardController12forwardCountEv
 __ZNK7WebCore21BackForwardController9backCountEv
+__ZNK7WebCore21NetworkStorageSession13cookieStorageEv
 __ZNK7WebCore21RenderLayerCompositor11scrollLayerEv
 __ZNK7WebCore21RenderLayerCompositor15rootRenderLayerEv
 __ZNK7WebCore21UserContentURLPattern7matchesERKNS_4KURLE
index 3685a98..3b7512f 100644 (file)
             'platform/network/MIMEHeader.cpp',
             'platform/network/NetworkStateNotifier.cpp',
             'platform/network/NetworkStateNotifier.h',
+            'platform/network/NetworkStorageSessionStub.cpp',
             'platform/network/ParsedContentType.cpp',
             'platform/network/ParsedContentType.h',
             'platform/network/ProtectionSpace.cpp',
             'platform/network/cf/AuthenticationCF.h',
             'platform/network/cf/CookieJarCFNet.cpp',
             'platform/network/cf/CookieStorageCFNet.cpp',
-            'platform/network/cf/CookieStorageCFNet.h',
             'platform/network/cf/CredentialStorageCFNet.cpp',
             'platform/network/cf/DNSCFNet.cpp',
             'platform/network/cf/DownloadBundle.h',
index 2f96165..2820d5e 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\platform\network\NetworkStorageSession.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\platform\network\NetworkingContext.h"
                                        >
                                </File>
                                                </FileConfiguration>
                                        </File>
                                        <File
-                                               RelativePath="..\platform\network\cf\CookieStorageCFNet.h"
-                                               >
-                                       </File>
-                                       <File
                                                RelativePath="..\platform\network\cf\CredentialStorageCFNet.cpp"
                                                >
                                                <FileConfiguration
                                                >
                                        </File>
                                        <File
+                                               RelativePath="..\platform\network\cf\NetworkStorageSessionCFNet.cpp"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\platform\network\cf\ProxyServerCFNet.cpp"
                                                >
                                                <FileConfiguration
index ccfb894..90aee06 100644 (file)
                7EE6846112D26E3800E79415 /* AuthenticationChallenge.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6844E12D26E3800E79415 /* AuthenticationChallenge.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7EE6846212D26E3800E79415 /* CookieJarCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EE6844F12D26E3800E79415 /* CookieJarCFNet.cpp */; };
                7EE6846312D26E3800E79415 /* CookieStorageCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EE6845012D26E3800E79415 /* CookieStorageCFNet.cpp */; };
-               7EE6846412D26E3800E79415 /* CookieStorageCFNet.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6845112D26E3800E79415 /* CookieStorageCFNet.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7EE6846512D26E3800E79415 /* CredentialStorageCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EE6845212D26E3800E79415 /* CredentialStorageCFNet.cpp */; };
                7EE6846612D26E3800E79415 /* FormDataStreamCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7EE6845312D26E3800E79415 /* FormDataStreamCFNet.cpp */; };
                7EE6846712D26E3800E79415 /* FormDataStreamCFNet.h in Headers */ = {isa = PBXBuildFile; fileRef = 7EE6845412D26E3800E79415 /* FormDataStreamCFNet.h */; };
                E134F5AB12EE343F004EC58D /* IntRectHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E134F5AA12EE343F004EC58D /* IntRectHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E139866315478474001E3F65 /* StyleResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E139866115478474001E3F65 /* StyleResolver.cpp */; };
                E139866415478474001E3F65 /* StyleResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = E139866215478474001E3F65 /* StyleResolver.h */; };
+               E13EF3441684ECF40034C83F /* NetworkStorageSession.h in Headers */ = {isa = PBXBuildFile; fileRef = E13EF3421684ECF40034C83F /* NetworkStorageSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E13EF34916850C470034C83F /* NetworkStorageSessionCFNet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E13EF34716850C470034C83F /* NetworkStorageSessionCFNet.cpp */; };
                E13F01F11270E19000DFBA71 /* CookieStorageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */; };
                E1424C8A164B3B4E00F32D40 /* PlatformCookieJar.h in Headers */ = {isa = PBXBuildFile; fileRef = E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E1424C90164B460B00F32D40 /* CookieJarMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1424C8F164B460B00F32D40 /* CookieJarMac.mm */; };
                7EE6844E12D26E3800E79415 /* AuthenticationChallenge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuthenticationChallenge.h; sourceTree = "<group>"; };
                7EE6844F12D26E3800E79415 /* CookieJarCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieJarCFNet.cpp; sourceTree = "<group>"; };
                7EE6845012D26E3800E79415 /* CookieStorageCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CookieStorageCFNet.cpp; sourceTree = "<group>"; };
-               7EE6845112D26E3800E79415 /* CookieStorageCFNet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieStorageCFNet.h; sourceTree = "<group>"; };
                7EE6845212D26E3800E79415 /* CredentialStorageCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CredentialStorageCFNet.cpp; sourceTree = "<group>"; };
                7EE6845312D26E3800E79415 /* FormDataStreamCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormDataStreamCFNet.cpp; sourceTree = "<group>"; };
                7EE6845412D26E3800E79415 /* FormDataStreamCFNet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormDataStreamCFNet.h; sourceTree = "<group>"; };
                E134F5AA12EE343F004EC58D /* IntRectHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntRectHash.h; sourceTree = "<group>"; };
                E139866115478474001E3F65 /* StyleResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleResolver.cpp; sourceTree = "<group>"; };
                E139866215478474001E3F65 /* StyleResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleResolver.h; sourceTree = "<group>"; };
+               E13EF3421684ECF40034C83F /* NetworkStorageSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkStorageSession.h; sourceTree = "<group>"; };
+               E13EF34716850C470034C83F /* NetworkStorageSessionCFNet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkStorageSessionCFNet.cpp; sourceTree = "<group>"; };
                E13F01EA1270E10D00DFBA71 /* CookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieStorage.h; sourceTree = "<group>"; };
                E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieStorageMac.mm; sourceTree = "<group>"; };
                E1424C89164B3B4E00F32D40 /* PlatformCookieJar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformCookieJar.h; path = network/PlatformCookieJar.h; sourceTree = "<group>"; };
                                37DDCD9213844FD50008B793 /* MIMEHeader.cpp */,
                                37DDCD9313844FD50008B793 /* MIMEHeader.h */,
                                628D214B12131ED10055DCFC /* NetworkingContext.h */,
+                               E13EF3421684ECF40034C83F /* NetworkStorageSession.h */,
                                1A7FA61A0DDA3BBE0028F8A5 /* NetworkStateNotifier.cpp */,
                                1A7FA6180DDA3B3A0028F8A5 /* NetworkStateNotifier.h */,
                                447958021643B47B001E0A7F /* ParsedContentType.cpp */,
                                7EE6844E12D26E3800E79415 /* AuthenticationChallenge.h */,
                                7EE6844F12D26E3800E79415 /* CookieJarCFNet.cpp */,
                                7EE6845012D26E3800E79415 /* CookieStorageCFNet.cpp */,
-                               7EE6845112D26E3800E79415 /* CookieStorageCFNet.h */,
                                7EE6845212D26E3800E79415 /* CredentialStorageCFNet.cpp */,
                                B2F34FE80E82F82700F627CD /* DNSCFNet.cpp */,
                                7EE6845312D26E3800E79415 /* FormDataStreamCFNet.cpp */,
                                7EE6845412D26E3800E79415 /* FormDataStreamCFNet.h */,
                                7EE6845512D26E3800E79415 /* LoaderRunLoopCF.cpp */,
                                7EE6845612D26E3800E79415 /* LoaderRunLoopCF.h */,
+                               E13EF34716850C470034C83F /* NetworkStorageSessionCFNet.cpp */,
                                1AF8E1C1125673E000230FF7 /* ProxyServerCFNet.cpp */,
                                7EE6845712D26E3800E79415 /* ResourceError.h */,
                                7EE6845812D26E3800E79415 /* ResourceErrorCF.cpp */,
                                D8B6152F1032495100C8554A /* Cookie.h in Headers */,
                                339B5B63131DAA3200F48D02 /* CookiesStrategy.h in Headers */,
                                33D0212D131DB37B004091A8 /* CookieStorage.h in Headers */,
-                               7EE6846412D26E3800E79415 /* CookieStorageCFNet.h in Headers */,
                                FE6FD4880F676E5700092873 /* Coordinates.h in Headers */,
                                A80E6D040A1989CA007FB8C5 /* Counter.h in Headers */,
                                BC5EB9790E82069200B25965 /* CounterContent.h in Headers */,
                                F37A56231679CF7B00C57046 /* HeapGraphSerializer.h in Headers */,
                                0FB8890A167D2FA10010CDA5 /* ScrollingTreeStickyNode.h in Headers */,
                                0FB8890F167D30160010CDA5 /* ScrollingStateStickyNode.h in Headers */,
+                               E13EF3441684ECF40034C83F /* NetworkStorageSession.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                0FB8890B167D2FA10010CDA5 /* ScrollingTreeStickyNode.mm in Sources */,
                                0FB8890E167D30160010CDA5 /* ScrollingStateStickyNode.cpp in Sources */,
                                209B456B16796A7E00E54E4E /* JSCryptoCustom.cpp in Sources */,
+                               E13EF34916850C470034C83F /* NetworkStorageSessionCFNet.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index a117953..34aa9db 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "Document.h"
 #include "Frame.h"
+#include "NetworkingContext.h"
 #include "PlatformCookieJar.h"
 
 #if USE(PLATFORM_STRATEGIES)
@@ -43,6 +44,7 @@ namespace WebCore {
 
 static NetworkingContext* networkingContext(const Document* document)
 {
+    // FIXME: Returning 0 means falling back to default context. That's not a choice that is appropriate to do at runtime
     if (!document)
         return 0;
     Frame* frame = document->frame();
@@ -54,57 +56,68 @@ static NetworkingContext* networkingContext(const Document* document)
     return loader->networkingContext();
 }
 
+#if PLATFORM(MAC) || USE(CFNETWORK)
+inline NetworkStorageSession& storageSession(const Document* document)
+{
+    NetworkingContext* context = networkingContext(document);
+    return context ? context->storageSession() : NetworkStorageSession::defaultStorageSession();
+}
+#define SESSION(document) storageSession(document)
+#else
+#define SESSION(document) NetworkStorageSession(networkingContext(document))
+#endif
+
 String cookies(const Document* document, const KURL& url)
 {
 #if USE(PLATFORM_STRATEGIES)
-    return platformStrategies()->cookiesStrategy()->cookiesForDOM(networkingContext(document), document->firstPartyForCookies(), url);
+    return platformStrategies()->cookiesStrategy()->cookiesForDOM(SESSION(document), document->firstPartyForCookies(), url);
 #else
-    return cookiesForDOM(networkingContext(document), document->firstPartyForCookies(), url);
+    return cookiesForDOM(SESSION(document), document->firstPartyForCookies(), url);
 #endif
 }
 
 void setCookies(Document* document, const KURL& url, const String& cookieString)
 {
 #if USE(PLATFORM_STRATEGIES)
-    platformStrategies()->cookiesStrategy()->setCookiesFromDOM(networkingContext(document), document->firstPartyForCookies(), url, cookieString);
+    platformStrategies()->cookiesStrategy()->setCookiesFromDOM(SESSION(document), document->firstPartyForCookies(), url, cookieString);
 #else
-    setCookiesFromDOM(networkingContext(document), document->firstPartyForCookies(), url, cookieString);
+    setCookiesFromDOM(SESSION(document), document->firstPartyForCookies(), url, cookieString);
 #endif
 }
 
 bool cookiesEnabled(const Document* document)
 {
 #if USE(PLATFORM_STRATEGIES)
-    return platformStrategies()->cookiesStrategy()->cookiesEnabled(networkingContext(document), document->firstPartyForCookies(), document->cookieURL());
+    return platformStrategies()->cookiesStrategy()->cookiesEnabled(SESSION(document), document->firstPartyForCookies(), document->cookieURL());
 #else
-    return cookiesEnabled(networkingContext(document), document->firstPartyForCookies(), document->cookieURL());
+    return cookiesEnabled(SESSION(document), document->firstPartyForCookies(), document->cookieURL());
 #endif
 }
 
 String cookieRequestHeaderFieldValue(const Document* document, const KURL& url)
 {
 #if USE(PLATFORM_STRATEGIES)
-    return platformStrategies()->cookiesStrategy()->cookieRequestHeaderFieldValue(networkingContext(document), document->firstPartyForCookies(), url);
+    return platformStrategies()->cookiesStrategy()->cookieRequestHeaderFieldValue(SESSION(document), document->firstPartyForCookies(), url);
 #else
-    return cookieRequestHeaderFieldValue(networkingContext(document), document->firstPartyForCookies(), url);
+    return cookieRequestHeaderFieldValue(SESSION(document), document->firstPartyForCookies(), url);
 #endif
 }
 
 bool getRawCookies(const Document* document, const KURL& url, Vector<Cookie>& cookies)
 {
 #if USE(PLATFORM_STRATEGIES)
-    return platformStrategies()->cookiesStrategy()->getRawCookies(networkingContext(document), document->firstPartyForCookies(), url, cookies);
+    return platformStrategies()->cookiesStrategy()->getRawCookies(SESSION(document), document->firstPartyForCookies(), url, cookies);
 #else
-    return getRawCookies(networkingContext(document), document->firstPartyForCookies(), url, cookies);
+    return getRawCookies(SESSION(document), document->firstPartyForCookies(), url, cookies);
 #endif
 }
 
 void deleteCookie(const Document* document, const KURL& url, const String& cookieName)
 {
 #if USE(PLATFORM_STRATEGIES)
-    platformStrategies()->cookiesStrategy()->deleteCookie(networkingContext(document), url, cookieName);
+    platformStrategies()->cookiesStrategy()->deleteCookie(SESSION(document), url, cookieName);
 #else
-    deleteCookie(networkingContext(document), url, cookieName);
+    deleteCookie(SESSION(document), url, cookieName);
 #endif
 }
 
index 18eafb7..29ef43b 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "ApplicationCacheHost.h"
 #include "AsyncFileStream.h"
+#include "AuthenticationChallenge.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
 #include "FrameLoader.h"
index 8f7908d..c7ebd54 100644 (file)
@@ -26,6 +26,7 @@
 #include "CachePolicy.h"
 #include "FrameLoaderTypes.h"
 #include "PurgePriority.h"
+#include "ResourceError.h"
 #include "ResourceLoadPriority.h"
 #include "ResourceLoaderOptions.h"
 #include "ResourceRequest.h"
index d5d2f31..a166f20 100644 (file)
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
-#if PLATFORM(MAC) || USE(CFNETWORK)
-typedef struct OpaqueCFHTTPCookieStorage*  CFHTTPCookieStorageRef;
-#endif
-
 namespace WebCore {
 
 class KURL;
-class NetworkingContext;
+class NetworkStorageSession;
 struct Cookie;
 
 class CookiesStrategy {
 public:
     virtual void notifyCookiesChanged() = 0;
 
-#if PLATFORM(MAC) || USE(CFNETWORK)
-    virtual RetainPtr<CFHTTPCookieStorageRef> defaultCookieStorage() = 0;
-#endif
-
-    virtual String cookiesForDOM(NetworkingContext*, const KURL& firstParty, const KURL&) = 0;
-    virtual void setCookiesFromDOM(NetworkingContext*, const KURL& firstParty, const KURL&, const String& cookieString) = 0;
-    virtual bool cookiesEnabled(NetworkingContext*, const KURL& firstParty, const KURL&) = 0;
-    virtual String cookieRequestHeaderFieldValue(NetworkingContext*, const KURL& firstParty, const KURL&) = 0;
-    virtual bool getRawCookies(NetworkingContext*, const KURL& firstParty, const KURL&, Vector<Cookie>&) = 0;
-    virtual void deleteCookie(NetworkingContext*, const KURL&, const String& cookieName) = 0;
+    virtual String cookiesForDOM(const NetworkStorageSession&, const KURL& firstParty, const KURL&) = 0;
+    virtual void setCookiesFromDOM(const NetworkStorageSession&, const KURL& firstParty, const KURL&, const String& cookieString) = 0;
+    virtual bool cookiesEnabled(const NetworkStorageSession&, const KURL& firstParty, const KURL&) = 0;
+    virtual String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const KURL& firstParty, const KURL&) = 0;
+    virtual bool getRawCookies(const NetworkStorageSession&, const KURL& firstParty, const KURL&, Vector<Cookie>&) = 0;
+    virtual void deleteCookie(const NetworkStorageSession&, const KURL&, const String& cookieName) = 0;
 
 protected:
     virtual ~CookiesStrategy() { }
index e47b879..c82b46c 100644 (file)
@@ -40,6 +40,7 @@
 #include "FileSystem.h"
 #include "HTTPParsers.h"
 #include "KURL.h"
+#include "NetworkingContext.h"
 #include "ResourceError.h"
 #include "ResourceHandleClient.h"
 #include "ResourceRequest.h"
diff --git a/Source/WebCore/platform/network/NetworkStorageSession.h b/Source/WebCore/platform/network/NetworkStorageSession.h
new file mode 100644 (file)
index 0000000..5e0a71d
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2012 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 NetworkStorageSession_h
+#define NetworkStorageSession_h
+
+#include <wtf/RetainPtr.h>
+#include <wtf/text/WTFString.h>
+
+#if PLATFORM(MAC) || USE(CFNETWORK)
+typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
+typedef struct OpaqueCFHTTPCookieStorage*  CFHTTPCookieStorageRef;
+#endif
+
+namespace WebCore {
+
+class NetworkingContext;
+
+class NetworkStorageSession {
+    WTF_MAKE_NONCOPYABLE(NetworkStorageSession); WTF_MAKE_FAST_ALLOCATED;
+public:
+    static NetworkStorageSession& defaultStorageSession();
+    static PassOwnPtr<NetworkStorageSession> createDefaultSession(const String& identifierBase);
+    static PassOwnPtr<NetworkStorageSession> createPrivateBrowsingSession(const String& identifierBase);
+
+    static void switchToNewTestingSession();
+
+#if PLATFORM(MAC) || USE(CFNETWORK)
+    // May be null, in which case a Foundation default should be used.
+    CFURLStorageSessionRef platformSession() { return m_platformSession.get(); }
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage() const;
+    bool isPrivateBrowsingSession() const { return m_isPrivate; }
+#else
+    NetworkStorageSession(NetworkingContext*);
+    ~NetworkStorageSession();
+    NetworkingContext* context() const;
+#endif
+
+private:
+#if PLATFORM(MAC) || USE(CFNETWORK)
+    NetworkStorageSession(CFURLStorageSessionRef platformSession);
+    NetworkStorageSession();
+    RetainPtr<CFURLStorageSessionRef> m_platformSession;
+    bool m_isPrivate;
+#else
+    RefPtr<NetworkingContext> m_context;
+#endif
+};
+
+#if PLATFORM(WIN)
+// Needed for WebKit1 API only.
+void overrideCookieStorage(CFHTTPCookieStorageRef);
+CFHTTPCookieStorageRef overridenCookieStorage();
+#endif
+
+}
+
+#endif // NetworkStorageSession_h
  */
 
 #include "config.h"
-#include "WebPlatformStrategies.h"
+#include "NetworkStorageSession.h"
 
-#include "WebFrameNetworkingContext.h"
-#include <WebKitSystemInterface.h>
+#include "NetworkingContext.h"
+#include <wtf/PassOwnPtr.h>
 
-using namespace WebCore;
+namespace WebCore {
 
-namespace WebKit {
+NetworkStorageSession::NetworkStorageSession(NetworkingContext* context)
+    : m_context(context)
+{
+}
+
+NetworkStorageSession::~NetworkStorageSession()
+{
+}
+
+NetworkingContext* NetworkStorageSession::context() const
+{
+    return m_context.get();
+}
 
-RetainPtr<CFHTTPCookieStorageRef> WebPlatformStrategies::defaultCookieStorage()
+PassOwnPtr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(const String&)
 {
-    if (CFURLStorageSessionRef session = WebFrameNetworkingContext::defaultStorageSession())
-        return adoptCF(WKCopyHTTPCookieStorage(session));
-
-#if USE(CFNETWORK)
-    return WKGetDefaultHTTPCookieStorage();
-#else
-    // When using NSURLConnection, we also use its shared cookie storage.
-    return 0;
-#endif
+    ASSERT_NOT_REACHED();
+    return nullptr;
 }
 
-} // namespace WebKit
+NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
+{
+    DEFINE_STATIC_LOCAL(NetworkStorageSession, session, (0));
+    return session;
+}
+
+void NetworkStorageSession::switchToNewTestingSession()
+{
+}
+
+}
index a7c7a4b..841f7ec 100644 (file)
@@ -20,7 +20,9 @@
 #ifndef NetworkingContext_h
 #define NetworkingContext_h
 
+#include "NetworkStorageSession.h"
 #include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
 
 #if PLATFORM(MAC)
 #include "SchedulePair.h"
@@ -40,10 +42,6 @@ class WebCookieJar;
 OBJC_CLASS NSOperationQueue;
 #endif
 
-#if PLATFORM(MAC) || USE(CFNETWORK)
-typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
-#endif
-
 #if PLATFORM(QT)
 QT_BEGIN_NAMESPACE
 class QObject;
@@ -68,6 +66,7 @@ public:
     virtual bool isValid() const { return true; }
 
 #if PLATFORM(CHROMIUM)
+    // FIXME: Wrap WebCookieJar into a NetworkStorageSession to make the code cross-platform.
     virtual WebKit::WebCookieJar* cookieJar() const = 0;
 #endif
 
@@ -80,11 +79,12 @@ public:
 #endif
 
 #if PLATFORM(MAC) || USE(CFNETWORK)
-    virtual bool inPrivateBrowsingMode() const = 0;
-    virtual CFURLStorageSessionRef storageSession() const = 0;
+
+    virtual NetworkStorageSession& storageSession() const = 0;
 #endif
 
 #if PLATFORM(QT)
+    // FIXME: Wrap QNetworkAccessManager into a NetworkStorageSession to make the code cross-platform.
     virtual QObject* originatingObject() const = 0;
     virtual QNetworkAccessManager* networkAccessManager() const = 0;
     virtual bool mimeSniffingEnabled() const = 0;
@@ -98,6 +98,7 @@ public:
 #endif
 
 #if USE(SOUP)
+    // FIXME: Wrap SoupSession into a NetworkStorageSession to make the code cross-platform.
     virtual SoupSession* soupSession() const = 0;
     virtual uint64_t initiatingPageID() const = 0;
 #endif
index aa30e38..91d51fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2006, 2008, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 namespace WebCore {
 
 class KURL;
-class NetworkingContext;
+class NetworkStorageSession;
 struct Cookie;
 
-// If networking context is null, default cookie storage is used.
-String cookiesForDOM(NetworkingContext*, const KURL& firstParty, const KURL&);
-void setCookiesFromDOM(NetworkingContext*, const KURL& firstParty, const KURL&, const String&);
-bool cookiesEnabled(NetworkingContext*, const KURL& firstParty, const KURL&);
-String cookieRequestHeaderFieldValue(NetworkingContext*, const KURL& firstParty, const KURL&);
-bool getRawCookies(NetworkingContext*, const KURL& firstParty, const KURL&, Vector<Cookie>&);
-void deleteCookie(NetworkingContext*, const KURL&, const String&);
-void getHostnamesWithCookies(NetworkingContext*, HashSet<String>& hostnames);
-void deleteCookiesForHostname(NetworkingContext*, const String& hostname);
-void deleteAllCookies(NetworkingContext*);
+// FIXME: These should probably be NetworkStorageSession member functions.
+
+String cookiesForDOM(const NetworkStorageSession&, const KURL& firstParty, const KURL&);
+void setCookiesFromDOM(const NetworkStorageSession&, const KURL& firstParty, const KURL&, const String&);
+bool cookiesEnabled(const NetworkStorageSession&, const KURL& firstParty, const KURL&);
+String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const KURL& firstParty, const KURL&);
+bool getRawCookies(const NetworkStorageSession&, const KURL& firstParty, const KURL&, Vector<Cookie>&);
+void deleteCookie(const NetworkStorageSession&, const KURL&, const String&);
+void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames);
+void deleteCookiesForHostname(const NetworkStorageSession&, const String& hostname);
+void deleteAllCookies(const NetworkStorageSession&);
 
 }
 
index 6d12f9d..57eefed 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "BlobRegistry.h"
 #include "Logging.h"
+#include "NetworkingContext.h"
 #include "ResourceHandleClient.h"
 #include "Timer.h"
 #include <algorithm>
index 1ec3f44..268f2c4 100644 (file)
 #ifndef ResourceHandle_h
 #define ResourceHandle_h
 
-#include "AuthenticationChallenge.h"
 #include "AuthenticationClient.h"
 #include "HTTPHeaderMap.h"
-#include "NetworkingContext.h"
 #include <wtf/OwnPtr.h>
+#include <wtf/RefCounted.h>
 
 #if USE(SOUP)
+typedef struct _GTlsCertificate GTlsCertificate;
 typedef struct _SoupSession SoupSession;
 typedef struct _SoupRequest SoupRequest;
 #endif
@@ -78,6 +78,7 @@ class AuthenticationChallenge;
 class Credential;
 class Frame;
 class KURL;
+class NetworkingContext;
 class ProtectionSpace;
 class ResourceError;
 class ResourceHandleClient;
index b7f6c95..17e0ea8 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef ResourceHandleInternal_h
 #define ResourceHandleInternal_h
 
+#include "NetworkingContext.h"
 #include "ResourceHandle.h"
 #include "ResourceRequest.h"
 #include "AuthenticationChallenge.h"
index e27d1a0..0db772c 100644 (file)
@@ -29,9 +29,8 @@
 #if USE(CFNETWORK)
 
 #include "Cookie.h"
-#include "CookieStorageCFNet.h"
 #include "KURL.h"
-#include "NetworkingContext.h"
+#include "NetworkStorageSession.h"
 #include "ResourceHandle.h"
 #include "SoftLinking.h"
 #include <CFNetwork/CFHTTPCookiesPriv.h>
@@ -95,15 +94,12 @@ static RetainPtr<CFArrayRef> filterCookies(CFArrayRef unfilteredCookies)
     return filteredCookies;
 }
 
-void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& value)
+void setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& value)
 {
     // <rdar://problem/5632883> CFHTTPCookieStorage stores an empty cookie, which would be sent as "Cookie: =".
     if (value.isEmpty())
         return;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
-
     RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
     RetainPtr<CFURLRef> firstPartyForCookiesCF(AdoptCF, firstParty.createCFURL());
 
@@ -119,54 +115,43 @@ void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const
     RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault,
         headerFieldsCF.get(), urlCF.get()));
 
-    CFHTTPCookieStorageSetCookies(cookieStorage.get(), filterCookies(cookiesCF.get()).get(), urlCF.get(), firstPartyForCookiesCF.get());
+    CFHTTPCookieStorageSetCookies(session.cookieStorage().get(), filterCookies(cookiesCF.get()).get(), urlCF.get(), firstPartyForCookiesCF.get());
 }
 
-String cookiesForDOM(NetworkingContext* context, const KURL&, const KURL& url)
+String cookiesForDOM(const NetworkStorageSession& session, const KURL&, const KURL& url)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
-
     RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
 
     bool secure = url.protocolIs("https");
-    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage.get(), urlCF.get(), secure));
+    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), secure));
     RetainPtr<CFDictionaryRef> headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, filterCookies(cookiesCF.get()).get()));
     return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
 }
 
-String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url)
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
-
     RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
 
     bool secure = url.protocolIs("https");
-    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage.get(), urlCF.get(), secure));
+    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), secure));
     RetainPtr<CFDictionaryRef> headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get()));
     return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF);
 }
 
-bool cookiesEnabled(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/)
+bool cookiesEnabled(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& /*url*/)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
-
-    CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageGetCookieAcceptPolicy(cookieStorage.get());
+    CFHTTPCookieStorageAcceptPolicy policy = CFHTTPCookieStorageGetCookieAcceptPolicy(session.cookieStorage().get());
     return policy == CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain || policy == CFHTTPCookieStorageAcceptPolicyAlways;
 }
 
-bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
+bool getRawCookies(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
 {
     rawCookies.clear();
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
 
     RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
 
     bool sendSecureCookies = url.protocolIs("https");
-    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage.get(), urlCF.get(), sendSecureCookies));
+    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(session.cookieStorage().get(), urlCF.get(), sendSecureCookies));
 
     CFIndex count = CFArrayGetCount(cookiesCF.get());
     rawCookies.reserveCapacity(count);
@@ -190,10 +175,9 @@ bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const
     return true;
 }
 
-void deleteCookie(NetworkingContext* context, const KURL& url, const String& name)
+void deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& name)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
 
     RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL());
 
@@ -210,12 +194,9 @@ void deleteCookie(NetworkingContext* context, const KURL& url, const String& nam
     }
 }
 
-void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
+void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
-
-    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookies(cookieStorage.get()));
+    RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookies(session.cookieStorage().get()));
     if (!cookiesCF)
         return;
 
@@ -227,10 +208,9 @@ void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostna
     }
 }
 
-void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
+void deleteCookiesForHostname(const NetworkStorageSession& session, const String& hostname)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
 
     RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookies(cookieStorage.get()));
     if (!cookiesCF)
@@ -245,12 +225,9 @@ void deleteCookiesForHostname(NetworkingContext* context, const String& hostname
     }
 }
 
-void deleteAllCookies(NetworkingContext* context)
+void deleteAllCookies(const NetworkStorageSession& session)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    ASSERT(cookieStorage);
-
-    CFHTTPCookieStorageDeleteAllCookies(cookieStorage.get());
+    CFHTTPCookieStorageDeleteAllCookies(session.cookieStorage().get());
 }
 
 } // namespace WebCore
index 44ab73d..b4f1ed5 100644 (file)
@@ -26,9 +26,7 @@
 #include "config.h"
 #include "CookieStorage.h"
 
-#include "CookieStorageCFNet.h"
-
-#include "ResourceHandle.h"
+#include "NetworkStorageSession.h"
 #include <wtf/MainThread.h>
 
 #if PLATFORM(MAC)
@@ -48,56 +46,6 @@ namespace WebCore {
 
 #if PLATFORM(WIN)
 
-static RetainPtr<CFHTTPCookieStorageRef>& cookieStorageOverride()
-{
-    DEFINE_STATIC_LOCAL(RetainPtr<CFHTTPCookieStorageRef>, cookieStorage, ());
-    return cookieStorage;
-}
-
-#endif
-
-RetainPtr<CFHTTPCookieStorageRef> currentCFHTTPCookieStorage(NetworkingContext* context)
-{
-#if PLATFORM(WIN)
-    if (RetainPtr<CFHTTPCookieStorageRef>& override = cookieStorageOverride())
-        return override;
-#endif
-
-    if (CFURLStorageSessionRef session = context->storageSession())
-        return RetainPtr<CFHTTPCookieStorageRef>(AdoptCF, wkCopyHTTPCookieStorage(session));
-
-#if USE(CFNETWORK)
-    return wkGetDefaultHTTPCookieStorage();
-#else
-    // When using NSURLConnection, we also use its shared cookie storage.
-    return 0;
-#endif
-}
-
-RetainPtr<CFHTTPCookieStorageRef> defaultCFHTTPCookieStorage()
-{
-#if PLATFORM(WIN)
-    if (RetainPtr<CFHTTPCookieStorageRef>& override = cookieStorageOverride())
-        return override;
-#endif
-
-    return platformStrategies()->cookiesStrategy()->defaultCookieStorage();
-}
-
-#if PLATFORM(WIN)
-
-void overrideCookieStorage(CFHTTPCookieStorageRef cookieStorage)
-{
-    ASSERT(isMainThread());
-    // FIXME: Why don't we retain it? The only caller is an API method that takes cookie storage as a raw argument.
-    cookieStorageOverride().adoptCF(cookieStorage);
-}
-
-CFHTTPCookieStorageRef overridenCookieStorage()
-{
-    return cookieStorageOverride().get();
-}
-
 static void notifyCookiesChangedOnMainThread(void*)
 {
     ASSERT(isMainThread());
@@ -130,7 +78,7 @@ void startObservingCookieChanges()
     CFRunLoopRef runLoop = cookieStorageObserverRunLoop();
     ASSERT(runLoop);
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage();
     ASSERT(cookieStorage);
 
     CFHTTPCookieStorageScheduleWithRunLoop(cookieStorage.get(), runLoop, kCFRunLoopCommonModes);
@@ -144,7 +92,7 @@ void stopObservingCookieChanges()
     CFRunLoopRef runLoop = cookieStorageObserverRunLoop();
     ASSERT(runLoop);
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage();
     ASSERT(cookieStorage);
 
     CFHTTPCookieStorageRemoveObserver(cookieStorage.get(), runLoop, kCFRunLoopDefaultMode, notifyCookiesChanged, 0);
diff --git a/Source/WebCore/platform/network/cf/CookieStorageCFNet.h b/Source/WebCore/platform/network/cf/CookieStorageCFNet.h
deleted file mode 100644 (file)
index 7b0953b..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 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 COMPUTER, INC. ``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 COMPUTER, INC. OR
- * 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 CookieStorageCFNet_h
-#define CookieStorageCFNet_h
-
-#include <wtf/RetainPtr.h>
-
-typedef struct OpaqueCFHTTPCookieStorage*  CFHTTPCookieStorageRef;
-
-namespace WebCore {
-
-class NetworkingContext;
-
-RetainPtr<CFHTTPCookieStorageRef> currentCFHTTPCookieStorage(NetworkingContext*); // Will be null when using shared NSHTTPCookieStorage.
-RetainPtr<CFHTTPCookieStorageRef> defaultCFHTTPCookieStorage(); // Doesn't take current session into account.
-
-#if PLATFORM(WIN)
-// Needed for WebKit1 API only.
-void overrideCookieStorage(CFHTTPCookieStorageRef);
-CFHTTPCookieStorageRef overridenCookieStorage();
-#endif
-
-}
-
-#endif // CookieStorageCFNet_h
diff --git a/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp b/Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
new file mode 100644 (file)
index 0000000..bd04789
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2012 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 "NetworkStorageSession.h"
+
+#include <wtf/MainThread.h>
+#include <wtf/PassOwnPtr.h>
+
+#if PLATFORM(MAC)
+#include "WebCoreSystemInterface.h"
+#else
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
+
+namespace WebCore {
+
+NetworkStorageSession::NetworkStorageSession(CFURLStorageSessionRef platformSession)
+    : m_platformSession(platformSession)
+    , m_isPrivate(false)
+{
+}
+
+static OwnPtr<NetworkStorageSession>& defaultNetworkStorageSession()
+{
+    ASSERT(isMainThread());
+    DEFINE_STATIC_LOCAL(OwnPtr<NetworkStorageSession>, session, ());
+    return session;
+}
+
+void NetworkStorageSession::switchToNewTestingSession()
+{
+    // Set a private session for testing to avoid interfering with global cookies. This should be different from private browsing session.
+    // FIXME: It looks like creating a new session with the same identifier may be just creating a reference to the same storage. See <rdar://problem/11571450> and <rdar://problem/12384380>.
+#if PLATFORM(MAC)
+    defaultNetworkStorageSession() = adoptPtr(new NetworkStorageSession(wkCreatePrivateStorageSession(CFSTR("Private WebKit Session"))));
+#else
+    defaultNetworkStorageSession() = adoptPtr(new NetworkStorageSession(wkCreatePrivateStorageSession(CFSTR("Private WebKit Session"), defaultNetworkStorageSession()->platformSession())));
+#endif
+}
+
+#if PLATFORM(WIN)
+static RetainPtr<CFHTTPCookieStorageRef>& cookieStorageOverride()
+{
+    DEFINE_STATIC_LOCAL(RetainPtr<CFHTTPCookieStorageRef>, cookieStorage, ());
+    return cookieStorage;
+}
+
+void overrideCookieStorage(CFHTTPCookieStorageRef cookieStorage)
+{
+    ASSERT(isMainThread());
+    // FIXME: Why don't we retain it? The only caller is an API method that takes cookie storage as a raw argument.
+    cookieStorageOverride().adoptCF(cookieStorage);
+}
+
+CFHTTPCookieStorageRef overridenCookieStorage()
+{
+    return cookieStorageOverride().get();
+}
+#endif
+
+NetworkStorageSession& NetworkStorageSession::defaultStorageSession()
+{
+    if (!defaultNetworkStorageSession())
+        defaultNetworkStorageSession() = adoptPtr(new NetworkStorageSession(0));
+    return *defaultNetworkStorageSession();
+}
+
+PassOwnPtr<NetworkStorageSession> NetworkStorageSession::createPrivateBrowsingSession(const String& identifierBase)
+{
+    RetainPtr<CFStringRef> cfIdentifier = String(identifierBase + ".PrivateBrowsing").createCFString();
+
+#if PLATFORM(MAC)
+    OwnPtr<NetworkStorageSession> session = adoptPtr(new NetworkStorageSession(wkCreatePrivateStorageSession(cfIdentifier.get())));
+#else
+    OwnPtr<NetworkStorageSession> session = adoptPtr(new NetworkStorageSession(wkCreatePrivateStorageSession(cfIdentifier.get(), defaultNetworkStorageSession()->platformSession())));
+#endif
+    session->m_isPrivate = true;
+
+    return session.release();
+}
+
+RetainPtr<CFHTTPCookieStorageRef> NetworkStorageSession::cookieStorage() const
+{
+#if PLATFORM(WIN)
+    if (RetainPtr<CFHTTPCookieStorageRef>& override = cookieStorageOverride())
+        return override;
+#endif
+
+    if (m_platformSession)
+        return RetainPtr<CFHTTPCookieStorageRef>(AdoptCF, wkCopyHTTPCookieStorage(m_platformSession.get()));
+
+#if USE(CFNETWORK)
+    return wkGetDefaultHTTPCookieStorage();
+#else
+    // When using NSURLConnection, we also use its shared cookie storage.
+    return 0;
+#endif
+}
+
+}
index 290c05d..4f92d77 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "AuthenticationCF.h"
 #include "AuthenticationChallenge.h"
-#include "CookieStorageCFNet.h"
 #include "CredentialStorage.h"
 #include "CachedResourceLoader.h"
 #include "FormDataStreamCFNet.h"
@@ -38,6 +37,7 @@
 #include "LoaderRunLoopCF.h"
 #include "Logging.h"
 #include "MIMETypeRegistry.h"
+#include "NetworkingContext.h"
 #include "ResourceError.h"
 #include "ResourceHandleClient.h"
 #include "ResourceResponse.h"
@@ -399,7 +399,7 @@ static bool shouldRelaxThirdPartyCookiePolicy(NetworkingContext* context, const
 {
     // If a URL already has cookies, then we'll relax the 3rd party cookie policy and accept new cookies.
 
-    RetainPtr<CFHTTPCookieStorageRef> cfCookieStorage = currentCFHTTPCookieStorage(context);
+    RetainPtr<CFHTTPCookieStorageRef> cfCookieStorage = context->storageSession().cookieStorage();
     CFHTTPCookieStorageAcceptPolicy cookieAcceptPolicy = CFHTTPCookieStorageGetCookieAcceptPolicy(cfCookieStorage.get());
 
     if (cookieAcceptPolicy != CFHTTPCookieStorageAcceptPolicyOnlyFromMainDocumentDomain)
@@ -506,7 +506,7 @@ bool ResourceHandle::start(NetworkingContext* context)
     if (!context->isValid())
         return false;
 
-    d->m_storageSession = context->storageSession();
+    d->m_storageSession = context->storageSession().platformSession();
 
     bool shouldUseCredentialStorage = !client() || client()->shouldUseCredentialStorage(this);
 
@@ -741,7 +741,7 @@ void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const
 
     RefPtr<ResourceHandle> handle = adoptRef(new ResourceHandle(request, client.get(), false /*defersLoading*/, true /*shouldContentSniff*/));
 
-    handle->d->m_storageSession = context->storageSession();
+    handle->d->m_storageSession = context->storageSession().platformSession();
 
     if (handle->d->m_scheduledFailureType != NoFailure) {
         error = context->blockedError(request);
index a773536..916731f 100644 (file)
 
 namespace WebCore {
 
-void setCookiesFromDOM(NetworkingContext* context, const KURL& firstPartyForCookies, const KURL& url, const String& cookieStr)
+void setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstPartyForCookies, const KURL& url, const String& cookieStr)
 {
-    if (!context)
+    if (!session.context())
         return;
-    WebKit::WebCookieJar* cookieJar = context->cookieJar();
+    WebKit::WebCookieJar* cookieJar = session.context()->cookieJar();
     if (cookieJar)
         cookieJar->setCookie(url, firstPartyForCookies, cookieStr);
 }
 
-String cookiesForDOM(NetworkingContext* context, const KURL& firstPartyForCookies, const KURL& url)
+String cookiesForDOM(const NetworkStorageSession& session, const KURL& firstPartyForCookies, const KURL& url)
 {
-    if (!context)
+    if (!session.context())
         return String();
     String result;
-    WebKit::WebCookieJar* cookieJar = context->cookieJar();
+    WebKit::WebCookieJar* cookieJar = session.context()->cookieJar();
     if (cookieJar)
         result = cookieJar->cookies(url, firstPartyForCookies);
     return result;
 }
 
-String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstPartyForCookies, const KURL& url)
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstPartyForCookies, const KURL& url)
 {
-    if (!context)
+    if (!session.context())
         return String();
     String result;
-    WebKit::WebCookieJar* cookieJar = context->cookieJar();
+    WebKit::WebCookieJar* cookieJar = session.context()->cookieJar();
     if (cookieJar)
         result = cookieJar->cookieRequestHeaderFieldValue(url, firstPartyForCookies);
     return result;
 }
 
-bool cookiesEnabled(NetworkingContext* context, const KURL& cookieURL, const KURL& firstPartyForCookies)
+bool cookiesEnabled(const NetworkStorageSession& session, const KURL& cookieURL, const KURL& firstPartyForCookies)
 {
     bool result = false;
-    if (!context)
+    if (!session.context())
         return result;
-    WebKit::WebCookieJar* cookieJar = context->cookieJar();
+    WebKit::WebCookieJar* cookieJar = session.context()->cookieJar();
     if (cookieJar)
         result = cookieJar->cookiesEnabled(cookieURL, firstPartyForCookies);
     return result;
 }
 
-bool getRawCookies(NetworkingContext* context, const KURL& firstPartyForCookies, const KURL& url, Vector<Cookie>& rawCookies)
+bool getRawCookies(const NetworkStorageSession& session, const KURL& firstPartyForCookies, const KURL& url, Vector<Cookie>& rawCookies)
 {
     rawCookies.clear();
-    if (!context)
+    if (!session.context())
         return false;
     WebKit::WebVector<WebKit::WebCookie> webCookies;
-    WebKit::WebCookieJar* cookieJar = context->cookieJar();
+    WebKit::WebCookieJar* cookieJar = session.context()->cookieJar();
     if (cookieJar)
         cookieJar->rawCookies(url, firstPartyForCookies, webCookies);
     for (unsigned i = 0; i < webCookies.size(); ++i) {
@@ -100,26 +100,26 @@ bool getRawCookies(NetworkingContext* context, const KURL& firstPartyForCookies,
     return true;
 }
 
-void deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
-    if (!context)
+    if (!session.context())
         return;
-    WebKit::WebCookieJar* cookieJar = context->cookieJar();
+    WebKit::WebCookieJar* cookieJar = session.context()->cookieJar();
     if (cookieJar)
         cookieJar->deleteCookie(url, cookieName);
 }
 
-void getHostnamesWithCookies(NetworkingContext* /*context*/, HashSet<String>& /*hostnames*/)
+void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& /*hostnames*/)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteCookiesForHostname(NetworkingContext* /*context*/, const String& /*hostname*/)
+void deleteCookiesForHostname(const NetworkStorageSession&, const String& /*hostname*/)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteAllCookies(NetworkingContext* /*context*/)
+void deleteAllCookies(const NetworkStorageSession&)
 {
     // FIXME: Not yet implemented
 }
index aae53bb..0c9eee8 100644 (file)
 #include "config.h"
 #include "ResourceHandle.h"
 
+#include "NetworkingContext.h"
+#include "ResourceError.h"
 #include "ResourceHandleClient.h"
 #include "ResourceHandleInternal.h"
 #include "ResourceRequest.h"
+#include "ResourceResponse.h"
 #include "SharedBuffer.h"
 #include "WrappedResourceRequest.h"
 #include "WrappedResourceResponse.h"
index d1c5cc8..e91459f 100644 (file)
@@ -27,50 +27,50 @@ namespace WebCore {
 
 static HashMap<String, String> cookieJar;
 
-void setCookiesFromDOM(NetworkingContext*, const KURL&, const KURL& url, const String& value)
+void setCookiesFromDOM(const NetworkStorageSession&, const KURL&, const KURL& url, const String& value)
 {
     cookieJar.set(url.string(), value);
 }
 
-String cookiesForDOM(NetworkingContext*, const KURL&, const KURL& url)
+String cookiesForDOM(const NetworkStorageSession&, const KURL&, const KURL& url)
 {
     return cookieJar.get(url.string());
 }
 
-String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url)
+String cookieRequestHeaderFieldValue(const NetworkStorageSession&, const KURL& /*firstParty*/, const KURL& url)
 {
     // FIXME: include HttpOnly cookie.
     return cookieJar.get(url.string());
 }
 
-bool cookiesEnabled(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/)
+bool cookiesEnabled(const NetworkStorageSession&, const KURL& /*firstParty*/, const KURL& /*url*/)
 {
     return true;
 }
 
-bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/, Vector<Cookie>& rawCookies)
+bool getRawCookies(const NetworkStorageSession&, const KURL& /*firstParty*/, const KURL& /*url*/, Vector<Cookie>& rawCookies)
 {
     // FIXME: Not yet implemented
     rawCookies.clear();
     return false; // return true when implemented
 }
 
-void deleteCookie(NetworkingContext*, const KURL&, const String&)
+void deleteCookie(const NetworkStorageSession&, const KURL&, const String&)
 {
     // FIXME: Not yet implemented
 }
 
-void getHostnamesWithCookies(NetworkingContext*, HashSet<String>& hostnames)
+void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteCookiesForHostname(NetworkingContext*, const String& hostname)
+void deleteCookiesForHostname(const NetworkStorageSession&, const String& hostname)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteAllCookies(NetworkingContext*)
+void deleteAllCookies(const NetworkStorageSession&)
 {
     // FIXME: Not yet implemented
 }
index ce4d209..2e7fdba 100644 (file)
@@ -29,6 +29,7 @@
 #include "ResourceHandle.h"
 
 #include "CachedResourceLoader.h"
+#include "NetworkingContext.h"
 #include "NotImplemented.h"
 #include "ResourceHandleInternal.h"
 #include "ResourceHandleManager.h"
index f0d4767..2a63296 100644 (file)
@@ -31,9 +31,8 @@
 #import "BlockExceptions.h"
 #import "Cookie.h"
 #import "CookieStorage.h"
-#import "CookieStorageCFNet.h"
 #import "KURL.h"
-#import "NetworkingContext.h"
+#import "NetworkStorageSession.h"
 #import "WebCoreSystemInterface.h"
 
 namespace WebCore {
@@ -62,31 +61,29 @@ static RetainPtr<NSArray> filterCookies(NSArray *unfilteredCookies)
     return filteredCookies;
 }
 
-String cookiesForDOM(NetworkingContext* context, const KURL&, const KURL& url)
+String cookiesForDOM(const NetworkStorageSession& session, const KURL&, const KURL& url)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), url);
+    NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), url);
     return [[NSHTTPCookie requestHeaderFieldsWithCookies:filterCookies(cookies).get()] objectForKey:@"Cookie"];
 
     END_BLOCK_OBJC_EXCEPTIONS;
     return String();
 }
 
-String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url)
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), url);
+    NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), url);
     return [[NSHTTPCookie requestHeaderFieldsWithCookies:cookies] objectForKey:@"Cookie"];
 
     END_BLOCK_OBJC_EXCEPTIONS;
     return String();
 }
 
-void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieStr)
+void setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieStr)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
@@ -103,31 +100,28 @@ void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const
     RetainPtr<NSArray> filteredCookies = filterCookies([NSHTTPCookie cookiesWithResponseHeaderFields:[NSDictionary dictionaryWithObject:cookieString forKey:@"Set-Cookie"] forURL:cookieURL]);
     ASSERT([filteredCookies.get() count] <= 1);
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    wkSetHTTPCookiesForURL(cookieStorage.get(), filteredCookies.get(), cookieURL, firstParty);
+    wkSetHTTPCookiesForURL(session.cookieStorage().get(), filteredCookies.get(), cookieURL, firstParty);
 
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-bool cookiesEnabled(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/)
+bool cookiesEnabled(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& /*url*/)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast<NSHTTPCookieAcceptPolicy>(wkGetHTTPCookieAcceptPolicy(cookieStorage.get()));
+    NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast<NSHTTPCookieAcceptPolicy>(wkGetHTTPCookieAcceptPolicy(session.cookieStorage().get()));
     return cookieAcceptPolicy == NSHTTPCookieAcceptPolicyAlways || cookieAcceptPolicy == NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
 
     END_BLOCK_OBJC_EXCEPTIONS;
     return false;
 }
 
-bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
+bool getRawCookies(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
 {
     rawCookies.clear();
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), url);
+    NSArray *cookies = wkHTTPCookiesForURL(session.cookieStorage().get(), url);
     NSUInteger count = [cookies count];
     rawCookies.reserveCapacity(count);
     for (NSUInteger i = 0; i < count; ++i) {
@@ -141,12 +135,12 @@ bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const
     return true;
 }
 
-void deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     NSURL *cookieURL = url;
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
     NSArray *cookies = wkHTTPCookiesForURL(cookieStorage.get(), cookieURL);
 
     NSString *cookieNameString = cookieName;
@@ -161,12 +155,11 @@ void deleteCookie(NetworkingContext* context, const KURL& url, const String& coo
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
+void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    NSArray *cookies = wkHTTPCookies(cookieStorage.get());
+    NSArray *cookies = wkHTTPCookies(session.cookieStorage().get());
     
     for (NSHTTPCookie* cookie in cookies)
         hostnames.add([cookie domain]);
@@ -174,11 +167,11 @@ void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostna
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
+void deleteCookiesForHostname(const NetworkStorageSession& session, const String& hostname)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
+    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
     NSArray *cookies = wkHTTPCookies(cookieStorage.get());
     if (!cookies)
         return;
@@ -191,10 +184,9 @@ void deleteCookiesForHostname(NetworkingContext* context, const String& hostname
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void deleteAllCookies(NetworkingContext* context)
+void deleteAllCookies(const NetworkStorageSession& session)
 {
-    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = context ? currentCFHTTPCookieStorage(context) : defaultCFHTTPCookieStorage();
-    wkDeleteAllHTTPCookies(cookieStorage.get());
+    wkDeleteAllHTTPCookies(session.cookieStorage().get());
 }
 
 }
index 8c25211..bfb8a00 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "config.h"
 #include "CookieStorage.h"
-#include "CookieStorageCFNet.h"
 
 #import "ResourceHandle.h"
 
index 4497dbe..3a54531 100644 (file)
@@ -33,7 +33,6 @@
 #import "BlobRegistry.h"
 #import "BlockExceptions.h"
 #import "CookieStorage.h"
-#import "CookieStorageCFNet.h"
 #import "CredentialStorage.h"
 #import "CachedResourceLoader.h"
 #import "EmptyProtocolDefinitions.h"
@@ -42,6 +41,7 @@
 #import "FrameLoader.h"
 #import "Logging.h"
 #import "MIMETypeRegistry.h"
+#import "NetworkingContext.h"
 #import "Page.h"
 #import "ResourceError.h"
 #import "ResourceResponse.h"
@@ -147,7 +147,7 @@ static bool shouldRelaxThirdPartyCookiePolicy(NetworkingContext* context, const
 {
     // If a URL already has cookies, then we'll relax the 3rd party cookie policy and accept new cookies.
 
-    RetainPtr<CFHTTPCookieStorageRef> cfCookieStorage = currentCFHTTPCookieStorage(context);
+    RetainPtr<CFHTTPCookieStorageRef> cfCookieStorage = context->storageSession().cookieStorage();
     NSHTTPCookieAcceptPolicy cookieAcceptPolicy = static_cast<NSHTTPCookieAcceptPolicy>(wkGetHTTPCookieAcceptPolicy(cfCookieStorage.get()));
 
     if (cookieAcceptPolicy != NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain)
@@ -230,7 +230,7 @@ bool ResourceHandle::start(NetworkingContext* context)
     if (!context->isValid())
         return false;
 
-    d->m_storageSession = context->storageSession();
+    d->m_storageSession = context->storageSession().platformSession();
 
     ASSERT(!d->m_proxy);
     d->m_proxy.adoptNS(wkCreateNSURLConnectionDelegateProxy());
@@ -396,7 +396,7 @@ void ResourceHandle::loadResourceSynchronously(NetworkingContext* context, const
 
     RefPtr<ResourceHandle> handle = adoptRef(new ResourceHandle(request, client.get(), false /*defersLoading*/, true /*shouldContentSniff*/));
 
-    handle->d->m_storageSession = context->storageSession();
+    handle->d->m_storageSession = context->storageSession().platformSession();
 
     if (context && handle->d->m_scheduledFailureType != NoFailure) {
         error = context->blockedError(request);
index 4df08a7..55aeac2 100644 (file)
@@ -46,15 +46,15 @@ namespace WebCore {
 
 static SharedCookieJarQt* s_sharedCookieJarQt = 0;
 
-void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& value)
+void setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& value)
 {
-    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
+    QNetworkCookieJar* jar = session.context() ? session.context()->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
     if (!jar)
         return;
 
     QUrl urlForCookies(url);
     QUrl firstPartyUrl(firstParty);
-    if (!thirdPartyCookiePolicyPermits(context, urlForCookies, firstPartyUrl))
+    if (!thirdPartyCookiePolicyPermits(session.context(), urlForCookies, firstPartyUrl))
         return;
 
     QList<QNetworkCookie> cookies = QNetworkCookie::parseCookies(QString(value).toLatin1());
@@ -69,15 +69,15 @@ void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const
     jar->setCookiesFromUrl(cookies, urlForCookies);
 }
 
-String cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
+    QNetworkCookieJar* jar = session.context() ? session.context()->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
     if (!jar)
         return String();
 
     QUrl urlForCookies(url);
     QUrl firstPartyUrl(firstParty);
-    if (!thirdPartyCookiePolicyPermits(context, urlForCookies, firstPartyUrl))
+    if (!thirdPartyCookiePolicyPermits(session.context(), urlForCookies, firstPartyUrl))
         return String();
 
     QList<QNetworkCookie> cookies = jar->cookiesForUrl(urlForCookies);
@@ -94,9 +94,9 @@ String cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const K
     return resultCookies.join(QLatin1String("; "));
 }
 
-String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url)
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url)
 {
-    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
+    QNetworkCookieJar* jar = session.context() ? session.context()->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
     if (!jar)
         return String();
 
@@ -111,43 +111,43 @@ String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& /*f
     return resultCookies.join(QLatin1String("; "));
 }
 
-bool cookiesEnabled(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/)
+bool cookiesEnabled(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& /*url*/)
 {
-    QNetworkCookieJar* jar = context ? context->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
+    QNetworkCookieJar* jar = session.context() ? session.context()->networkAccessManager()->cookieJar() : SharedCookieJarQt::shared();
     return !!jar;
 }
 
-bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/, Vector<Cookie>& rawCookies)
+bool getRawCookies(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& /*url*/, Vector<Cookie>& rawCookies)
 {
     // FIXME: Not yet implemented
     rawCookies.clear();
     return false; // return true when implemented
 }
 
-void deleteCookie(NetworkingContext*, const KURL&, const String&)
+void deleteCookie(const NetworkStorageSession&, const KURL&, const String&)
 {
     // FIXME: Not yet implemented
 }
 
-void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
+void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
-    ASSERT_UNUSED(context, !context); // Not yet implemented for cookie jars other than the shared one.
+    ASSERT_UNUSED(session, !session.context()); // Not yet implemented for cookie jars other than the shared one.
     SharedCookieJarQt* jar = SharedCookieJarQt::shared();
     if (jar)
         jar->getHostnamesWithCookies(hostnames);
 }
 
-void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
+void deleteCookiesForHostname(const NetworkStorageSession& session, const String& hostname)
 {
-    ASSERT_UNUSED(context, !context); // Not yet implemented for cookie jars other than the shared one.
+    ASSERT_UNUSED(session, !session.context()); // Not yet implemented for cookie jars other than the shared one.
     SharedCookieJarQt* jar = SharedCookieJarQt::shared();
     if (jar)
         jar->deleteCookiesForHostname(hostname);
 }
 
-void deleteAllCookies(NetworkingContext* context)
+void deleteAllCookies(const NetworkStorageSession& session)
 {
-    ASSERT_UNUSED(context, !context); // Not yet implemented for cookie jars other than the shared one.
+    ASSERT_UNUSED(session, !session.context()); // Not yet implemented for cookie jars other than the shared one.
     SharedCookieJarQt* jar = SharedCookieJarQt::shared();
     if (jar)
         jar->deleteAllCookies();
index 904e859..0b64b79 100644 (file)
@@ -24,6 +24,7 @@
 #include "BlobData.h"
 #include "HTTPParsers.h"
 #include "MIMETypeRegistry.h"
+#include "NetworkingContext.h"
 #include "ResourceHandle.h"
 #include "ResourceHandleClient.h"
 #include "ResourceHandleInternal.h"
index f393a8b..c68b083 100644 (file)
 
 namespace WebCore {
 
-static SoupCookieJar* cookieJarForContext(NetworkingContext* context)
+static SoupCookieJar* cookieJarForSession(const NetworkStorageSession& session)
 {
-    return SOUP_COOKIE_JAR(soup_session_get_feature(context->soupSession(), SOUP_TYPE_COOKIE_JAR));
+    if (!session.context())
+        return soupCookieJar();
+    return SOUP_COOKIE_JAR(soup_session_get_feature(session.context()->soupSession(), SOUP_TYPE_COOKIE_JAR));
 }
 
 static GRefPtr<SoupCookieJar>& defaultCookieJar()
@@ -73,9 +75,9 @@ static inline bool httpOnlyCookieExists(const GSList* cookies, const gchar* name
     return false;
 }
 
-void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& value)
+void setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& value)
 {
-    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
+    SoupCookieJar* jar = cookieJarForSession(session);
     if (!jar)
         return;
 
@@ -107,9 +109,9 @@ void setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const
     soup_cookies_free(existingCookies);
 }
 
-static String cookiesForContext(NetworkingContext* context, const KURL& url, bool forHTTPHeader)
+static String cookiesForSession(const NetworkStorageSession& session, const KURL& url, bool forHTTPHeader)
 {
-    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
+    SoupCookieJar* jar = cookieJarForSession(session);
     if (!jar)
         return String();
 
@@ -118,25 +120,25 @@ static String cookiesForContext(NetworkingContext* context, const KURL& url, boo
     return String::fromUTF8(cookies.get());
 }
 
-String cookiesForDOM(NetworkingContext* context, const KURL&, const KURL& url)
+String cookiesForDOM(const NetworkStorageSession& session, const KURL&, const KURL& url)
 {
-    return cookiesForContext(context, url, false);
+    return cookiesForSession(session, url, false);
 }
 
-String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url)
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url)
 {
-    return cookiesForContext(context, url, true);
+    return cookiesForSession(session, url, true);
 }
 
-bool cookiesEnabled(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/)
+bool cookiesEnabled(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& /*url*/)
 {
-    return !!cookieJarForContext(context);
+    return !!cookieJarForSession(session);
 }
 
-bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
+bool getRawCookies(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url, Vector<Cookie>& rawCookies)
 {
     rawCookies.clear();
-    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
+    SoupCookieJar* jar = cookieJarForSession(session);
     if (!jar)
         return false;
 
@@ -157,9 +159,9 @@ bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const
     return true;
 }
 
-void deleteCookie(NetworkingContext* context, const KURL& url, const String& name)
+void deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& name)
 {
-    SoupCookieJar* jar = context ? cookieJarForContext(context) : soupCookieJar();
+    SoupCookieJar* jar = cookieJarForSession(session);
     if (!jar)
         return;
 
@@ -178,9 +180,9 @@ void deleteCookie(NetworkingContext* context, const KURL& url, const String& nam
     }
 }
 
-void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostnames)
+void getHostnamesWithCookies(const NetworkStorageSession& session, HashSet<String>& hostnames)
 {
-    SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar();
+    SoupCookieJar* cookieJar = cookieJarForSession(session);
     GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
     for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
         GOwnPtr<SoupCookie> cookie(static_cast<SoupCookie*>(item->data));
@@ -190,10 +192,10 @@ void getHostnamesWithCookies(NetworkingContext* context, HashSet<String>& hostna
     }
 }
 
-void deleteCookiesForHostname(NetworkingContext* context, const String& hostname)
+void deleteCookiesForHostname(const NetworkStorageSession& session, const String& hostname)
 {
     CString hostNameString = hostname.utf8();
-    SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar();
+    SoupCookieJar* cookieJar = cookieJarForSession(session);
     GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
     for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
         SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
@@ -203,9 +205,9 @@ void deleteCookiesForHostname(NetworkingContext* context, const String& hostname
     }
 }
 
-void deleteAllCookies(NetworkingContext* context)
+void deleteAllCookies(const NetworkStorageSession& session)
 {
-    SoupCookieJar* cookieJar = context ? cookieJarForContext(context) : soupCookieJar();
+    SoupCookieJar* cookieJar = cookieJarForSession(session);
     GOwnPtr<GSList> cookies(soup_cookie_jar_all_cookies(cookieJar));
     for (GSList* item = cookies.get(); item; item = g_slist_next(item)) {
         SoupCookie* cookie = static_cast<SoupCookie*>(item->data);
index 94b60c0..baba204 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "GOwnPtrSoup.h"
 #include "ResourceHandle.h"
+#include <libsoup/soup.h>
 #include <wtf/MainThread.h>
 #include <wtf/text/CString.h>
 
index a40393d..6a75de2 100644 (file)
@@ -40,6 +40,7 @@
 #include "LocalizedStrings.h"
 #include "Logging.h"
 #include "MIMETypeRegistry.h"
+#include "NetworkingContext.h"
 #include "NotImplemented.h"
 #include "Page.h"
 #include "ResourceError.h"
index d4f54ae..554704a 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "Cookie.h"
 #include "KURL.h"
+#include "NetworkingContext.h"
 #include "ResourceHandle.h"
 #include <windows.h>
 #include <Wininet.h>
@@ -35,7 +36,7 @@
 
 namespace WebCore {
 
-void setCookiesFromDOM(NetworkingContext*, const KURL&, const KURL& url, const String& value)
+void setCookiesFromDOM(const NetworkStorageSession&, const KURL&, const KURL& url, const String& value)
 {
     // FIXME: Deal with firstParty argument.
     String str = url.string();
@@ -43,7 +44,7 @@ void setCookiesFromDOM(NetworkingContext*, const KURL&, const KURL& url, const S
     InternetSetCookie(str.charactersWithNullTermination(), 0, val.charactersWithNullTermination());
 }
 
-String cookiesForDOM(NetworkingContext*, const KURL&, const KURL& url)
+String cookiesForDOM(const NetworkStorageSession&, const KURL&, const KURL& url)
 {
     // FIXME: Deal with firstParty argument.
 
@@ -64,40 +65,40 @@ String cookiesForDOM(NetworkingContext*, const KURL&, const KURL& url)
     return String::adopt(buffer);
 }
 
-String cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
     // FIXME: include HttpOnly cookie
-    return cookiesForDOM(context, firstParty, url);
+    return cookiesForDOM(session.context(), firstParty, url);
 }
 
-bool cookiesEnabled(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/)
+bool cookiesEnabled(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& /*url*/)
 {
     return true;
 }
 
-bool getRawCookies(NetworkingContext* context, const KURL& /*firstParty*/, const KURL& /*url*/, Vector<Cookie>& rawCookies)
+bool getRawCookies(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& /*url*/, Vector<Cookie>& rawCookies)
 {
     // FIXME: Not yet implemented
     rawCookies.clear();
     return false; // return true when implemented
 }
 
-void deleteCookie(NetworkingContext*, const KURL&, const String&)
+void deleteCookie(const NetworkStorageSession&, const KURL&, const String&)
 {
     // FIXME: Not yet implemented
 }
 
-void getHostnamesWithCookies(NetworkingContext*, HashSet<String>& hostnames)
+void getHostnamesWithCookies(const NetworkStorageSession&, HashSet<String>& hostnames)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteCookiesForHostname(NetworkingContext*, const String& hostname)
+void deleteCookiesForHostname(const NetworkStorageSession&, const String& hostname)
 {
     // FIXME: Not yet implemented
 }
 
-void deleteAllCookies(NetworkingContext*)
+void deleteAllCookies(const NetworkStorageSession&)
 {
     // FIXME: Not yet implemented
 }
index f250527..989f074 100644 (file)
@@ -30,6 +30,7 @@
 #include "DataURL.h"
 #include "HTTPParsers.h"
 #include "MIMETypeRegistry.h"
+#include "NetworkingContext.h"
 #include "NotImplemented.h"
 #include "ResourceError.h"
 #include "ResourceHandleClient.h"
index c92efa9..5859c12 100644 (file)
@@ -1,3 +1,20 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/PlatformStrategiesEfl.cpp:
+        (PlatformStrategiesEfl::cookiesForDOM):
+        (PlatformStrategiesEfl::setCookiesFromDOM):
+        (PlatformStrategiesEfl::cookiesEnabled):
+        (PlatformStrategiesEfl::cookieRequestHeaderFieldValue):
+        (PlatformStrategiesEfl::getRawCookies):
+        (PlatformStrategiesEfl::deleteCookie):
+        * WebCoreSupport/PlatformStrategiesEfl.h:
+        Cookie functions now take a NetworkStorageSession, not a NetworkingContext.
+
 2012-12-21  Seokju Kwon  <seokju.kwon@gmail.com>
 
         [EFL] Add guard around ContextMenuItemTagInspectElement
index 94a9531..a3c6352 100644 (file)
@@ -86,34 +86,34 @@ void PlatformStrategiesEfl::notifyCookiesChanged()
 {
 }
 
-String PlatformStrategiesEfl::cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesEfl::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesForDOM(context, firstParty, url);
+    return WebCore::cookiesForDOM(session, firstParty, url);
 }
 
-void PlatformStrategiesEfl::setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieString)
+void PlatformStrategiesEfl::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
-    WebCore::setCookiesFromDOM(context, firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
 }
 
-bool PlatformStrategiesEfl::cookiesEnabled(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+bool PlatformStrategiesEfl::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesEnabled(context, firstParty, url);
+    return WebCore::cookiesEnabled(session, firstParty, url);
 }
 
-String PlatformStrategiesEfl::cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesEfl::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookieRequestHeaderFieldValue(context, firstParty, url);
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
 }
 
-bool PlatformStrategiesEfl::getRawCookies(NetworkingContext* context, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
+bool PlatformStrategiesEfl::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
 {
-    return WebCore::getRawCookies(context, firstParty, url, rawCookies);
+    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
 }
 
-void PlatformStrategiesEfl::deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void PlatformStrategiesEfl::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
-    WebCore::deleteCookie(context, url, cookieName);
+    WebCore::deleteCookie(session, url, cookieName);
 }
 
 void PlatformStrategiesEfl::refreshPlugins()
index 56184b3..ee63496 100644 (file)
@@ -47,12 +47,12 @@ private:
 
     // WebCore::CookiesStrategy
     virtual void notifyCookiesChanged();
-    virtual String cookiesForDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual void setCookiesFromDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
-    virtual bool cookiesEnabled(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual String cookieRequestHeaderFieldValue(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual bool getRawCookies(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
-    virtual void deleteCookie(WebCore::NetworkingContext*, const WebCore::KURL&, const String&);
+    virtual String cookiesForDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
+    virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
+    virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::KURL&, const String&);
 
     // WebCore::DatabaseStrategy
     // - Using default implementation.
index 418884d..1b50959 100644 (file)
@@ -1,3 +1,20 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/PlatformStrategiesGtk.cpp:
+        (PlatformStrategiesGtk::cookiesForDOM):
+        (PlatformStrategiesGtk::setCookiesFromDOM):
+        (PlatformStrategiesGtk::cookiesEnabled):
+        (PlatformStrategiesGtk::cookieRequestHeaderFieldValue):
+        (PlatformStrategiesGtk::getRawCookies):
+        (PlatformStrategiesGtk::deleteCookie):
+        * WebCoreSupport/PlatformStrategiesGtk.h:
+        Cookie functions now take a NetworkStorageSession, not a NetworkingContext.
+
 2012-12-18  Alexey Proskuryakov  <ap@apple.com>
 
         Remove unnecessary functions from CookiesStrategy
index 7e9eb2b..9713d1e 100644 (file)
@@ -80,34 +80,34 @@ void PlatformStrategiesGtk::notifyCookiesChanged()
 {
 }
 
-String PlatformStrategiesGtk::cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesGtk::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesForDOM(context, firstParty, url);
+    return WebCore::cookiesForDOM(session, firstParty, url);
 }
 
-void PlatformStrategiesGtk::setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieString)
+void PlatformStrategiesGtk::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
-    WebCore::setCookiesFromDOM(context, firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
 }
 
-bool PlatformStrategiesGtk::cookiesEnabled(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+bool PlatformStrategiesGtk::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesEnabled(context, firstParty, url);
+    return WebCore::cookiesEnabled(session, firstParty, url);
 }
 
-String PlatformStrategiesGtk::cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesGtk::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookieRequestHeaderFieldValue(context, firstParty, url);
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
 }
 
-bool PlatformStrategiesGtk::getRawCookies(NetworkingContext* context, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
+bool PlatformStrategiesGtk::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
 {
-    return WebCore::getRawCookies(context, firstParty, url, rawCookies);
+    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
 }
 
-void PlatformStrategiesGtk::deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void PlatformStrategiesGtk::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
-    WebCore::deleteCookie(context, url, cookieName);
+    WebCore::deleteCookie(session, url, cookieName);
 }
 
 // PluginStrategy
index ba4a32f..727f3b9 100644 (file)
@@ -46,12 +46,12 @@ private:
 
     // WebCore::CookiesStrategy
     virtual void notifyCookiesChanged();
-    virtual String cookiesForDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual void setCookiesFromDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
-    virtual bool cookiesEnabled(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual String cookieRequestHeaderFieldValue(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual bool getRawCookies(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
-    virtual void deleteCookie(WebCore::NetworkingContext*, const WebCore::KURL&, const String&);
+    virtual String cookiesForDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
+    virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
+    virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::KURL&, const String&);
 
     // WebCore::DatabaseStrategy
     // - Using default implementation.
index 83ff013..85cbe83 100644 (file)
@@ -1,3 +1,37 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        Updated for ResourceHandle include changes.
+
+        * WebCoreSupport/WebFrameNetworkingContext.h:
+        * WebCoreSupport/WebFrameNetworkingContext.mm:
+        This class is now simpler, with more session tracking being in WebCore now.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::cookiesForDOM):
+        (WebPlatformStrategies::setCookiesFromDOM):
+        (WebPlatformStrategies::cookiesEnabled):
+        (WebPlatformStrategies::cookieRequestHeaderFieldValue):
+        (WebPlatformStrategies::getRawCookies):
+        (WebPlatformStrategies::deleteCookie):
+        We no longer need a function for default cookie storage! Other cookie functions
+        now take a session.
+
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences _switchNetworkLoaderToNewTestingSession]): Initialize WCSI before
+        calling a WebCore that uses it.
+        (+[WebPreferences _setCurrentNetworkLoaderSessionCookieAcceptPolicy:]): Use
+        NetworkStorageSession for session tracking.
+
+        * WebView/WebView.mm: (-[WebView _cachedResponseForURL:]): Updated for networking
+        context now returning a class for session.
+
 2012-12-20  Ilya Tikhonovsky  <loislo@chromium.org>
 
         Unreviewed build fix for chromium mac after r138206.
index 8ed4801..57c5a68 100644 (file)
 #import <WebCore/MouseEvent.h>
 #import <WebCore/Page.h>
 #import <WebCore/PluginViewBase.h>
+#import <WebCore/ProtectionSpace.h>
 #import <WebCore/ResourceError.h>
 #import <WebCore/ResourceHandle.h>
 #import <WebCore/ResourceLoader.h>
index 9561369..4de3b25 100644 (file)
@@ -27,13 +27,8 @@ public:
         return adoptRef(new WebFrameNetworkingContext(frame));
     }
 
-    static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
-    static void switchToNewTestingSession();
     static void ensurePrivateBrowsingSession();
     static void destroyPrivateBrowsingSession();
-    static CFURLStorageSessionRef defaultStorageSession();
-
-    static void setCookieAcceptPolicyForTestingContext(NSHTTPCookieAcceptPolicy);
 
 private:
     WebFrameNetworkingContext(WebCore::Frame* frame)
@@ -43,8 +38,7 @@ private:
 
     virtual bool needsSiteSpecificQuirks() const OVERRIDE;
     virtual bool localFileContentSniffingEnabled() const OVERRIDE;
-    virtual bool inPrivateBrowsingMode() const OVERRIDE;
-    virtual CFURLStorageSessionRef storageSession() const OVERRIDE;
+    virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
     virtual WebCore::SchedulePairHashSet* scheduledRunLoopPairs() const OVERRIDE;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
 };
index 8edced0..3055f9e 100644 (file)
@@ -21,6 +21,7 @@
 #import "WebFrameNetworkingContext.h"
 
 #import <WebCore/FrameLoaderClient.h>
+#import <WebCore/NetworkStorageSession.h>
 #import <WebCore/Page.h>
 #import <WebCore/ResourceError.h>
 #import <WebCore/Settings.h>
 
 using namespace WebCore;
 
-static CFURLStorageSessionRef defaultCFStorageSession;
-static CFURLStorageSessionRef privateBrowsingStorageSession;
+static OwnPtr<NetworkStorageSession>& privateBrowsingStorageSession()
+{
+    DEFINE_STATIC_LOCAL(OwnPtr<NetworkStorageSession>, session, ());
+    return session;
+}
 
 bool WebFrameNetworkingContext::needsSiteSpecificQuirks() const
 {
@@ -51,69 +55,27 @@ ResourceError WebFrameNetworkingContext::blockedError(const ResourceRequest& req
     return frame()->loader()->client()->blockedError(request);
 }
 
-static String& privateBrowsingStorageSessionIdentifierBase()
-{
-    ASSERT(isMainThread());
-    DEFINE_STATIC_LOCAL(String, base, ());
-    return base;
-}
-
-void WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(const String& identifier)
-{
-    privateBrowsingStorageSessionIdentifierBase() = identifier;
-}
-
-void WebFrameNetworkingContext::switchToNewTestingSession()
-{
-    // Set a private session for testing to avoid interfering with global cookies. This should be different from private browsing session.
-    if (defaultCFStorageSession)
-        CFRelease(defaultCFStorageSession);
-    defaultCFStorageSession = WKCreatePrivateStorageSession(CFSTR("Private WebKit Session"));
-}
-
 void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
 {
     ASSERT(isMainThread());
-    if (privateBrowsingStorageSession)
+    if (privateBrowsingStorageSession())
         return;
 
-    String base = privateBrowsingStorageSessionIdentifierBase().isNull() ? String([[NSBundle mainBundle] bundleIdentifier]) : privateBrowsingStorageSessionIdentifierBase();
-    RetainPtr<CFStringRef> cfIdentifier = String(base + ".PrivateBrowsing").createCFString();
-
-    privateBrowsingStorageSession = WKCreatePrivateStorageSession(cfIdentifier.get());
+    privateBrowsingStorageSession() = NetworkStorageSession::createPrivateBrowsingSession([[NSBundle mainBundle] bundleIdentifier]);
 }
 
 void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
 {
-    if (!privateBrowsingStorageSession)
-        return;
-
-    CFRelease(privateBrowsingStorageSession);
-    privateBrowsingStorageSession = 0;
-}
-
-CFURLStorageSessionRef WebFrameNetworkingContext::defaultStorageSession()
-{
-    return defaultCFStorageSession;
+    privateBrowsingStorageSession() = nullptr;
 }
 
-bool WebFrameNetworkingContext::inPrivateBrowsingMode() const
+NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
 {
-    return frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled();
-}
-
-CFURLStorageSessionRef WebFrameNetworkingContext::storageSession() const
-{
-    if (inPrivateBrowsingMode()) {
-        ASSERT(privateBrowsingStorageSession);
-        return privateBrowsingStorageSession;
+    bool inPrivateBrowsingMode = frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled();
+    if (inPrivateBrowsingMode) {
+        ASSERT(privateBrowsingStorageSession());
+        return *privateBrowsingStorageSession();
     }
-    return defaultCFStorageSession;
+    return NetworkStorageSession::defaultStorageSession();
 }
 
-void WebFrameNetworkingContext::setCookieAcceptPolicyForTestingContext(NSHTTPCookieAcceptPolicy policy)
-{
-    ASSERT(defaultCFStorageSession);
-    RetainPtr<CFHTTPCookieStorageRef> defaultCookieStorage = adoptCF(WKCopyHTTPCookieStorage(defaultCFStorageSession));
-    WKSetHTTPCookieAcceptPolicy(defaultCookieStorage.get(), policy);
-}
index 23a0396..a4f2ccc 100644 (file)
@@ -53,13 +53,12 @@ private:
 
     // WebCore::CookiesStrategy
     virtual void notifyCookiesChanged() OVERRIDE;
-    virtual RetainPtr<CFHTTPCookieStorageRef> defaultCookieStorage() OVERRIDE;
-    virtual String cookiesForDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
-    virtual void setCookiesFromDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&) OVERRIDE;
-    virtual bool cookiesEnabled(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
-    virtual String cookieRequestHeaderFieldValue(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
-    virtual bool getRawCookies(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&) OVERRIDE;
-    virtual void deleteCookie(WebCore::NetworkingContext*, const WebCore::KURL&, const String&) OVERRIDE;
+    virtual String cookiesForDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
+    virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&) OVERRIDE;
+    virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
+    virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
+    virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&) OVERRIDE;
+    virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::KURL&, const String&) OVERRIDE;
 
     // WebCore::DatabaseStrategy
     // - Using default implementation.
index 5599c5d..0b440eb 100644 (file)
@@ -87,47 +87,34 @@ void WebPlatformStrategies::notifyCookiesChanged()
 {
 }
 
-RetainPtr<CFHTTPCookieStorageRef> WebPlatformStrategies::defaultCookieStorage()
+String WebPlatformStrategies::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    if (CFURLStorageSessionRef session = WebFrameNetworkingContext::defaultStorageSession())
-        return adoptCF(WKCopyHTTPCookieStorage(session));
-
-#if USE(CFNETWORK)
-    return WKGetDefaultHTTPCookieStorage();
-#else
-    // When using NSURLConnection, we also use its shared cookie storage.
-    return 0;
-#endif
-}
-
-String WebPlatformStrategies::cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
-{
-    return WebCore::cookiesForDOM(context, firstParty, url);
+    return WebCore::cookiesForDOM(session, firstParty, url);
 }
 
-void WebPlatformStrategies::setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieString)
+void WebPlatformStrategies::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
-    WebCore::setCookiesFromDOM(context, firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
 }
 
-bool WebPlatformStrategies::cookiesEnabled(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+bool WebPlatformStrategies::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesEnabled(context, firstParty, url);
+    return WebCore::cookiesEnabled(session, firstParty, url);
 }
 
-String WebPlatformStrategies::cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String WebPlatformStrategies::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookieRequestHeaderFieldValue(context, firstParty, url);
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
 }
 
-bool WebPlatformStrategies::getRawCookies(NetworkingContext* context, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
+bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
 {
-    return WebCore::getRawCookies(context, firstParty, url, rawCookies);
+    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
 }
 
-void WebPlatformStrategies::deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
-    WebCore::deleteCookie(context, url, cookieName);
+    WebCore::deleteCookie(session, url, cookieName);
 }
 
 void WebPlatformStrategies::refreshPlugins()
index c1ef699..f4b1b54 100644 (file)
@@ -39,8 +39,9 @@
 #import "WebKitVersionChecks.h"
 #import "WebNSDictionaryExtras.h"
 #import "WebNSURLExtras.h"
+#import "WebSystemInterface.h"
 #import <WebCore/ApplicationCacheStorage.h>
-#import <WebCore/CookieStorageCFNet.h>
+#import <WebCore/NetworkStorageSession.h>
 #import <WebCore/ResourceHandle.h>
 #import <wtf/RetainPtr.h>
 
@@ -1286,12 +1287,13 @@ static NSString *classIBCreatorID = nil;
 
 + (void)_switchNetworkLoaderToNewTestingSession
 {
-    WebFrameNetworkingContext::switchToNewTestingSession();
+    InitWebCoreSystemInterface();
+    NetworkStorageSession::switchToNewTestingSession();
 }
 
 + (void)_setCurrentNetworkLoaderSessionCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)policy
 {
-    WebFrameNetworkingContext::setCookieAcceptPolicyForTestingContext(policy);
+    WKSetHTTPCookieAcceptPolicy(NetworkStorageSession::defaultStorageSession().cookieStorage().get(), policy);
 }
 
 - (BOOL)isDOMPasteAllowed
index 9512988..93a68b6 100644 (file)
@@ -2016,7 +2016,7 @@ static inline IMP getMethod(id o, SEL s)
     if (!_private->page)
         return nil;
 
-    if (CFURLStorageSessionRef storageSession = _private->page->mainFrame()->loader()->networkingContext()->storageSession())
+    if (CFURLStorageSessionRef storageSession = _private->page->mainFrame()->loader()->networkingContext()->storageSession().platformSession())
         cachedResponse = WKCachedResponseForRequest(storageSession, request.get());
     else
         cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request.get()];
index 2d1e70b..a591539 100644 (file)
@@ -1,3 +1,24 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/PlatformStrategiesQt.cpp:
+        (PlatformStrategiesQt::cookiesForDOM):
+        (PlatformStrategiesQt::setCookiesFromDOM):
+        (PlatformStrategiesQt::cookiesEnabled):
+        (PlatformStrategiesQt::cookieRequestHeaderFieldValue):
+        (PlatformStrategiesQt::getRawCookies):
+        (PlatformStrategiesQt::deleteCookie):
+        * WebCoreSupport/PlatformStrategiesQt.h:
+        Cookie functions now take a NetworkStorageSession, not a NetworkingContext.
+
+        * WebCoreSupport/QWebFrameAdapter.cpp:
+        * WebCoreSupport/QWebPageAdapter.cpp:
+        Updated for ResourceHandle include changes.
+
 2012-12-18  Alexey Proskuryakov  <ap@apple.com>
 
         Remove unnecessary functions from CookiesStrategy
index 3e7518a..3159656 100644 (file)
@@ -99,34 +99,34 @@ void PlatformStrategiesQt::notifyCookiesChanged()
 {
 }
 
-String PlatformStrategiesQt::cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesQt::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesForDOM(context, firstParty, url);
+    return WebCore::cookiesForDOM(session, firstParty, url);
 }
 
-void PlatformStrategiesQt::setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieString)
+void PlatformStrategiesQt::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
-    WebCore::setCookiesFromDOM(context, firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
 }
 
-bool PlatformStrategiesQt::cookiesEnabled(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+bool PlatformStrategiesQt::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesEnabled(context, firstParty, url);
+    return WebCore::cookiesEnabled(session, firstParty, url);
 }
 
-String PlatformStrategiesQt::cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesQt::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookieRequestHeaderFieldValue(context, firstParty, url);
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
 }
 
-bool PlatformStrategiesQt::getRawCookies(NetworkingContext* context, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
+bool PlatformStrategiesQt::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
 {
-    return WebCore::getRawCookies(context, firstParty, url, rawCookies);
+    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
 }
 
-void PlatformStrategiesQt::deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void PlatformStrategiesQt::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
-    WebCore::deleteCookie(context, url, cookieName);
+    WebCore::deleteCookie(session, url, cookieName);
 }
 
 void PlatformStrategiesQt::refreshPlugins()
index 0285edb..4fe63ca 100644 (file)
@@ -58,12 +58,12 @@ private:
     
     // WebCore::CookiesStrategy
     virtual void notifyCookiesChanged();
-    virtual String cookiesForDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual void setCookiesFromDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
-    virtual bool cookiesEnabled(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual String cookieRequestHeaderFieldValue(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual bool getRawCookies(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
-    virtual void deleteCookie(WebCore::NetworkingContext*, const WebCore::KURL&, const String&);
+    virtual String cookiesForDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
+    virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
+    virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::KURL&, const String&);
 
     // WebCore::DatabaseStrategy
     // - Using default implementation.
index 7f55da3..1efea50 100644 (file)
@@ -37,6 +37,7 @@
 #include "JSDOMWindowBase.h"
 #include "KURL.h"
 #include "NavigationScheduler.h"
+#include "NetworkingContext.h"
 #include "NodeList.h"
 #include "Page.h"
 #include "QWebPageAdapter.h"
index 5588c11..c20a246 100644 (file)
@@ -58,6 +58,7 @@
 #include "LocalizedStrings.h"
 #include "MIMETypeRegistry.h"
 #include "MemoryCache.h"
+#include "NetworkingContext.h"
 #include "NodeList.h"
 #include "NotificationPresenterClientQt.h"
 #include "PageGroup.h"
index 72e5169..0d18426 100644 (file)
@@ -1,3 +1,28 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        * WebCookieManagerCFNet.cpp:
+        * WebView.cpp:
+        Updated includes.
+
+        * WebCoreSupport/WebFrameNetworkingContext.cpp:
+        * WebCoreSupport/WebFrameNetworkingContext.h:
+        This class is now simpler, with most session tracking being in WebCore.
+
+        * WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebPlatformStrategies::cookiesForDOM):
+        (WebPlatformStrategies::setCookiesFromDOM):
+        (WebPlatformStrategies::cookiesEnabled):
+        (WebPlatformStrategies::cookieRequestHeaderFieldValue):
+        (WebPlatformStrategies::getRawCookies):
+        (WebPlatformStrategies::deleteCookie):
+        * WebCoreSupport/WebPlatformStrategies.h:
+        We no longer need a function for default storage! Other functions now take a session.
+
 2012-12-21  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r138331.
index f0804df..b48ba7b 100644 (file)
@@ -28,7 +28,7 @@
 #include "WebCookieManager.h"
 
 #include <CFNetwork/CFHTTPCookiesPriv.h>
-#include <WebCore/CookieStorageCFNet.h>
+#include <WebCore/NetworkStorageSession.h>
 
 using namespace WebCore;
 
index 78b6694..4d5a6d1 100644 (file)
@@ -23,7 +23,6 @@
 #include "FrameLoaderClient.h"
 #if USE(CFNETWORK)
 #include <CFNetwork/CFHTTPCookiesPriv.h>
-#include <WebCore/CookieStorageCFNet.h>
 #endif
 #include <WebCore/Settings.h>
 #if USE(CFNETWORK)
 using namespace WebCore;
 
 #if USE(CFNETWORK)
-static CFURLStorageSessionRef defaultCFStorageSession;
-static CFURLStorageSessionRef privateBrowsingStorageSession;
+static OwnPtr<NetworkStorageSession>& privateBrowsingStorageSession()
+{
+    DEFINE_STATIC_LOCAL(OwnPtr<NetworkStorageSession>, session, ());
+    return session;
+}
 #endif
 
 PassRefPtr<WebFrameNetworkingContext> WebFrameNetworkingContext::create(Frame* frame, const String& userAgent)
@@ -69,75 +71,43 @@ void WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(c
     privateBrowsingStorageSessionIdentifierBase() = identifier;
 }
 
-void WebFrameNetworkingContext::switchToNewTestingSession()
-{
-#if USE(CFNETWORK)
-    // Set a private session for testing to avoid interfering with global cookies. This should be different from private browsing session.
-    defaultCFStorageSession = wkCreatePrivateStorageSession(CFSTR("Private WebKit Session"), defaultCFStorageSession);
-#endif
-}
-
 void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
 {
     ASSERT(isMainThread());
 #if USE(CFNETWORK)
-    if (privateBrowsingStorageSession)
+    if (privateBrowsingStorageSession())
         return;
 
-    String base = privateBrowsingStorageSessionIdentifierBase().isNull() ? String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey))) : privateBrowsingStorageSessionIdentifierBase();
-    RetainPtr<CFStringRef> cfIdentifier = String(base + ".PrivateBrowsing").createCFString();
+    String identifierBase = privateBrowsingStorageSessionIdentifierBase().isNull() ? String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey))) : privateBrowsingStorageSessionIdentifierBase();
 
-    privateBrowsingStorageSession = wkCreatePrivateStorageSession(cfIdentifier.get(), defaultCFStorageSession);
+    privateBrowsingStorageSession() = NetworkStorageSession::createPrivateBrowsingSession(identifierBase);
 #endif
 }
 
 void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
 {
 #if USE(CFNETWORK)
-    if (!privateBrowsingStorageSession)
-        return;
-
-    CFRelease(privateBrowsingStorageSession);
-    privateBrowsingStorageSession = 0;
+    privateBrowsingStorageSession() = nullptr;
 #endif
 }
 
 #if USE(CFNETWORK)
-CFURLStorageSessionRef WebFrameNetworkingContext::defaultStorageSession()
+NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
 {
-    return defaultCFStorageSession;
-}
-
-bool WebFrameNetworkingContext::inPrivateBrowsingMode() const
-{
-    return frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled();
-}
-
-CFURLStorageSessionRef WebFrameNetworkingContext::storageSession() const
-{
-    bool privateBrowsingEnabled = inPrivateBrowsingMode();
-    if (privateBrowsingEnabled) {
-        ASSERT(privateBrowsingStorageSession);
-        return privateBrowsingStorageSession;
+    bool inPrivateBrowsingMode = frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled();
+    if (inPrivateBrowsingMode) {
+        ASSERT(privateBrowsingStorageSession());
+        return *privateBrowsingStorageSession();
     }
-    return defaultCFStorageSession;
-}
-
-void WebFrameNetworkingContext::setCookieAcceptPolicyForTestingContext(CFHTTPCookieStorageAcceptPolicy policy)
-{
-    ASSERT(defaultCFStorageSession);
-    RetainPtr<CFHTTPCookieStorageRef> defaultCookieStorage = adoptCF(wkCopyHTTPCookieStorage(defaultCFStorageSession));
-    CFHTTPCookieStorageSetCookieAcceptPolicy(defaultCookieStorage.get(), policy);
+    return NetworkStorageSession::defaultStorageSession();
 }
 
 void WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts(CFHTTPCookieStorageAcceptPolicy policy)
 {
-    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage())
+    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage())
         CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), policy);
 
-    if (privateBrowsingStorageSession) {
-        RetainPtr<CFHTTPCookieStorageRef> privateBrowsingCookieStorage = adoptCF(wkCopyHTTPCookieStorage(privateBrowsingStorageSession));
-        CFHTTPCookieStorageSetCookieAcceptPolicy(privateBrowsingCookieStorage.get(), policy);
-    }
+    if (privateBrowsingStorageSession())
+        CFHTTPCookieStorageSetCookieAcceptPolicy(privateBrowsingStorageSession()->cookieStorage().get(), policy);
 }
 #endif
index 25c630e..488feb3 100644 (file)
@@ -29,14 +29,10 @@ public:
     static PassRefPtr<WebFrameNetworkingContext> create(WebCore::Frame*, const WTF::String& userAgent);
 
     static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
-    static void switchToNewTestingSession();
     static void ensurePrivateBrowsingSession();
     static void destroyPrivateBrowsingSession();
 
 #if USE(CFNETWORK)
-    static CFURLStorageSessionRef defaultStorageSession();
-
-    static void setCookieAcceptPolicyForTestingContext(CFHTTPCookieStorageAcceptPolicy);
     static void setCookieAcceptPolicyForAllContexts(CFHTTPCookieStorageAcceptPolicy);
 #endif
 
@@ -50,8 +46,7 @@ private:
     virtual WTF::String userAgent() const;
     virtual WTF::String referrer() const;
 #if USE(CFNETWORK)
-    virtual bool inPrivateBrowsingMode() const;
-    virtual CFURLStorageSessionRef storageSession() const;
+    virtual WebCore::NetworkStorageSession& storageSession() const;
 #endif
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const;
 
index a727bdb..3890d42 100644 (file)
@@ -86,44 +86,34 @@ void WebPlatformStrategies::notifyCookiesChanged()
 {
 }
 
-#if USE(CFNETWORK)
-RetainPtr<CFHTTPCookieStorageRef> WebPlatformStrategies::defaultCookieStorage()
-{
-    if (CFURLStorageSessionRef session = WebFrameNetworkingContext::defaultStorageSession())
-        return adoptCF(wkCopyHTTPCookieStorage(session));
-
-    return wkGetDefaultHTTPCookieStorage();
-}
-#endif
-
-String WebPlatformStrategies::cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String WebPlatformStrategies::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesForDOM(context, firstParty, url);
+    return WebCore::cookiesForDOM(session, firstParty, url);
 }
 
-void WebPlatformStrategies::setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieString)
+void WebPlatformStrategies::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
-    WebCore::setCookiesFromDOM(context, firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
 }
 
-bool WebPlatformStrategies::cookiesEnabled(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+bool WebPlatformStrategies::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesEnabled(context, firstParty, url);
+    return WebCore::cookiesEnabled(session, firstParty, url);
 }
 
-String WebPlatformStrategies::cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String WebPlatformStrategies::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookieRequestHeaderFieldValue(context, firstParty, url);
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
 }
 
-bool WebPlatformStrategies::getRawCookies(NetworkingContext* context, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
+bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
 {
-    return WebCore::getRawCookies(context, firstParty, url, rawCookies);
+    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
 }
 
-void WebPlatformStrategies::deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
-    WebCore::deleteCookie(context, url, cookieName);
+    WebCore::deleteCookie(session, url, cookieName);
 }
 
 void WebPlatformStrategies::refreshPlugins()
index c3900f2..b3b52cc 100644 (file)
@@ -52,15 +52,12 @@ private:
 
     // WebCore::CookiesStrategy
     virtual void notifyCookiesChanged();
-#if USE(CFNETWORK)
-    virtual RetainPtr<CFHTTPCookieStorageRef> defaultCookieStorage();
-#endif
-    virtual String cookiesForDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual void setCookiesFromDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
-    virtual bool cookiesEnabled(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual String cookieRequestHeaderFieldValue(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual bool getRawCookies(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
-    virtual void deleteCookie(WebCore::NetworkingContext*, const WebCore::KURL&, const String&);
+    virtual String cookiesForDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
+    virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
+    virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::KURL&, const String&);
 
     // WebCore::DatabaseStrategy
     // - Using default implementation.
index cfb89f4..50fa384 100644 (file)
 #if USE(CFNETWORK)
 #include <CFNetwork/CFURLCachePriv.h>
 #include <CFNetwork/CFURLProtocolPriv.h>
-#include <WebCore/CookieStorageCFNet.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h> 
 #endif
 
index 6689b27..9513677 100644 (file)
@@ -1,3 +1,20 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        * WebCoreSupport/PlatformStrategiesWinCE.cpp:
+        (PlatformStrategiesWinCE::cookiesForDOM):
+        (PlatformStrategiesWinCE::setCookiesFromDOM):
+        (PlatformStrategiesWinCE::cookiesEnabled):
+        (PlatformStrategiesWinCE::cookieRequestHeaderFieldValue):
+        (PlatformStrategiesWinCE::getRawCookies):
+        (PlatformStrategiesWinCE::deleteCookie):
+        * WebCoreSupport/PlatformStrategiesWinCE.h:
+        Cookie functions now take a NetworkStorageSession, not a NetworkingContext.
+
 2012-12-18  Alexey Proskuryakov  <ap@apple.com>
 
         Remove unnecessary functions from CookiesStrategy
index 4bd47dc..c1c6f80 100644 (file)
@@ -83,34 +83,34 @@ void PlatformStrategiesWinCE::notifyCookiesChanged()
 {
 }
 
-String PlatformStrategiesWinCE::cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesWinCE::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesForDOM(context, firstParty, url);
+    return WebCore::cookiesForDOM(session, firstParty, url);
 }
 
-void PlatformStrategiesWinCE::setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieString)
+void PlatformStrategiesWinCE::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
-    WebCore::setCookiesFromDOM(context, firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
 }
 
-bool PlatformStrategiesWinCE::cookiesEnabled(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+bool PlatformStrategiesWinCE::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookiesEnabled(context, firstParty, url);
+    return WebCore::cookiesEnabled(session, firstParty, url);
 }
 
-String PlatformStrategiesWinCE::cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String PlatformStrategiesWinCE::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
-    return WebCore::cookieRequestHeaderFieldValue(context, firstParty, url);
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
 }
 
-bool PlatformStrategiesWinCE::getRawCookies(NetworkingContext* context, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
+bool PlatformStrategiesWinCE::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
 {
-    return WebCore::getRawCookies(context, firstParty, url, rawCookies);
+    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
 }
 
-void PlatformStrategiesWinCE::deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void PlatformStrategiesWinCE::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
-    WebCore::deleteCookie(context, url, cookieName);
+    WebCore::deleteCookie(session, url, cookieName);
 }
 
 void PlatformStrategiesWinCE::refreshPlugins()
index 847d7b6..d694a63 100644 (file)
@@ -51,12 +51,12 @@ private:
 
     // WebCore::CookiesStrategy
     virtual void notifyCookiesChanged();
-    virtual String cookiesForDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual void setCookiesFromDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
-    virtual bool cookiesEnabled(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual String cookieRequestHeaderFieldValue(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&);
-    virtual bool getRawCookies(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
-    virtual void deleteCookie(WebCore::NetworkingContext*, const WebCore::KURL&, const String&);
+    virtual String cookiesForDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&);
+    virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&);
+    virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&);
+    virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::KURL&, const String&);
 
     // WebCore::DatabaseStrategy
     // - Using default implementation.
index 498f872..fc62c56 100644 (file)
@@ -1,3 +1,60 @@
+2012-12-22  Alexey Proskuryakov  <ap@apple.com>
+
+        Add a separate class for networking related storage
+        https://bugs.webkit.org/show_bug.cgi?id=105676
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp: We no longer need to create
+        fake RemoteNetworkingContexts here! Use an actual default or private storage session.
+
+        * NetworkProcess/mac/NetworkProcessMainMac.mm: Updated form of WebSystemInterface.h include,
+        it's not a system one.
+
+        * NetworkProcess/mac/RemoteNetworkingContext.h: Expose privateBrowsingSession(),
+        so that NetworkConnectionToWebProcess could use it. We can generalize the interface
+        one we support more sessions.
+
+        * NetworkProcess/mac/RemoteNetworkingContext.mm: This class now only tracks private
+        browsing session, with most other code being in NetworkStorageSession.
+
+        * Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm:
+        * UIProcess/Launcher/efl/ProcessLauncherEfl.cpp:
+        * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp:
+        * WebProcess/WebProcess.cpp:
+        * WebProcess/efl/WebProcessMainEfl.cpp:
+        * WebProcess/gtk/WebProcessMainGtk.cpp:
+        * WebProcess/Downloads/cfnet/DownloadCFNet.cpp:
+        * WebProcess/Downloads/efl/DownloadSoupErrorsEfl.cpp:
+        * WebProcess/Downloads/gtk/DownloadSoupErrorsGtk.cpp:
+        * WebProcess/Downloads/mac/DownloadMac.mm:
+        * WebProcess/Network/WebResourceLoader.cpp:
+        Updated includes for ResourceHandle change. For some ports, the includes could be
+        made more tight, but I have no practical way to do that.
+
+        * WebKit2.xcodeproj/project.pbxproj: Removed WebPlatformStrategiesMac.mm.
+
+        * WebProcess/Cookies/WebCookieManager.cpp:
+        (WebKit::WebCookieManager::getHostnamesWithCookies):
+        (WebKit::WebCookieManager::deleteCookiesForHostname):
+        (WebKit::WebCookieManager::deleteAllCookies):
+        Pass a proper session instead of relying on a strategy to call back to WebKit
+        for default cookie storage (we don't even have strategies initialized in NetworkProcess).
+
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::switchNetworkLoaderToNewTestingSession): Initialize WCSI
+        before calling a function that now uses in in WebCore.
+
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: We no longer need a strategy
+        for default cookie storage! Updated other functions to use sessions.
+
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.h:
+        * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
+        * WebProcess/WebCoreSupport/mac/WebPlatformStrategiesMac.mm: Removed.
+        * WebProcess/WebCoreSupport/win/WebFrameNetworkingContext.h:
+        WebFrameNetworkingContext is now simpler, with more tracking being donre through WebCore.
+
 2012-12-21  Elliott Sprehn  <esprehn@chromium.org>
 
         Replace documentFragmentIsShadowRoot with isTreeScope
index 8e06443..9ce5606 100644 (file)
@@ -144,16 +144,9 @@ void NetworkConnectionToWebProcess::setSerialLoadingEnabled(bool enabled)
     m_serialLoadingEnabled = enabled;
 }
 
-static RemoteNetworkingContext* networkingContext(bool privateBrowsingEnabled)
-{
-    // This networking context is only needed to get storage session from.
-    if (privateBrowsingEnabled) {
-        static RemoteNetworkingContext* context = RemoteNetworkingContext::create(false, false, true).leakRef();
-        return context;
-    } else {
-        static RemoteNetworkingContext* context = RemoteNetworkingContext::create(false, false, false).leakRef();
-        return context;
-    }
+static NetworkStorageSession& storageSession(bool privateBrowsingEnabled)
+{
+    return privateBrowsingEnabled ? RemoteNetworkingContext::privateBrowsingSession() : NetworkStorageSession::defaultStorageSession();
 }
 
 void NetworkConnectionToWebProcess::startDownload(bool privateBrowsingEnabled, uint64_t downloadID, const ResourceRequest& request)
@@ -164,32 +157,32 @@ void NetworkConnectionToWebProcess::startDownload(bool privateBrowsingEnabled, u
 
 void NetworkConnectionToWebProcess::cookiesForDOM(bool privateBrowsingEnabled, const KURL& firstParty, const KURL& url, String& result)
 {
-    result = WebCore::cookiesForDOM(networkingContext(privateBrowsingEnabled), firstParty, url);
+    result = WebCore::cookiesForDOM(storageSession(privateBrowsingEnabled), firstParty, url);
 }
 
 void NetworkConnectionToWebProcess::setCookiesFromDOM(bool privateBrowsingEnabled, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
-    WebCore::setCookiesFromDOM(networkingContext(privateBrowsingEnabled), firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(storageSession(privateBrowsingEnabled), firstParty, url, cookieString);
 }
 
 void NetworkConnectionToWebProcess::cookiesEnabled(bool privateBrowsingEnabled, const KURL& firstParty, const KURL& url, bool& result)
 {
-    result = WebCore::cookiesEnabled(networkingContext(privateBrowsingEnabled), firstParty, url);
+    result = WebCore::cookiesEnabled(storageSession(privateBrowsingEnabled), firstParty, url);
 }
 
 void NetworkConnectionToWebProcess::cookieRequestHeaderFieldValue(bool privateBrowsingEnabled, const KURL& firstParty, const KURL& url, String& result)
 {
-    result = WebCore::cookieRequestHeaderFieldValue(networkingContext(privateBrowsingEnabled), firstParty, url);
+    result = WebCore::cookieRequestHeaderFieldValue(storageSession(privateBrowsingEnabled), firstParty, url);
 }
 
 void NetworkConnectionToWebProcess::getRawCookies(bool privateBrowsingEnabled, const KURL& firstParty, const KURL& url, Vector<Cookie>& result)
 {
-    WebCore::getRawCookies(networkingContext(privateBrowsingEnabled), firstParty, url, result);
+    WebCore::getRawCookies(storageSession(privateBrowsingEnabled), firstParty, url, result);
 }
 
 void NetworkConnectionToWebProcess::deleteCookie(bool privateBrowsingEnabled, const KURL& url, const String& cookieName)
 {
-    WebCore::deleteCookie(networkingContext(privateBrowsingEnabled), url, cookieName);
+    WebCore::deleteCookie(storageSession(privateBrowsingEnabled), url, cookieName);
 }
 
 } // namespace WebKit
index c56f80a..6503eea 100644 (file)
@@ -31,9 +31,9 @@
 #import "CommandLine.h"
 #import "EnvironmentUtilities.h"
 #import "NetworkProcess.h"
+#import "WebSystemInterface.h"
 #import <WebCore/RunLoop.h>
 #import <WebKitSystemInterface.h>
-#import <WebSystemInterface.h>
 #import <mach/mach_error.h>
 #import <runtime/InitializeThreading.h>
 #import <servers/bootstrap.h>
index adf4e32..5c5f163 100644 (file)
@@ -42,6 +42,8 @@ public:
     static void ensurePrivateBrowsingSession();
     static void destroyPrivateBrowsingSession();
 
+    static WebCore::NetworkStorageSession& privateBrowsingSession(); // Can only be called when the session exists.
+
 private:
     RemoteNetworkingContext(bool needsSiteSpecificQuirks, bool localFileContentSniffingEnabled, bool privateBrowsingEnabled);
 
@@ -49,8 +51,7 @@ private:
 
     virtual bool needsSiteSpecificQuirks() const OVERRIDE;
     virtual bool localFileContentSniffingEnabled() const OVERRIDE;
-    virtual bool inPrivateBrowsingMode() const OVERRIDE;
-    virtual CFURLStorageSessionRef storageSession() const OVERRIDE;
+    virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
     virtual NSOperationQueue *scheduledOperationQueue() const OVERRIDE;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
 
index 3c1e72c..de7e0fc 100644 (file)
@@ -35,7 +35,12 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static CFURLStorageSessionRef privateBrowsingStorageSession;
+static OwnPtr<NetworkStorageSession>& privateBrowsingStorageSession()
+{
+    ASSERT(isMainThread());
+    DEFINE_STATIC_LOCAL(OwnPtr<NetworkStorageSession>, session, ());
+    return session;
+}
 
 RemoteNetworkingContext::RemoteNetworkingContext(bool needsSiteSpecificQuirks, bool localFileContentSniffingEnabled, bool privateBrowsingEnabled)
     : m_needsSiteSpecificQuirks(needsSiteSpecificQuirks)
@@ -63,19 +68,20 @@ bool RemoteNetworkingContext::localFileContentSniffingEnabled() const
     return m_localFileContentSniffingEnabled;
 }
 
-bool RemoteNetworkingContext::inPrivateBrowsingMode() const
+NetworkStorageSession& RemoteNetworkingContext::storageSession() const
 {
-    return m_privateBrowsingEnabled;
+    if (m_privateBrowsingEnabled) {
+        ASSERT(privateBrowsingStorageSession());
+        return *privateBrowsingStorageSession();
+    }
+
+    return NetworkStorageSession::defaultStorageSession();
 }
 
-CFURLStorageSessionRef RemoteNetworkingContext::storageSession() const
+NetworkStorageSession& RemoteNetworkingContext::privateBrowsingSession()
 {
-    if (inPrivateBrowsingMode()) {
-        ASSERT(privateBrowsingStorageSession);
-        return privateBrowsingStorageSession;
-    }
-    // FIXME (NetworkProcess): Return a default session that's used for testing.
-    return 0;
+    ASSERT(privateBrowsingStorageSession());
+    return *privateBrowsingStorageSession();
 }
 
 NSOperationQueue *RemoteNetworkingContext::scheduledOperationQueue() const
@@ -108,23 +114,18 @@ void RemoteNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(con
 
 void RemoteNetworkingContext::ensurePrivateBrowsingSession()
 {
-    ASSERT(isMainThread());
-    if (privateBrowsingStorageSession)
+    if (privateBrowsingStorageSession())
         return;
 
     ASSERT(!privateBrowsingStorageSessionIdentifierBase().isNull());
     RetainPtr<CFStringRef> cfIdentifier = String(privateBrowsingStorageSessionIdentifierBase() + ".PrivateBrowsing").createCFString();
 
-    privateBrowsingStorageSession = WKCreatePrivateStorageSession(cfIdentifier.get());
+    privateBrowsingStorageSession() = NetworkStorageSession::createPrivateBrowsingSession(privateBrowsingStorageSessionIdentifierBase());
 }
 
 void RemoteNetworkingContext::destroyPrivateBrowsingSession()
 {
-    if (!privateBrowsingStorageSession)
-        return;
-
-    CFRelease(privateBrowsingStorageSession);
-    privateBrowsingStorageSession = 0;
+    privateBrowsingStorageSession() = nullptr;
 }
 
 }
index 4f39d98..2920f0b 100644 (file)
@@ -22,7 +22,9 @@
 
 #include "Connection.h"
 #include "ProcessExecutablePath.h"
+#include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/FileSystem.h>
+#include <WebCore/NetworkingContext.h>
 #include <WebCore/ResourceHandle.h>
 #include <WebCore/RunLoop.h>
 #include <wtf/text/CString.h>
index f9b8e5b..1b08bd5 100644 (file)
@@ -29,7 +29,9 @@
 
 #include "Connection.h"
 #include "ProcessExecutablePath.h"
+#include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/FileSystem.h>
+#include <WebCore/NetworkingContext.h>
 #include <WebCore/ResourceHandle.h>
 #include <WebCore/RunLoop.h>
 #include <errno.h>
index 00381e4..7ecfa83 100644 (file)
                E1B78473163F253E0007B692 /* RemoteNetworkingContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1B78472163F253E0007B692 /* RemoteNetworkingContext.mm */; };
                E1CC1B9012D7EADF00625838 /* PrintInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = E1CC1B8E12D7EADF00625838 /* PrintInfo.h */; };
                E1CC1B9112D7EADF00625838 /* PrintInfoMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1CC1B8F12D7EADF00625838 /* PrintInfoMac.mm */; };
-               E1D229711652DC5200BAA4BD /* WebPlatformStrategiesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1D2296E1652DB9C00BAA4BD /* WebPlatformStrategiesMac.mm */; };
                E1EDFDA61628868E0039ECDA /* MainMacProcess.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A6FA31011E3921E00DB1371 /* MainMacProcess.cpp */; };
                E1EDFDA7162886960039ECDA /* SharedWorkerProcessMainMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1EDFD9B16287D0B0039ECDA /* SharedWorkerProcessMainMac.mm */; };
                E1EDFDA8162886990039ECDA /* SharedWorkerProcessMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1EDFDA21628838C0039ECDA /* SharedWorkerProcessMac.mm */; };
                E1B78472163F253E0007B692 /* RemoteNetworkingContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteNetworkingContext.mm; sourceTree = "<group>"; };
                E1CC1B8E12D7EADF00625838 /* PrintInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintInfo.h; sourceTree = "<group>"; };
                E1CC1B8F12D7EADF00625838 /* PrintInfoMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrintInfoMac.mm; sourceTree = "<group>"; };
-               E1D2296E1652DB9C00BAA4BD /* WebPlatformStrategiesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPlatformStrategiesMac.mm; sourceTree = "<group>"; };
                E1EDFD9816287BD10039ECDA /* SharedWorkerProcessMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedWorkerProcessMain.h; sourceTree = "<group>"; };
                E1EDFD9B16287D0B0039ECDA /* SharedWorkerProcessMainMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SharedWorkerProcessMainMac.mm; sourceTree = "<group>"; };
                E1EDFD9D16287F190039ECDA /* SharedWorkerProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedWorkerProcess.h; sourceTree = "<group>"; };
                                BC111ADF112F5BC200337BAB /* WebErrorsMac.mm */,
                                9391F283121B38F500EBF7E8 /* WebFrameNetworkingContext.h */,
                                9391F284121B38F500EBF7E8 /* WebFrameNetworkingContext.mm */,
-                               E1D2296E1652DB9C00BAA4BD /* WebPlatformStrategiesMac.mm */,
                                BCC43AC6127B99DE00317F16 /* WebPopupMenuMac.mm */,
                                BCC57159115ADAEF001CCAF9 /* WebSystemInterface.h */,
                                BCC5715A115ADAEF001CCAF9 /* WebSystemInterface.mm */,
                                51217460164C20E30037A5C1 /* ShareableResource.cpp in Sources */,
                                51217464164C21370037A5C1 /* WebResourceBuffer.cpp in Sources */,
                                1AF1AC6B1651759E00C17D7F /* RemoteLayerTreeTransaction.mm in Sources */,
-                               E1D229711652DC5200BAA4BD /* WebPlatformStrategiesMac.mm in Sources */,
                                1AA3D75B1651B44F008713D0 /* RemoteLayerTreeHost.mm in Sources */,
                                1AA3D7611651B7D3008713D0 /* RemoteLayerTreeHostMessageReceiver.cpp in Sources */,
                                51FD18B51651FBAD00DBE1CE /* NetworkResourceLoader.cpp in Sources */,
index 0a6d285..056651f 100644 (file)
@@ -30,6 +30,7 @@
 #include "WebCookieManagerProxyMessages.h"
 #include "WebProcess.h"
 #include <WebCore/CookieStorage.h>
+#include <WebCore/NetworkStorageSession.h>
 #include <WebCore/PlatformCookieJar.h>
 
 using namespace WebCore;
@@ -55,7 +56,7 @@ void WebCookieManager::getHostnamesWithCookies(uint64_t callbackID)
 {
     HashSet<String> hostnames;
 
-    WebCore::getHostnamesWithCookies(0, hostnames);
+    WebCore::getHostnamesWithCookies(NetworkStorageSession::defaultStorageSession(), hostnames);
 
     Vector<String> hostnameList;
     copyToVector(hostnames, hostnameList);
@@ -65,12 +66,12 @@ void WebCookieManager::getHostnamesWithCookies(uint64_t callbackID)
 
 void WebCookieManager::deleteCookiesForHostname(const String& hostname)
 {
-    WebCore::deleteCookiesForHostname(0, hostname);
+    WebCore::deleteCookiesForHostname(NetworkStorageSession::defaultStorageSession(), hostname);
 }
 
 void WebCookieManager::deleteAllCookies()
 {
-    WebCore::deleteAllCookies(0);
+    WebCore::deleteAllCookies(NetworkStorageSession::defaultStorageSession());
 }
 
 void WebCookieManager::startObservingCookieChanges()
index a0f3d0b..49b3861 100644 (file)
@@ -31,6 +31,7 @@
 
 #pragma warning(push, 0)
 #include <WebCore/AuthenticationCF.h>
+#include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/DownloadBundle.h>
 #include <WebCore/LoaderRunLoopCF.h>
 #include <WebCore/NotImplemented.h>
index d1ba587..946f351 100644 (file)
@@ -27,6 +27,7 @@
 #include "DownloadSoupErrors.h"
 
 #include <WebCore/ErrorsEfl.h>
+#include <WebCore/ResourceError.h>
 
 using namespace WebCore;
 
index 0d23e6e..0d3f9d3 100644 (file)
@@ -27,6 +27,7 @@
 #include "DownloadSoupErrors.h"
 
 #include <WebCore/ErrorsGtk.h>
+#include <WebCore/ResourceError.h>
 
 using namespace WebCore;
 
index 9d4e016..1f6ffe2 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "Download.h"
 
+#import <WebCore/AuthenticationChallenge.h>
 #import <WebCore/AuthenticationMac.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/ResourceHandle.h>
index 913d0e4..3ba3ec9 100644 (file)
 #include <WebCore/RuntimeEnabledFeatures.h>
 #endif
 
+#if PLATFORM(MAC)
+#include "WebSystemInterface.h"
+#endif
+
 using namespace WebCore;
 using namespace JSC;
 
@@ -303,7 +307,8 @@ void InjectedBundle::switchNetworkLoaderToNewTestingSession()
 {
 #if (PLATFORM(MAC) || USE(CFNETWORK)) && !PLATFORM(WIN)
     // FIXME (NetworkProcess): Do this in network process, too.
-    WebFrameNetworkingContext::switchToNewTestingSession();
+    InitWebCoreSystemInterface();
+    NetworkStorageSession::switchToNewTestingSession();
 #endif
 }
 
index 56904b0..6c7f834 100644 (file)
@@ -37,6 +37,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebErrors.h"
 #include "WebProcess.h"
+#include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/ResourceLoader.h>
 
 using namespace WebCore;
index 73b1abb..93b357a 100644 (file)
@@ -38,6 +38,7 @@
 #include <WebCore/Color.h>
 #include <WebCore/KURL.h>
 #include <WebCore/LoaderStrategy.h>
+#include <WebCore/NetworkStorageSession.h>
 #include <WebCore/Page.h>
 #include <WebCore/PlatformCookieJar.h>
 #include <WebCore/PlatformPasteboard.h>
@@ -113,90 +114,83 @@ void WebPlatformStrategies::notifyCookiesChanged()
     WebCookieManager::shared().dispatchCookiesDidChange();
 }
 
-#if PLATFORM(WIN) && USE(CFNETWORK)
-RetainPtr<CFHTTPCookieStorageRef> WebPlatformStrategies::defaultCookieStorage()
-{
-    return 0;
-}
-#endif
-
-String WebPlatformStrategies::cookiesForDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String WebPlatformStrategies::cookiesForDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
 #if ENABLE(NETWORK_PROCESS)
     if (WebProcess::shared().usesNetworkProcess()) {
         String result;
-        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesForDOM(context && context->inPrivateBrowsingMode(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesForDOM::Reply(result), 0))
+        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesForDOM(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesForDOM::Reply(result), 0))
             return String();
         return result;
     }
 #endif
 
-    return WebCore::cookiesForDOM(context, firstParty, url);
+    return WebCore::cookiesForDOM(session, firstParty, url);
 }
 
-void WebPlatformStrategies::setCookiesFromDOM(NetworkingContext* context, const KURL& firstParty, const KURL& url, const String& cookieString)
+void WebPlatformStrategies::setCookiesFromDOM(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, const String& cookieString)
 {
 #if ENABLE(NETWORK_PROCESS)
     if (WebProcess::shared().usesNetworkProcess()) {
-        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::SetCookiesFromDOM(context && context->inPrivateBrowsingMode(), firstParty, url, cookieString), 0);
+        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::SetCookiesFromDOM(session.isPrivateBrowsingSession(), firstParty, url, cookieString), 0);
         return;
     }
 #endif
 
-    WebCore::setCookiesFromDOM(context, firstParty, url, cookieString);
+    WebCore::setCookiesFromDOM(session, firstParty, url, cookieString);
 }
 
-bool WebPlatformStrategies::cookiesEnabled(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+bool WebPlatformStrategies::cookiesEnabled(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
 #if ENABLE(NETWORK_PROCESS)
     if (WebProcess::shared().usesNetworkProcess()) {
         bool result;
-        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesEnabled(context && context->inPrivateBrowsingMode(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesEnabled::Reply(result), 0))
+        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookiesEnabled(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookiesEnabled::Reply(result), 0))
             return false;
         return result;
     }
 #endif
 
-    return WebCore::cookiesEnabled(context, firstParty, url);
+    return WebCore::cookiesEnabled(session, firstParty, url);
 }
 
-String WebPlatformStrategies::cookieRequestHeaderFieldValue(NetworkingContext* context, const KURL& firstParty, const KURL& url)
+String WebPlatformStrategies::cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url)
 {
 #if ENABLE(NETWORK_PROCESS)
     if (WebProcess::shared().usesNetworkProcess()) {
         String result;
-        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(context && context->inPrivateBrowsingMode(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue::Reply(result), 0))
+        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::CookieRequestHeaderFieldValue::Reply(result), 0))
             return String();
         return result;
     }
 #endif
 
-    return WebCore::cookieRequestHeaderFieldValue(context, firstParty, url);
+    return WebCore::cookieRequestHeaderFieldValue(session, firstParty, url);
 }
 
-bool WebPlatformStrategies::getRawCookies(NetworkingContext* context, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
+bool WebPlatformStrategies::getRawCookies(const NetworkStorageSession& session, const KURL& firstParty, const KURL& url, Vector<Cookie>& rawCookies)
 {
 #if ENABLE(NETWORK_PROCESS)
     if (WebProcess::shared().usesNetworkProcess()) {
-        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::GetRawCookies(context && context->inPrivateBrowsingMode(), firstParty, url), Messages::NetworkConnectionToWebProcess::GetRawCookies::Reply(rawCookies), 0))
+        if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::GetRawCookies(session.isPrivateBrowsingSession(), firstParty, url), Messages::NetworkConnectionToWebProcess::GetRawCookies::Reply(rawCookies), 0))
             return false;
         return true;
     }
 #endif
 
-    return WebCore::getRawCookies(context, firstParty, url, rawCookies);
+    return WebCore::getRawCookies(session, firstParty, url, rawCookies);
 }
 
-void WebPlatformStrategies::deleteCookie(NetworkingContext* context, const KURL& url, const String& cookieName)
+void WebPlatformStrategies::deleteCookie(const NetworkStorageSession& session, const KURL& url, const String& cookieName)
 {
 #if ENABLE(NETWORK_PROCESS)
     if (WebProcess::shared().usesNetworkProcess()) {
-        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::DeleteCookie(context && context->inPrivateBrowsingMode(), url, cookieName), 0);
+        WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::DeleteCookie(session.isPrivateBrowsingSession(), url, cookieName), 0);
         return;
     }
 #endif
 
-    WebCore::deleteCookie(context, url, cookieName);
+    WebCore::deleteCookie(session, url, cookieName);
 }
 
 // DatabaseStrategy
index e82c92e..efb9148 100644 (file)
@@ -57,15 +57,12 @@ private:
 
     // WebCore::CookiesStrategy
     virtual void notifyCookiesChanged() OVERRIDE;
-#if PLATFORM(MAC) || USE(CFNETWORK)
-    virtual RetainPtr<CFHTTPCookieStorageRef> defaultCookieStorage() OVERRIDE;
-#endif
-    virtual String cookiesForDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
-    virtual void setCookiesFromDOM(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&) OVERRIDE;
-    virtual bool cookiesEnabled(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
-    virtual String cookieRequestHeaderFieldValue(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
-    virtual bool getRawCookies(WebCore::NetworkingContext*, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&) OVERRIDE;
-    virtual void deleteCookie(WebCore::NetworkingContext*, const WebCore::KURL&, const String&) OVERRIDE;
+    virtual String cookiesForDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
+    virtual void setCookiesFromDOM(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&) OVERRIDE;
+    virtual bool cookiesEnabled(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
+    virtual String cookieRequestHeaderFieldValue(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&) OVERRIDE;
+    virtual bool getRawCookies(const WebCore::NetworkStorageSession&, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&) OVERRIDE;
+    virtual void deleteCookie(const WebCore::NetworkStorageSession&, const WebCore::KURL&, const String&) OVERRIDE;
 
     // WebCore::DatabaseStrategy
 #if ENABLE(SQL_DATABASE)
index 39df010..a91c87b 100644 (file)
@@ -34,10 +34,8 @@ public:
     }
 
     static void setPrivateBrowsingStorageSessionIdentifierBase(const String&);
-    static void switchToNewTestingSession();
     static void ensurePrivateBrowsingSession();
     static void destroyPrivateBrowsingSession();
-    static CFURLStorageSessionRef defaultStorageSession();
     static void setCookieAcceptPolicyForAllContexts(HTTPCookieAcceptPolicy);
 
 private:
@@ -48,8 +46,7 @@ private:
 
     virtual bool needsSiteSpecificQuirks() const OVERRIDE;
     virtual bool localFileContentSniffingEnabled() const OVERRIDE;
-    virtual bool inPrivateBrowsingMode() const OVERRIDE;
-    virtual CFURLStorageSessionRef storageSession() const OVERRIDE;
+    virtual WebCore::NetworkStorageSession& storageSession() const OVERRIDE;
     virtual WebCore::SchedulePairHashSet* scheduledRunLoopPairs() const OVERRIDE;
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const OVERRIDE;
 };
index 01d769d..48ef937 100644 (file)
@@ -21,7 +21,6 @@
 #import "config.h"
 #import "WebFrameNetworkingContext.h"
 
-#import <WebCore/CookieStorageCFNet.h>
 #import <WebCore/FrameLoaderClient.h>
 #import <WebCore/Page.h>
 #import <WebCore/ResourceError.h>
@@ -32,8 +31,11 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static CFURLStorageSessionRef defaultCFStorageSession;
-static CFURLStorageSessionRef privateBrowsingStorageSession;
+static OwnPtr<NetworkStorageSession>& privateBrowsingStorageSession()
+{
+    DEFINE_STATIC_LOCAL(OwnPtr<NetworkStorageSession>, session, ());
+    return session;
+}
 
 bool WebFrameNetworkingContext::needsSiteSpecificQuirks() const
 {
@@ -67,26 +69,17 @@ void WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase(c
     privateBrowsingStorageSessionIdentifierBase() = identifier;
 }
 
-void WebFrameNetworkingContext::switchToNewTestingSession()
-{
-    // Set a private session for testing to avoid interfering with global cookies. This should be different from private browsing session.
-    if (defaultCFStorageSession)
-        CFRelease(defaultCFStorageSession);
-    defaultCFStorageSession = WKCreatePrivateStorageSession(CFSTR("Private WebKit Session"));
-}
-
 void WebFrameNetworkingContext::ensurePrivateBrowsingSession()
 {
     // FIXME (NetworkProcess): Don't create an unnecessary session when using network process.
 
     ASSERT(isMainThread());
-    if (privateBrowsingStorageSession)
+    if (privateBrowsingStorageSession())
         return;
 
-    String base = privateBrowsingStorageSessionIdentifierBase().isNull() ? String([[NSBundle mainBundle] bundleIdentifier]) : privateBrowsingStorageSessionIdentifierBase();
-    RetainPtr<CFStringRef> cfIdentifier = String(base + ".PrivateBrowsing").createCFString();
+    String identifierBase = privateBrowsingStorageSessionIdentifierBase().isNull() ? String([[NSBundle mainBundle] bundleIdentifier]) : privateBrowsingStorageSessionIdentifierBase();
 
-    privateBrowsingStorageSession = WKCreatePrivateStorageSession(cfIdentifier.get());
+    privateBrowsingStorageSession() = NetworkStorageSession::createPrivateBrowsingSession(identifierBase);
 }
 
 void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
@@ -94,39 +87,28 @@ void WebFrameNetworkingContext::destroyPrivateBrowsingSession()
     if (!privateBrowsingStorageSession)
         return;
 
-    CFRelease(privateBrowsingStorageSession);
-    privateBrowsingStorageSession = 0;
-}
-
-CFURLStorageSessionRef WebFrameNetworkingContext::defaultStorageSession()
-{
-    return defaultCFStorageSession;
-}
-
-bool WebFrameNetworkingContext::inPrivateBrowsingMode() const
-{
-    return frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled();
+    privateBrowsingStorageSession() = nullptr;
 }
 
-CFURLStorageSessionRef WebFrameNetworkingContext::storageSession() const
+NetworkStorageSession& WebFrameNetworkingContext::storageSession() const
 {
-    if (inPrivateBrowsingMode()) {
-        ASSERT(privateBrowsingStorageSession);
-        return privateBrowsingStorageSession;
+    bool inPrivateBrowsingMode = frame() && frame()->settings() && frame()->settings()->privateBrowsingEnabled();
+    if (inPrivateBrowsingMode) {
+        ASSERT(privateBrowsingStorageSession());
+        return *privateBrowsingStorageSession();
     }
-    return defaultCFStorageSession;
+    return NetworkStorageSession::defaultStorageSession();
 }
 
 void WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts(HTTPCookieAcceptPolicy policy)
 {
     [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:static_cast<NSHTTPCookieAcceptPolicy>(policy)];
 
-    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = defaultCFHTTPCookieStorage())
+    if (RetainPtr<CFHTTPCookieStorageRef> cookieStorage = NetworkStorageSession::defaultStorageSession().cookieStorage())
         WKSetHTTPCookieAcceptPolicy(cookieStorage.get(), policy);
 
-    if (privateBrowsingStorageSession) {
-        RetainPtr<CFHTTPCookieStorageRef> privateBrowsingCookieStorage = adoptCF(WKCopyHTTPCookieStorage(privateBrowsingStorageSession));
-        WKSetHTTPCookieAcceptPolicy(privateBrowsingCookieStorage.get(), policy);
+    if (privateBrowsingStorageSession()) {
+        WKSetHTTPCookieAcceptPolicy(privateBrowsingStorageSession()->cookieStorage().get(), policy);
     }
 }
 
index 54e7b59..459b4ea 100644 (file)
@@ -45,8 +45,7 @@ private:
     virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const;
 
 #if USE(CFNETWORK)
-    virtual bool inPrivateBrowsingMode() const;
-    virtual CFURLStorageSessionRef storageSession() const;
+    virtual WebCore::NetworkStorageSession& storageSession() const;
 #endif
 
     String m_userAgent;
index f7e8fd5..983a5e7 100644 (file)
@@ -55,6 +55,7 @@
 #include <WebCore/JSElement.h>
 #include <WebCore/JSRange.h>
 #include <WebCore/MainResourceLoader.h>
+#include <WebCore/NetworkingContext.h>
 #include <WebCore/NodeTraversal.h>
 #include <WebCore/Page.h>
 #include <WebCore/PluginDocument.h>
@@ -248,7 +249,7 @@ void WebFrame::startDownload(const WebCore::ResourceRequest& request)
 
 #if ENABLE(NETWORK_PROCESS)
     if (WebProcess::shared().usesNetworkProcess()) {
-        bool privateBrowsingEnabled = m_coreFrame->loader()->networkingContext()->inPrivateBrowsingMode();
+        bool privateBrowsingEnabled = m_coreFrame->loader()->networkingContext()->storageSession().isPrivateBrowsingSession();
         WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::StartDownload(privateBrowsingEnabled, policyDownloadID, request), 0);
         return;
     }
index 15cabdc..8d4109e 100644 (file)
@@ -49,6 +49,7 @@
 #import <WebCore/HitTestResult.h>
 #import <WebCore/HTMLConverter.h>
 #import <WebCore/KeyboardEvent.h>
+#import <WebCore/NetworkingContext.h>
 #import <WebCore/Page.h>
 #import <WebCore/PlatformKeyboardEvent.h>
 #import <WebCore/ResourceHandle.h>
@@ -678,7 +679,7 @@ bool WebPage::platformHasLocalDataForURL(const WebCore::KURL& url)
     NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];
     [request setValue:(NSString*)userAgent() forHTTPHeaderField:@"User-Agent"];
     NSCachedURLResponse *cachedResponse;
-    if (CFURLStorageSessionRef storageSession = corePage()->mainFrame()->loader()->networkingContext()->storageSession())
+    if (CFURLStorageSessionRef storageSession = corePage()->mainFrame()->loader()->networkingContext()->storageSession().platformSession())
         cachedResponse = WKCachedResponseForRequest(storageSession, request);
     else
         cachedResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:request];
@@ -692,7 +693,7 @@ static NSCachedURLResponse *cachedResponseForURL(WebPage* webPage, const KURL& u
     RetainPtr<NSMutableURLRequest> request(AdoptNS, [[NSMutableURLRequest alloc] initWithURL:url]);
     [request.get() setValue:(NSString *)webPage->userAgent() forHTTPHeaderField:@"User-Agent"];
 
-    if (CFURLStorageSessionRef storageSession = webPage->corePage()->mainFrame()->loader()->networkingContext()->storageSession())
+    if (CFURLStorageSessionRef storageSession = webPage->corePage()->mainFrame()->loader()->networkingContext()->storageSession().platformSession())
         return WKCachedResponseForRequest(storageSession, request.get());
 
     return [[NSURLCache sharedURLCache] cachedResponseForRequest:request.get()];
index 1b480a7..58ecc24 100644 (file)
@@ -55,6 +55,7 @@
 #include <JavaScriptCore/MemoryStatistics.h>
 #include <WebCore/AXObjectCache.h>
 #include <WebCore/ApplicationCacheStorage.h>
+#include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/CrossOriginPreflightResultCache.h>
 #include <WebCore/Font.h>
 #include <WebCore/FontCache.h>
index 64f509c..3e8420a 100644 (file)
@@ -32,6 +32,8 @@
 #include "WKBase.h"
 #include <Ecore.h>
 #include <Efreet.h>
+#include <WebCore/AuthenticationChallenge.h>
+#include <WebCore/NetworkingContext.h>
 #include <WebCore/ResourceHandle.h>
 #include <WebCore/RunLoop.h>
 #include <WebKit2/WebProcess.h>
index 3a07e49..d286c5e 100644 (file)
@@ -30,6 +30,8 @@
 #define LIBSOUP_USE_UNSTABLE_REQUEST_API
 
 #include "WKBase.h"
+#include <WebCore/AuthenticationChallenge.h>
+#include <WebCore/NetworkingContext.h>
 #include <WebCore/ResourceHandle.h>
 #include <WebCore/RunLoop.h>
 #include <WebKit2/WebProcess.h>