Remove global initializer in CookieStorageCFNet.cpp
authorpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Feb 2011 00:13:58 +0000 (00:13 +0000)
committerpsolanki@apple.com <psolanki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Feb 2011 00:13:58 +0000 (00:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=54905

Reviewed by Darin Adler.

* platform/network/cf/CookieStorageCFNet.cpp:
(WebCore::currentCookieStorage):
(WebCore::setCurrentCookieStorage):
(WebCore::setCookieStoragePrivateBrowsingEnabled):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/network/cf/CookieStorageCFNet.cpp

index b45bf45..a783ab0 100644 (file)
@@ -1,3 +1,15 @@
+2011-02-21  Pratik Solanki  <psolanki@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Remove global initializer in CookieStorageCFNet.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=54905
+
+        * platform/network/cf/CookieStorageCFNet.cpp:
+        (WebCore::currentCookieStorage):
+        (WebCore::setCurrentCookieStorage):
+        (WebCore::setCookieStoragePrivateBrowsingEnabled):
+
 2011-02-18  Jer Noble  <jer.noble@apple.com>
 
         Reviewed by Sam Weinig.
index 3deb688..13e7451 100644 (file)
 
 namespace WebCore {
 
-static RetainPtr<CFHTTPCookieStorageRef> s_cookieStorage;
+static CFHTTPCookieStorageRef s_cookieStorage;
 
 CFHTTPCookieStorageRef currentCookieStorage()
 {
     ASSERT(isMainThread());
 
     if (s_cookieStorage)
-        return s_cookieStorage.get();
+        return s_cookieStorage;
     return wkGetDefaultHTTPCookieStorage();
 }
 
@@ -50,6 +50,10 @@ void setCurrentCookieStorage(CFHTTPCookieStorageRef cookieStorage)
 {
     ASSERT(isMainThread());
 
+    CFRetain(cookieStorage);
+    if (s_cookieStorage)
+        CFRelease(s_cookieStorage);
+
     s_cookieStorage = cookieStorage;
 }
 
@@ -57,8 +61,11 @@ void setCookieStoragePrivateBrowsingEnabled(bool enabled)
 {
     ASSERT(isMainThread());
 
+    if (s_cookieStorage)
+        CFRelease(s_cookieStorage);
+
     if (enabled)
-        s_cookieStorage.adoptCF(wkCreatePrivateHTTPCookieStorage());
+        s_cookieStorage = wkCreatePrivateHTTPCookieStorage();
     else
         s_cookieStorage = 0;
 }