Use RetainPtr to store WebPreferences::m_privatePrefs
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2007 21:24:18 +0000 (21:24 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Aug 2007 21:24:18 +0000 (21:24 +0000)
        Reviewed by Darin.

        * WebPreferences.cpp:
        (WebPreferences::setStringValue):
        (WebPreferences::setIntegerValue):
        (WebPreferences::setBoolValue):
        (WebPreferences::initWithIdentifier):
        * WebPreferences.h:

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

WebKit/win/ChangeLog
WebKit/win/WebPreferences.cpp
WebKit/win/WebPreferences.h

index 377c68669548c5036390a341e8c22b242ff08fd5..a199957cedc30fe2d020ef267c60a78d84b6319b 100644 (file)
@@ -1,3 +1,16 @@
+2007-08-12  Adam Roben  <aroben@apple.com>
+
+        Use RetainPtr to store WebPreferences::m_privatePrefs
+
+        Reviewed by Darin.
+
+        * WebPreferences.cpp:
+        (WebPreferences::setStringValue):
+        (WebPreferences::setIntegerValue):
+        (WebPreferences::setBoolValue):
+        (WebPreferences::initWithIdentifier):
+        * WebPreferences.h:
+
 2007-08-12  Adam Roben  <aroben@apple.com>
 
         Fix <rdar://problem/5278790> Hole for find-on-page match in subframe isn't clipped by frame bounds
index 79bd23ada1b142f57c32dcdd97c3f075937222dd..807d440f8054efddb1d9916bb12f368e799aa52e 100644 (file)
@@ -44,7 +44,6 @@
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <wtf/HashMap.h>
 #include <wtf/OwnPtr.h>
-#include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
 
 static unsigned long long WebSystemMainMemory()
@@ -65,7 +64,6 @@ static HashMap<WebCore::String, WebPreferences*> webPreferencesInstances;
 
 WebPreferences::WebPreferences()
 : m_refCount(0)
-, m_privatePrefs(0)
 , m_autoSaves(0)
 {
     gClassCount++;
@@ -73,8 +71,6 @@ WebPreferences::WebPreferences()
 
 WebPreferences::~WebPreferences()
 {
-    if (m_privatePrefs)
-        CFRelease(m_privatePrefs);
     gClassCount--;
 }
 
@@ -339,7 +335,7 @@ void WebPreferences::initialize()
 
 const void* WebPreferences::valueForKey(CFStringRef key)
 {
-    const void* value = CFDictionaryGetValue(m_privatePrefs, key);
+    const void* value = CFDictionaryGetValue(m_privatePrefs.get(), key);
     if (!value)
         value = CFDictionaryGetValue(m_standardUserDefaults, key);
 
@@ -429,7 +425,7 @@ void WebPreferences::setStringValue(CFStringRef key, LPCTSTR value)
     
     RetainPtr<CFStringRef> valueRef(AdoptCF,
         CFStringCreateWithCharactersNoCopy(0, (UniChar*)_wcsdup(value), (CFIndex)_tcslen(value), kCFAllocatorMalloc));
-    CFDictionarySetValue(m_privatePrefs, key, valueRef.get());
+    CFDictionarySetValue(m_privatePrefs.get(), key, valueRef.get());
     if (m_autoSaves) {
         CFDictionarySetValue(m_standardUserDefaults, key, valueRef.get());
         save();
@@ -450,7 +446,7 @@ void WebPreferences::setIntegerValue(CFStringRef key, int value)
         return;
 
     RetainPtr<CFNumberRef> valueRef(AdoptCF, CFNumberCreate(0, kCFNumberSInt32Type, &value));
-    CFDictionarySetValue(m_privatePrefs, key, valueRef.get());
+    CFDictionarySetValue(m_privatePrefs.get(), key, valueRef.get());
     if (m_autoSaves) {
         CFDictionarySetValue(m_standardUserDefaults, key, valueRef.get());
         save();
@@ -464,7 +460,7 @@ void WebPreferences::setBoolValue(CFStringRef key, BOOL value)
     if (boolValueForKey(key) == value)
         return;
 
-    CFDictionarySetValue(m_privatePrefs, key, value ? kCFBooleanTrue : kCFBooleanFalse);
+    CFDictionarySetValue(m_privatePrefs.get(), key, value ? kCFBooleanTrue : kCFBooleanFalse);
     if (m_autoSaves) {
         CFDictionarySetValue(m_standardUserDefaults, key, value ? kCFBooleanTrue : kCFBooleanFalse);
         save();
@@ -685,9 +681,7 @@ HRESULT STDMETHODCALLTYPE WebPreferences::initWithIdentifier(
 
     load();
 
-    if (m_privatePrefs)
-        CFRelease(m_privatePrefs);
-    m_privatePrefs = CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    m_privatePrefs.adoptCF(CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
 
     *preferences = this;
     AddRef();
index e53b9a3dd962486c8c1f17d45bc3462881d91099..c2ec506e1d6e91f3c454aeec7d4dbbebe34a596b 100644 (file)
@@ -29,9 +29,9 @@
 #include "IWebPreferences.h"
 #include <CoreFoundation/CoreFoundation.h>
 #include <WebCore/BString.h>
+#include <wtf/RetainPtr.h>
 
-class WebPreferences : public IWebPreferences
-{
+class WebPreferences : public IWebPreferences {
 public:
     static WebPreferences* createInstance();
 protected:
@@ -301,7 +301,7 @@ protected:
 
 protected:
     ULONG m_refCount;
-    CFMutableDictionaryRef m_privatePrefs;
+    RetainPtr<CFMutableDictionaryRef> m_privatePrefs;
     bool m_autoSaves;
     WebCore::BString m_identifier;
     static CFMutableDictionaryRef m_standardUserDefaults;