String::createCFString should return a RetainPtr
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Oct 2012 16:10:14 +0000 (16:10 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Oct 2012 16:10:14 +0000 (16:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=100419

Reviewed by Andreas Kling.

Source/WebCore:

Update callers of String::createCFString.

* bridge/objc/objc_runtime.mm:
(JSC::Bindings::callObjCFallbackObject):
* html/HTMLMediaElement.cpp:
(WebCore::createFileURLForApplicationCacheResource):
* loader/archive/cf/LegacyWebArchive.cpp:
(WebCore::LegacyWebArchive::createPropertyListRepresentation):
* platform/LocalizedStrings.cpp:
(WebCore::formatLocalizedString):
(WebCore::contextMenuItemTagLookUpInDictionary):
(WebCore::keygenKeychainItemName):
(WebCore::imageTitle):
* platform/RuntimeApplicationChecks.cpp:
(WebCore::mainBundleIsEqualTo):
* platform/cf/FileSystemCF.cpp:
(WebCore::fileSystemRepresentation):
(WebCore::pathAsURL):
* platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
(PlatformCAAnimation::PlatformCAAnimation):
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(resubmitAllAnimations):
(PlatformCALayer::addAnimationForKey):
(PlatformCALayer::removeAnimationForKey):
(PlatformCALayer::setName):
* platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
(PlatformCALayerWinInternal::updateTiles):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::utiFromMIMEType):
* platform/graphics/cg/ImageSourceCGMac.mm:
(WebCore::MIMETypeForImageSourceType):
(WebCore::preferredExtensionForImageSourceType):
* platform/mac/ClipboardMac.mm:
(WebCore::cocoaTypeFromHTMLClipboardType):
(WebCore::utiTypeFromCocoaType):
* platform/mac/SSLKeyGeneratorMac.cpp:
(WebCore::signedPublicKeyAndChallengeString):
* platform/network/cf/AuthenticationCF.cpp:
(WebCore::createCF):
* platform/network/cf/CookieJarCFNet.cpp:
(WebCore::setCookies):
* platform/network/cf/DNSCFNet.cpp:
(WebCore::DNSResolveQueue::platformResolve):
* platform/network/cf/ResourceErrorCF.cpp:
(WebCore::ResourceError::cfError):
* platform/network/cf/ResourceHandleCFNet.cpp:
(WebCore::setDefaultMIMEType):
(WebCore::willSendRequest):
(WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
(WebCore::ResourceHandle::setPrivateBrowsingEnabled):
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::setHeaderFields):
(WebCore::ResourceRequest::doUpdatePlatformRequest):
* platform/network/cf/ResourceResponseCFNet.cpp:
(WebCore::ResourceResponse::cfURLResponse):
* platform/network/cf/SocketStreamHandleCFNet.cpp:
(WebCore::SocketStreamHandle::createStreams):
(WebCore::SocketStreamHandle::addCONNECTCredentials):
(WebCore::SocketStreamHandle::copyCFStreamDescription):
* platform/network/mac/ResourceRequestMac.mm:
(WebCore::ResourceRequest::doUpdatePlatformRequest):
* platform/network/mac/WebCoreURLResponse.mm:
(WebCore::adjustMIMETypeIfNecessary):
* platform/text/cf/HyphenationCF.cpp:
(WebCore::::createValueForKey):
* platform/text/cf/StringCF.cpp:
(WTF::String::createCFString):
* platform/text/cf/StringImplCF.cpp:
(WTF::StringImpl::createCFString):
* platform/text/mac/StringImplMac.mm:
(WTF::StringImpl::operator NSString *):
* platform/text/mac/TextCodecMac.cpp:
(WebCore::TextCodecMac::encode):
* platform/win/SearchPopupMenuWin.cpp:
(WebCore::autosaveKey):
(WebCore::SearchPopupMenuWin::saveRecentSearches):

Source/WebKit/cf:

Update callers of String::createCFString.

* WebCoreSupport/WebInspectorClientCF.cpp:
(createKeyForPreferences):
(populateSetting):
(storeSetting):

Source/WebKit/win:

Update callers of String::createCFString.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDidFailToStartPlugin):
* WebDatabaseManager.cpp:
(WebDatabaseManager::dispatchDidModifyDatabase):
* WebHistory.cpp:
(WebHistory::visitedURL):
(WebHistory::itemForURLString):
* WebHistoryItem.cpp:
(WebHistoryItem::dictionaryRepresentation):
* WebIconDatabase.cpp:
(WebIconDatabase::iconDatabaseNotificationUserInfoURLKey):
(postDidAddIconNotification):
* WebLocalizableStrings.cpp:
(createWebKitBundle):
(copyLocalizedStringFromBundle):
* WebPreferences.cpp:
(WebPreferences::initializeDefaultSettings):
* WebView.cpp:
(WebView::setCacheModel):
(WebView::notifyPreferencesChanged):

Source/WebKit2:

Update callers of String::createCFString.

* Platform/mac/ModuleMac.mm:
(WebKit::Module::load):
* PluginProcess/mac/PluginProcessMac.mm:
(WebKit::initializeSandbox):
* Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
(WebKit::NetscapePluginModule::getPluginInfo):
(WebKit::NetscapePluginModule::createPluginMIMETypesPreferences):
* UIProcess/cf/WebBackForwardListCF.cpp:
(WebKit::WebBackForwardList::createCFDictionaryRepresentation):
* UIProcess/cf/WebPageProxyCF.cpp:
(WebKit::WebPageProxy::sessionStateData):
(WebKit::autosaveKey):
(WebKit::WebPageProxy::saveRecentSearches):
* WebProcess/ResourceCache/WebResourceCacheManager.cpp:
(WebKit::WebResourceCacheManager::clearCacheForOrigin):
* WebProcess/WebPage/win/WebPageWin.cpp:
(WebKit::cachedResponseForURL):
* WebProcess/win/WebProcessWin.cpp:
(WebKit::WebProcess::platformSetCacheModel):
(WebKit::WebProcess::platformInitializeWebProcess):

Source/WTF:

Make String::createCFString and StringImpl::createCFString return RetainPtrs.

* wtf/text/AtomicString.h:
* wtf/text/StringImpl.h:
* wtf/text/WTFString.h:

Tools:

Update callers of String::createCFString.

* WebKitTestRunner/InjectedBundle/mac/InjectedBundlePageMac.mm:
(WTR::InjectedBundlePage::platformDidStartProvisionalLoadForFrame):

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

55 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringImpl.h
Source/WTF/wtf/text/WTFString.h
Source/WebCore/ChangeLog
Source/WebCore/bridge/objc/objc_runtime.mm
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/loader/archive/cf/LegacyWebArchive.cpp
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/RuntimeApplicationChecks.cpp
Source/WebCore/platform/cf/FileSystemCF.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp
Source/WebCore/platform/graphics/cg/ImageSourceCGMac.mm
Source/WebCore/platform/mac/ClipboardMac.mm
Source/WebCore/platform/mac/SSLKeyGeneratorMac.cpp
Source/WebCore/platform/network/cf/AuthenticationCF.cpp
Source/WebCore/platform/network/cf/CookieJarCFNet.cpp
Source/WebCore/platform/network/cf/DNSCFNet.cpp
Source/WebCore/platform/network/cf/ResourceErrorCF.cpp
Source/WebCore/platform/network/cf/ResourceHandleCFNet.cpp
Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp
Source/WebCore/platform/network/cf/ResourceResponseCFNet.cpp
Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp
Source/WebCore/platform/network/mac/ResourceRequestMac.mm
Source/WebCore/platform/network/mac/WebCoreURLResponse.mm
Source/WebCore/platform/text/cf/HyphenationCF.cpp
Source/WebCore/platform/text/cf/StringCF.cpp
Source/WebCore/platform/text/cf/StringImplCF.cpp
Source/WebCore/platform/text/mac/StringImplMac.mm
Source/WebCore/platform/text/mac/TextCodecMac.cpp
Source/WebCore/platform/win/SearchPopupMenuWin.cpp
Source/WebKit/cf/ChangeLog
Source/WebKit/cf/WebCoreSupport/WebInspectorClientCF.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/win/WebDatabaseManager.cpp
Source/WebKit/win/WebHistory.cpp
Source/WebKit/win/WebHistoryItem.cpp
Source/WebKit/win/WebIconDatabase.cpp
Source/WebKit/win/WebLocalizableStrings.cpp
Source/WebKit/win/WebPreferences.cpp
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/mac/ModuleMac.mm
Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm
Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm
Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp
Source/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
Source/WebKit2/WebProcess/win/WebProcessWin.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundlePageMac.mm

index ba46f88..4aefd10 100644 (file)
@@ -1,3 +1,16 @@
+2012-10-29  Anders Carlsson  <andersca@apple.com>
+
+        String::createCFString should return a RetainPtr
+        https://bugs.webkit.org/show_bug.cgi?id=100419
+
+        Reviewed by Andreas Kling.
+
+        Make String::createCFString and StringImpl::createCFString return RetainPtrs.
+
+        * wtf/text/AtomicString.h:
+        * wtf/text/StringImpl.h:
+        * wtf/text/WTFString.h:
+
 2012-10-30  Mark Rowe  <mrowe@apple.com>
 
         Fix WTF to not install a few header files in bogus locations.
index 09ef646..eb4662c 100644 (file)
@@ -67,6 +67,7 @@ struct CharBufferFromLiteralDataTranslator;
 class MemoryObjectInfo;
 struct SubstringTranslator;
 struct UCharBufferTranslator;
+template<typename> class RetainPtr;
 
 enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive };
 
@@ -714,7 +715,7 @@ public:
     WTF_EXPORT_STRING_API WTF::Unicode::Direction defaultWritingDirection(bool* hasStrongDirectionality = 0);
 
 #if USE(CF)
-    CFStringRef createCFString();
+    RetainPtr<CFStringRef> createCFString();
 #endif
 #ifdef __OBJC__
     operator NSString*();
index e58baed..624eb54 100644 (file)
 #include <objc/objc.h>
 #endif
 
-#if USE(CF)
-typedef const struct __CFString * CFStringRef;
-#endif
-
 #if PLATFORM(QT)
 QT_BEGIN_NAMESPACE
 class QString;
@@ -392,7 +388,7 @@ public:
 
 #if USE(CF)
     String(CFStringRef);
-    CFStringRef createCFString() const;
+    RetainPtr<CFStringRef> createCFString() const;
 #endif
 
 #ifdef __OBJC__
index 412ddb3..0e806cf 100644 (file)
@@ -1,3 +1,87 @@
+2012-10-29  Anders Carlsson  <andersca@apple.com>
+
+        String::createCFString should return a RetainPtr
+        https://bugs.webkit.org/show_bug.cgi?id=100419
+
+        Reviewed by Andreas Kling.
+
+        Update callers of String::createCFString.
+
+        * bridge/objc/objc_runtime.mm:
+        (JSC::Bindings::callObjCFallbackObject):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::createFileURLForApplicationCacheResource):
+        * loader/archive/cf/LegacyWebArchive.cpp:
+        (WebCore::LegacyWebArchive::createPropertyListRepresentation):
+        * platform/LocalizedStrings.cpp:
+        (WebCore::formatLocalizedString):
+        (WebCore::contextMenuItemTagLookUpInDictionary):
+        (WebCore::keygenKeychainItemName):
+        (WebCore::imageTitle):
+        * platform/RuntimeApplicationChecks.cpp:
+        (WebCore::mainBundleIsEqualTo):
+        * platform/cf/FileSystemCF.cpp:
+        (WebCore::fileSystemRepresentation):
+        (WebCore::pathAsURL):
+        * platform/graphics/ca/win/PlatformCAAnimationWin.cpp:
+        (PlatformCAAnimation::PlatformCAAnimation):
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        (resubmitAllAnimations):
+        (PlatformCALayer::addAnimationForKey):
+        (PlatformCALayer::removeAnimationForKey):
+        (PlatformCALayer::setName):
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
+        (PlatformCALayerWinInternal::updateTiles):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::utiFromMIMEType):
+        * platform/graphics/cg/ImageSourceCGMac.mm:
+        (WebCore::MIMETypeForImageSourceType):
+        (WebCore::preferredExtensionForImageSourceType):
+        * platform/mac/ClipboardMac.mm:
+        (WebCore::cocoaTypeFromHTMLClipboardType):
+        (WebCore::utiTypeFromCocoaType):
+        * platform/mac/SSLKeyGeneratorMac.cpp:
+        (WebCore::signedPublicKeyAndChallengeString):
+        * platform/network/cf/AuthenticationCF.cpp:
+        (WebCore::createCF):
+        * platform/network/cf/CookieJarCFNet.cpp:
+        (WebCore::setCookies):
+        * platform/network/cf/DNSCFNet.cpp:
+        (WebCore::DNSResolveQueue::platformResolve):
+        * platform/network/cf/ResourceErrorCF.cpp:
+        (WebCore::ResourceError::cfError):
+        * platform/network/cf/ResourceHandleCFNet.cpp:
+        (WebCore::setDefaultMIMEType):
+        (WebCore::willSendRequest):
+        (WebCore::ResourceHandle::didReceiveAuthenticationChallenge):
+        (WebCore::ResourceHandle::setPrivateBrowsingEnabled):
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::setHeaderFields):
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        * platform/network/cf/ResourceResponseCFNet.cpp:
+        (WebCore::ResourceResponse::cfURLResponse):
+        * platform/network/cf/SocketStreamHandleCFNet.cpp:
+        (WebCore::SocketStreamHandle::createStreams):
+        (WebCore::SocketStreamHandle::addCONNECTCredentials):
+        (WebCore::SocketStreamHandle::copyCFStreamDescription):
+        * platform/network/mac/ResourceRequestMac.mm:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        * platform/network/mac/WebCoreURLResponse.mm:
+        (WebCore::adjustMIMETypeIfNecessary):
+        * platform/text/cf/HyphenationCF.cpp:
+        (WebCore::::createValueForKey):
+        * platform/text/cf/StringCF.cpp:
+        (WTF::String::createCFString):
+        * platform/text/cf/StringImplCF.cpp:
+        (WTF::StringImpl::createCFString):
+        * platform/text/mac/StringImplMac.mm:
+        (WTF::StringImpl::operator NSString *):
+        * platform/text/mac/TextCodecMac.cpp:
+        (WebCore::TextCodecMac::encode):
+        * platform/win/SearchPopupMenuWin.cpp:
+        (WebCore::autosaveKey):
+        (WebCore::SearchPopupMenuWin::saveRecentSearches):
+
 2012-10-30  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Support embedded SVG objects in AX tree
index 2cf0db5..be24fdb 100644 (file)
@@ -248,8 +248,7 @@ static EncodedJSValue JSC_HOST_CALL callObjCFallbackObject(ExecState* exec)
         ObjcClass* objcClass = static_cast<ObjcClass*>(objcInstance->getClass());
         OwnPtr<ObjcMethod> fallbackMethod(adoptPtr(new ObjcMethod(objcClass->isa(), @selector(invokeUndefinedMethodFromWebScript:withArguments:))));
         const String& nameIdentifier = static_cast<ObjcFallbackObjectImp*>(exec->callee())->propertyName();
-        RetainPtr<CFStringRef> name(AdoptCF, nameIdentifier.createCFString());
-        fallbackMethod->setJavaScriptName(name.get());
+        fallbackMethod->setJavaScriptName(nameIdentifier.createCFString().get());
         result = objcInstance->invokeObjcMethod(exec, fallbackMethod.get());
     }
             
index 458eac6..e9cd1af 100644 (file)
@@ -916,8 +916,7 @@ static KURL createFileURLForApplicationCacheResource(const String& path)
     // app cache media files are always created with encodeForFileName(createCanonicalUUIDString()).
 
 #if USE(CF) && PLATFORM(WIN)
-    RetainPtr<CFStringRef> cfPath(AdoptCF, path.createCFString());
-    RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, cfPath.get(), kCFURLWindowsPathStyle, false));
+    RetainPtr<CFURLRef> cfURL(AdoptCF, CFURLCreateWithFileSystemPath(0, path.createCFString().get(), kCFURLWindowsPathStyle, false));
     KURL url(cfURL.get());
 #else
     KURL url;
index 3576d64..d77f874 100644 (file)
@@ -91,8 +91,7 @@ RetainPtr<CFDictionaryRef> LegacyWebArchive::createPropertyListRepresentation(Ar
     CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceDataKey, cfData.get());
     
     // Resource URL cannot be null
-    RetainPtr<CFStringRef> cfURL(AdoptCF, resource->url().string().createCFString());
-    if (cfURL)
+    if (RetainPtr<CFStringRef> cfURL = resource->url().string().createCFString())
         CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceURLKey, cfURL.get());
     else {
         LOG(Archives, "LegacyWebArchive - NULL resource URL is invalid - returning null property list");
@@ -101,23 +100,17 @@ RetainPtr<CFDictionaryRef> LegacyWebArchive::createPropertyListRepresentation(Ar
 
     // FrameName should be left out if empty for subresources, but always included for main resources
     const String& frameName(resource->frameName());
-    if (!frameName.isEmpty() || isMainResource) {
-        RetainPtr<CFStringRef> cfFrameName(AdoptCF, frameName.createCFString());
-        CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceFrameNameKey, cfFrameName.get());
-    }
+    if (!frameName.isEmpty() || isMainResource)
+        CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceFrameNameKey, frameName.createCFString().get());
     
     // Set MIMEType, TextEncodingName, and ResourceResponse only if they actually exist
     const String& mimeType(resource->mimeType());
-    if (!mimeType.isEmpty()) {
-        RetainPtr<CFStringRef> cfMIMEType(AdoptCF, mimeType.createCFString());
-        CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceMIMETypeKey, cfMIMEType.get());
-    }
+    if (!mimeType.isEmpty())
+        CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceMIMETypeKey, mimeType.createCFString().get());
     
     const String& textEncoding(resource->textEncoding());
-    if (!textEncoding.isEmpty()) {
-        RetainPtr<CFStringRef> cfTextEncoding(AdoptCF, textEncoding.createCFString());
-        CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceTextEncodingNameKey, cfTextEncoding.get());
-    }
+    if (!textEncoding.isEmpty())
+        CFDictionarySetValue(propertyList.get(), LegacyWebArchiveResourceTextEncodingNameKey, textEncoding.createCFString().get());
 
     // Don't include the resource response for the main resource
     if (!isMainResource) {
index abf1bca..690843b 100644 (file)
@@ -54,13 +54,12 @@ static String formatLocalizedString(String format, ...)
 #if USE(CF)
     va_list arguments;
     va_start(arguments, format);
-    RetainPtr<CFStringRef> formatCFString(AdoptCF, format.createCFString());
 
 #if COMPILER(CLANG)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wformat-nonliteral"
 #endif
-    RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments));
+    RetainPtr<CFStringRef> result = adoptCF(CFStringCreateWithFormatAndArguments(0, 0, format.createCFString().get(), arguments));
 #if COMPILER(CLANG)
 #pragma clang diagnostic pop
 #endif
@@ -260,7 +259,7 @@ String contextMenuItemTagLookUpInDictionary(const String& selectedString)
     return WEB_UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item");
 #else
 #if USE(CF)
-    RetainPtr<CFStringRef> selectedCFString(AdoptCF, truncatedStringForLookupMenuItem(selectedString).createCFString());
+    RetainPtr<CFStringRef> selectedCFString = truncatedStringForLookupMenuItem(selectedString).createCFString();
     return formatLocalizedString(WEB_UI_STRING("Look Up “%@”", "Look Up context menu item with selected word"), selectedCFString.get());
 #else
     return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));
@@ -738,8 +737,7 @@ String keygenMenuItem2048()
 
 String keygenKeychainItemName(const String& host)
 {
-    RetainPtr<CFStringRef> hostCFString(AdoptCF, host.createCFString());
-    return formatLocalizedString(WEB_UI_STRING("Key from %@", "Name of keychain key generated by the KEYGEN tag"), hostCFString.get());
+    return formatLocalizedString(WEB_UI_STRING("Key from %@", "Name of keychain key generated by the KEYGEN tag"), host.createCFString().get());
 }
 
 #endif
@@ -762,8 +760,7 @@ String imageTitle(const String& filename, const IntSize& size)
 {
 #if USE(CF)
 #if !PLATFORM(MAC) || PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
-    RetainPtr<CFStringRef> filenameCFString(AdoptCF, filename.createCFString());
-    RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCopyCurrent());
+    RetainPtr<CFLocaleRef> locale = adoptCF(CFLocaleCopyCurrent());
     RetainPtr<CFNumberFormatterRef> formatter(AdoptCF, CFNumberFormatterCreate(0, locale.get(), kCFNumberFormatterDecimalStyle));
 
     int widthInt = size.width();
@@ -774,7 +771,7 @@ String imageTitle(const String& filename, const IntSize& size)
     RetainPtr<CFNumberRef> height(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &heightInt));
     RetainPtr<CFStringRef> heightString(AdoptCF, CFNumberFormatterCreateStringWithNumber(0, formatter.get(), height.get()));
 
-    return formatLocalizedString(WEB_UI_STRING("%@ %@×%@ pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filenameCFString.get(), widthString.get(), heightString.get());
+    return formatLocalizedString(WEB_UI_STRING("%@ %@×%@ pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename.createCFString().get(), widthString.get(), heightString.get());
 #else
     RetainPtr<CFStringRef> filenameCFString(AdoptCF, filename.createCFString());
     return formatLocalizedString(WEB_UI_STRING("%@ %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filenameCFString.get(), size.width(), size.height());
index 1b8d006..730edc1 100644 (file)
@@ -46,8 +46,7 @@ static bool mainBundleIsEqualTo(const String& bundleIdentifierString)
     if (!bundleIdentifier)
         return false;
 
-    RetainPtr<CFStringRef> bundleIdentifierToCompare(AdoptCF, bundleIdentifierString.createCFString());
-    return CFStringCompare(bundleIdentifier, bundleIdentifierToCompare.get(), 0) == kCFCompareEqualTo;
+    return CFStringCompare(bundleIdentifier, bundleIdentifierString.createCFString().get(), 0) == kCFCompareEqualTo;
 #else
     UNUSED_PARAM(bundleIdentifierString);
     return false;
index 8ef50ee..ffea905 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
 CString fileSystemRepresentation(const String& path)
 {
-    RetainPtr<CFStringRef> cfString(AdoptCF, path.createCFString());
+    RetainPtr<CFStringRef> cfString = path.createCFString();
 
     if (!cfString)
         return CString();
@@ -63,8 +63,7 @@ RetainPtr<CFURLRef> pathAsURL(const String& path)
 #else
     pathStyle = kCFURLPOSIXPathStyle;
 #endif
-    return RetainPtr<CFURLRef>(AdoptCF, CFURLCreateWithFileSystemPath(0,
-        RetainPtr<CFStringRef>(AdoptCF, path.createCFString()).get(), pathStyle, FALSE));
+    return adoptCF(CFURLCreateWithFileSystemPath(0, path.createCFString().get(), pathStyle, FALSE));
 }
 
 } // namespace WebCore
index 97fb0b6..856a4fc 100644 (file)
@@ -151,8 +151,7 @@ PlatformCAAnimation::PlatformCAAnimation(AnimationType type, const String& keyPa
     else
         m_animation.adoptCF(CACFAnimationCreate(kCACFKeyframeAnimation));
     
-    RetainPtr<CFStringRef> s(AdoptCF, keyPath.createCFString());
-    CACFAnimationSetKeyPath(m_animation.get(), s.get());
+    CACFAnimationSetKeyPath(m_animation.get(), keyPath.createCFString().get());
 }
 
 PlatformCAAnimation::PlatformCAAnimation(PlatformAnimationRef animation)
index 70168b2..dd61633 100644 (file)
@@ -176,10 +176,8 @@ void PlatformCALayer::animationStarted(CFTimeInterval beginTime)
 static void resubmitAllAnimations(PlatformCALayer* layer)
 {
     HashMap<String, RefPtr<PlatformCAAnimation> >::const_iterator end = layer->animations().end();
-    for (HashMap<String, RefPtr<PlatformCAAnimation> >::const_iterator it = layer->animations().begin(); it != end; ++it) {
-        RetainPtr<CFStringRef> s(AdoptCF, it->key.createCFString());
-        CACFLayerAddAnimation(layer->platformLayer(), s.get(), it->value->platformAnimation());
-    }
+    for (HashMap<String, RefPtr<PlatformCAAnimation> >::const_iterator it = layer->animations().begin(); it != end; ++it)
+        CACFLayerAddAnimation(layer->platformLayer(), it->key.createCFString().get(), it->value->platformAnimation());
 }
 
 void PlatformCALayer::ensureAnimationsSubmitted()
@@ -297,8 +295,7 @@ void PlatformCALayer::addAnimationForKey(const String& key, PlatformCAAnimation*
     // Add it to the animation list
     m_animations.add(key, animation);
 
-    RetainPtr<CFStringRef> s(AdoptCF, key.createCFString());
-    CACFLayerAddAnimation(m_layer.get(), s.get(), animation->platformAnimation());
+    CACFLayerAddAnimation(m_layer.get(), key.createCFString().get(), animation->platformAnimation());
     setNeedsCommit();
 
     // Tell the host about it so we can fire the start animation event
@@ -312,8 +309,7 @@ void PlatformCALayer::removeAnimationForKey(const String& key)
     // Remove it from the animation list
     m_animations.remove(key);
 
-    RetainPtr<CFStringRef> s(AdoptCF, key.createCFString());
-    CACFLayerRemoveAnimation(m_layer.get(), s.get());
+    CACFLayerRemoveAnimation(m_layer.get(), key.createCFString().get());
 
     // We don't "remove" a layer from AbstractCACFLayerTreeHost when it loses an animation.
     // There may be other active animations on the layer and if an animation
@@ -586,8 +582,7 @@ String PlatformCALayer::name() const
 
 void PlatformCALayer::setName(const String& value)
 {
-    RetainPtr<CFStringRef> s(AdoptCF, value.createCFString());
-    CACFLayerSetName(m_layer.get(), s.get());
+    CACFLayerSetName(m_layer.get(), value.createCFString().get());
     setNeedsCommit();
 }
 
index c430cf2..15275b3 100644 (file)
@@ -459,7 +459,7 @@ void PlatformCALayerWinInternal::updateTiles()
 
 #ifndef NDEBUG
             String name = "Tile (" + String::number(i) + "," + String::number(j) + ")";
-            CACFLayerSetName(tile, RetainPtr<CFStringRef>(AdoptCF, name.createCFString()).get());
+            CACFLayerSetName(tile, name.createCFString().get());
 #endif
         }
     }
index 21e9db4..dd37815 100644 (file)
@@ -377,8 +377,7 @@ static inline CFStringRef jpegUTI()
 static RetainPtr<CFStringRef> utiFromMIMEType(const String& mimeType)
 {
 #if PLATFORM(MAC)
-    RetainPtr<CFStringRef> mimeTypeCFString(AdoptCF, mimeType.createCFString());
-    return RetainPtr<CFStringRef>(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeTypeCFString.get(), 0));
+    return adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType.createCFString().get(), 0));
 #else
     ASSERT(isMainThread()); // It is unclear if CFSTR is threadsafe.
 
index bd50a31..953bcb9 100644 (file)
@@ -33,16 +33,12 @@ namespace WebCore {
 
 String MIMETypeForImageSourceType(const String& uti)
 {
-    RetainPtr<CFStringRef> utiref(AdoptCF, uti.createCFString());
-    RetainPtr<CFStringRef> mime(AdoptCF, UTTypeCopyPreferredTagWithClass(utiref.get(), kUTTagClassMIMEType));
-    return mime.get();
+    return adoptCF(UTTypeCopyPreferredTagWithClass(uti.createCFString().get(), kUTTagClassMIMEType)).get();
 }
 
 String preferredExtensionForImageSourceType(const String& uti)
 {
-    RetainPtr<CFStringRef> type(AdoptCF, uti.createCFString());
-    RetainPtr<CFStringRef> extension(AdoptCF, UTTypeCopyPreferredTagWithClass(type.get(), kUTTagClassFilenameExtension));
-    return extension.get();
+    return adoptCF(UTTypeCopyPreferredTagWithClass(uti.createCFString().get(), kUTTagClassFilenameExtension)).get();
 }
 
 } // namespace WebCore
index bd88020..fd4ab99 100644 (file)
@@ -99,11 +99,10 @@ static String cocoaTypeFromHTMLClipboardType(const String& type)
 
     // Try UTI now
     String mimeType = qType;
-    RetainPtr<CFStringRef> utiType(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType.createCFString(), NULL));
-    if (utiType) {
-        CFStringRef pbType = UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType);
+    if (RetainPtr<CFStringRef> utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType.createCFString().get(), NULL))) {
+        RetainPtr<CFStringRef> pbType = adoptCF(UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassNSPboardType));
         if (pbType)
-            return pbType;
+            return pbType.get();
     }
 
     // No mapping, just pass the whole string though
@@ -112,11 +111,8 @@ static String cocoaTypeFromHTMLClipboardType(const String& type)
 
 static String utiTypeFromCocoaType(const String& type)
 {
-    RetainPtr<CFStringRef> typeCF = adoptCF(type.createCFString());
-    RetainPtr<CFStringRef> utiType(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, typeCF.get(), 0));
-    if (utiType) {
-        RetainPtr<CFStringRef> mimeType(AdoptCF, UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassMIMEType));
-        if (mimeType)
+    if (RetainPtr<CFStringRef> utiType = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassNSPboardType, type.createCFString().get(), 0))) {
+        if (RetainPtr<CFStringRef> mimeType = adoptCF(UTTypeCopyPreferredTagWithClass(utiType.get(), kUTTagClassMIMEType)))
             return String(mimeType.get());
     }
     return String();
index 0a1a4d8..e58d9a9 100644 (file)
@@ -60,11 +60,7 @@ String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& ch
         return String();
     }
 
-    RetainPtr<CFStringRef> challengeStringCF(AdoptCF, challengeString.createCFString());
-    RetainPtr<CFStringRef> keyDescription(AdoptCF, keygenKeychainItemName(url.host()).createCFString());
-    RetainPtr<CFStringRef> result(AdoptCF, wkSignedPublicKeyAndChallengeString(keySize, challengeStringCF.get(), keyDescription.get()));
-
-    return result.get();
+    return adoptCF(wkSignedPublicKeyAndChallengeString(keySize, challengeString.createCFString().get(), keygenKeychainItemName(url.host()).createCFString().get())).get();
 }
 
 }
index 87a3fab..7b1d4fa 100644 (file)
@@ -119,13 +119,7 @@ CFURLCredentialRef createCF(const Credential& coreCredential)
         return CFURLCredentialCreateWithIdentityAndCertificateArray(kCFAllocatorDefault, coreCredential.identity(), coreCredential.certificates(), persistence);
 #endif
 
-    CFStringRef user = coreCredential.user().createCFString();
-    CFStringRef password = coreCredential.password().createCFString();
-    CFURLCredentialRef result = CFURLCredentialCreate(0, user, password, 0, persistence);
-    CFRelease(user);
-    CFRelease(password);
-
-    return result;
+    return CFURLCredentialCreate(0, coreCredential.user().createCFString().get(), coreCredential.password().createCFString().get(), 0, persistence);
 }
 
 CFURLProtectionSpaceRef createCF(const ProtectionSpace& coreSpace)
@@ -192,13 +186,7 @@ CFURLProtectionSpaceRef createCF(const ProtectionSpace& coreSpace)
         ASSERT_NOT_REACHED();
     }
 
-    CFStringRef host = coreSpace.host().createCFString();
-    CFStringRef realm = coreSpace.realm().createCFString();
-    CFURLProtectionSpaceRef result = CFURLProtectionSpaceCreate(0, host, coreSpace.port(), serverType, realm, scheme);
-    CFRelease(host);
-    CFRelease(realm);
-    
-    return result;
+    return CFURLProtectionSpaceCreate(0, coreSpace.host().createCFString().get(), coreSpace.port(), serverType, coreSpace.realm().createCFString().get(), scheme);
 }
 
 Credential core(CFURLCredentialRef cfCredential)
index 5d6d739..5017971 100644 (file)
@@ -112,7 +112,7 @@ void setCookies(Document* document, const KURL& url, const String& value)
     // cookiesWithResponseHeaderFields doesn't parse cookies without a value
     String cookieString = value.contains('=') ? value : value + "=";
 
-    RetainPtr<CFStringRef> cookieStringCF(AdoptCF, cookieString.createCFString());
+    RetainPtr<CFStringRef> cookieStringCF = cookieString.createCFString();
     RetainPtr<CFDictionaryRef> headerFieldsCF(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault,
         (const void**)&s_setCookieKeyCF, (const void**)&cookieStringCF, 1,
         &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
index 3f901a5..ce14519 100644 (file)
@@ -90,12 +90,12 @@ void DNSResolveQueue::platformResolve(const String& hostname)
 {
     ASSERT(isMainThread());
 
-    RetainPtr<CFStringRef> hostnameCF(AdoptCF, hostname.createCFString());
-    RetainPtr<CFHostRef> host(AdoptCF, CFHostCreateWithName(0, hostnameCF.get()));
+    RetainPtr<CFHostRef> host = adoptCF(CFHostCreateWithName(0, hostname.createCFString().get()));
     if (!host) {
         decrementRequestCount();
         return;
     }
+
     CFHostClientContext context = { 0, 0, 0, 0, 0 };
     CFHostRef leakedHost = host.leakRef(); // The host will be released from clientCallback().
     Boolean result = CFHostSetClient(leakedHost, clientCallback, &context);
index 354fd27..5895ed9 100644 (file)
@@ -145,13 +145,11 @@ CFErrorRef ResourceError::cfError() const
     if (!m_platformError) {
         RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
 
-        if (!m_localizedDescription.isEmpty()) {
-            RetainPtr<CFStringRef> localizedDescriptionString(AdoptCF, m_localizedDescription.createCFString());
-            CFDictionarySetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey, localizedDescriptionString.get());
-        }
+        if (!m_localizedDescription.isEmpty())
+            CFDictionarySetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey, m_localizedDescription.createCFString().get());
 
         if (!m_failingURL.isEmpty()) {
-            RetainPtr<CFStringRef> failingURLString(AdoptCF, m_failingURL.createCFString());
+            RetainPtr<CFStringRef> failingURLString = m_failingURL.createCFString();
             CFDictionarySetValue(userInfo.get(), failingURLStringKey, failingURLString.get());
             RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithString(0, failingURLString.get(), 0));
             CFDictionarySetValue(userInfo.get(), failingURLKey, url.get());
@@ -162,8 +160,7 @@ CFErrorRef ResourceError::cfError() const
             wkSetSSLPeerCertificateData(userInfo.get(), m_certificate.get());
 #endif
         
-        RetainPtr<CFStringRef> domainString(AdoptCF, m_domain.createCFString());
-        m_platformError.adoptCF(CFErrorCreate(0, domainString.get(), m_errorCode, userInfo.get()));
+        m_platformError = adoptCF(CFErrorCreate(0, m_domain.createCFString().get(), m_errorCode, userInfo.get()));
     }
 
     return m_platformError.get();
index 01e8b8a..8070c25 100644 (file)
@@ -131,7 +131,7 @@ static HashMap<String, RetainPtr<CFDataRef> >& clientCerts()
 
 static void setDefaultMIMEType(CFURLResponseRef response)
 {
-    static CFStringRef defaultMIMETypeString = defaultMIMEType().createCFString();
+    static CFStringRef defaultMIMETypeString = defaultMIMEType().createCFString().leakRef();
     
     CFURLResponseSetMIMEType(response, defaultMIMETypeString);
 }
@@ -161,8 +161,8 @@ static CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef
     if (cfRedirectResponse) {
         CFHTTPMessageRef httpMessage = CFURLResponseGetHTTPResponse(cfRedirectResponse);
         if (httpMessage && CFHTTPMessageGetResponseStatusCode(httpMessage) == 307) {
-            RetainPtr<CFStringRef> lastHTTPMethod(AdoptCF, handle->lastHTTPMethod().createCFString());
-            RetainPtr<CFStringRef> newMethod(AdoptCF, CFURLRequestCopyHTTPRequestMethod(cfRequest));
+            RetainPtr<CFStringRef> lastHTTPMethod = handle->lastHTTPMethod().createCFString();
+            RetainPtr<CFStringRef> newMethod = adoptCF(CFURLRequestCopyHTTPRequestMethod(cfRequest));
             if (CFStringCompareWithOptions(lastHTTPMethod.get(), newMethod.get(), CFRangeMake(0, CFStringGetLength(lastHTTPMethod.get())), kCFCompareCaseInsensitive)) {
                 RetainPtr<CFMutableURLRequestRef> mutableRequest(AdoptCF, CFURLRequestCreateMutableCopy(0, cfRequest));
 #if USE(CFURLSTORAGESESSIONS)
@@ -175,9 +175,8 @@ static CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef
                     WebCore::setHTTPBody(mutableRequest.get(), body);
 
                 String originalContentType = handle->firstRequest().httpContentType();
-                RetainPtr<CFStringRef> originalContentTypeCF(AdoptCF, originalContentType.createCFString());
                 if (!originalContentType.isEmpty())
-                    CFURLRequestSetHTTPHeaderFieldValue(mutableRequest.get(), CFSTR("Content-Type"), originalContentTypeCF.get());
+                    CFURLRequestSetHTTPHeaderFieldValue(mutableRequest.get(), CFSTR("Content-Type"), originalContentType.createCFString().get());
 
                 request = mutableRequest.get();
             }
@@ -607,10 +606,7 @@ void ResourceHandle::didReceiveAuthenticationChallenge(const AuthenticationChall
 #endif
 
     if (!d->m_user.isNull() && !d->m_pass.isNull()) {
-        RetainPtr<CFStringRef> user(AdoptCF, d->m_user.createCFString());
-        RetainPtr<CFStringRef> pass(AdoptCF, d->m_pass.createCFString());
-        RetainPtr<CFURLCredentialRef> credential(AdoptCF,
-            CFURLCredentialCreate(kCFAllocatorDefault, user.get(), pass.get(), 0, kCFURLCredentialPersistenceNone));
+        RetainPtr<CFURLCredentialRef> credential = adoptCF(CFURLCredentialCreate(kCFAllocatorDefault, d->m_user.createCFString().get(), d->m_pass.createCFString().get(), 0, kCFURLCredentialPersistenceNone));
         
         KURL urlToStore;
         if (challenge.failureResponse().httpStatusCode() == 401)
@@ -1005,7 +1001,7 @@ void ResourceHandle::setPrivateBrowsingEnabled(bool enabled)
         return;
 
     String base = privateBrowsingStorageSessionIdentifierBase().isNull() ? privateBrowsingStorageSessionIdentifierDefaultBase() : privateBrowsingStorageSessionIdentifierBase();
-    RetainPtr<CFStringRef> cfIdentifier(AdoptCF, String(base + ".PrivateBrowsing").createCFString());
+    RetainPtr<CFStringRef> cfIdentifier = String(base + ".PrivateBrowsing").createCFString();
 
     privateStorageSession() = createPrivateBrowsingStorageSession(cfIdentifier.get());
 }
index 0232c54..586831a 100644 (file)
@@ -118,14 +118,8 @@ static inline void setHeaderFields(CFMutableURLRequestRef request, const HTTPHea
             CFURLRequestSetHTTPHeaderFieldValue(request, oldHeaderFieldNames[i], 0);
     }
 
-    HTTPHeaderMap::const_iterator end = requestHeaders.end();
-    for (HTTPHeaderMap::const_iterator it = requestHeaders.begin(); it != end; ++it) {
-        CFStringRef key = it->key.string().createCFString();
-        CFStringRef value = it->value.createCFString();
-        CFURLRequestSetHTTPHeaderFieldValue(request, key, value);
-        CFRelease(key);
-        CFRelease(value);
-    }
+    for (HTTPHeaderMap::const_iterator it = requestHeaders.begin(), end = requestHeaders.end(); it != end; ++it)
+        CFURLRequestSetHTTPHeaderFieldValue(request, it->key.string().createCFString().get(), it->value.createCFString().get());
 }
 
 void ResourceRequest::doUpdatePlatformRequest()
@@ -146,8 +140,7 @@ void ResourceRequest::doUpdatePlatformRequest()
     wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), cfRequest);
 #endif
 
-    RetainPtr<CFStringRef> requestMethod(AdoptCF, httpMethod().createCFString());
-    CFURLRequestSetHTTPRequestMethod(cfRequest, requestMethod.get());
+    CFURLRequestSetHTTPRequestMethod(cfRequest, httpMethod().createCFString().get());
 
     if (httpPipeliningEnabled())
         wkSetHTTPPipeliningPriority(cfRequest, toHTTPPipeliningPriority(m_priority));
@@ -164,7 +157,7 @@ void ResourceRequest::doUpdatePlatformRequest()
     unsigned fallbackCount = m_responseContentDispositionEncodingFallbackArray.size();
     RetainPtr<CFMutableArrayRef> encodingFallbacks(AdoptCF, CFArrayCreateMutable(kCFAllocatorDefault, fallbackCount, 0));
     for (unsigned i = 0; i != fallbackCount; ++i) {
-        RetainPtr<CFStringRef> encodingName(AdoptCF, m_responseContentDispositionEncodingFallbackArray[i].createCFString());
+        RetainPtr<CFStringRef> encodingName = m_responseContentDispositionEncodingFallbackArray[i].createCFString();
         CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding(encodingName.get());
         if (encoding != kCFStringEncodingInvalidId)
             CFArrayAppendValue(encodingFallbacks.get(), reinterpret_cast<const void*>(encoding));
index a45beed..9550836 100644 (file)
@@ -51,9 +51,7 @@ CFURLResponseRef ResourceResponse::cfURLResponse() const
 {
     if (!m_cfResponse && !m_isNull) {
         RetainPtr<CFURLRef> url(AdoptCF, m_url.createCFURL());
-        RetainPtr<CFStringRef> mimeType(AdoptCF, m_mimeType.createCFString());
-        RetainPtr<CFStringRef> textEncodingName(AdoptCF, m_textEncodingName.createCFString());
-        m_cfResponse.adoptCF(CFURLResponseCreate(0, url.get(), mimeType.get(), m_expectedContentLength, textEncodingName.get(), kCFURLCacheStorageAllowed));
+        m_cfResponse.adoptCF(CFURLResponseCreate(0, url.get(), m_mimeType.createCFString().get(), m_expectedContentLength, m_textEncodingName.createCFString().get(), kCFURLCacheStorageAllowed));
     }
 
     return m_cfResponse.get();
index d86c76b..4a7cd90 100644 (file)
@@ -269,7 +269,7 @@ void SocketStreamHandle::createStreams()
     if (m_connectionType == Unknown)
         return;
 
-    RetainPtr<CFStringRef> host(AdoptCF, m_url.host().createCFString());
+    RetainPtr<CFStringRef> host = m_url.host().createCFString();
 
     // Creating streams to final destination, not to proxy.
     CFReadStreamRef readStream = 0;
@@ -359,12 +359,10 @@ void SocketStreamHandle::addCONNECTCredentials(CFHTTPMessageRef proxyResponse)
     String password;
     if (!m_sentStoredCredentials && getStoredCONNECTProxyCredentials(protectionSpace, login, password)) {
         // Try to apply stored credentials, if we haven't tried those already.
-        RetainPtr<CFStringRef> loginCF(AdoptCF, login.createCFString());
-        RetainPtr<CFStringRef> passwordCF(AdoptCF, password.createCFString());
-        // Creating a temporary request to make CFNetwork apply credentials to it. Unfortunately, this cannot work with NTLM authentication.
+        // Create a temporary request to make CFNetwork apply credentials to it. Unfortunately, this cannot work with NTLM authentication.
         RetainPtr<CFHTTPMessageRef> dummyRequest(AdoptCF, CFHTTPMessageCreateRequest(0, CFSTR("GET"), m_httpsURL.get(), kCFHTTPVersion1_1));
 
-        Boolean appliedCredentials = CFHTTPMessageApplyCredentials(dummyRequest.get(), authentication.get(), loginCF.get(), passwordCF.get(), 0);
+        Boolean appliedCredentials = CFHTTPMessageApplyCredentials(dummyRequest.get(), authentication.get(), login.createCFString().get(), password.createCFString().get(), 0);
         ASSERT_UNUSED(appliedCredentials, appliedCredentials);
 
         RetainPtr<CFStringRef> proxyAuthorizationString(AdoptCF, CFHTTPMessageCopyHeaderFieldValue(dummyRequest.get(), CFSTR("Proxy-Authorization")));
@@ -389,7 +387,7 @@ void SocketStreamHandle::addCONNECTCredentials(CFHTTPMessageRef proxyResponse)
 CFStringRef SocketStreamHandle::copyCFStreamDescription(void* info)
 {
     SocketStreamHandle* handle = static_cast<SocketStreamHandle*>(info);
-    return String("WebKit socket stream, " + handle->m_url.string()).createCFString();
+    return String("WebKit socket stream, " + handle->m_url.string()).createCFString().leakRef();
 }
 
 struct MainThreadEventCallbackInfo {
index 93216cb..e693484 100644 (file)
@@ -163,9 +163,9 @@ void ResourceRequest::doUpdatePlatformRequest()
         NSMutableArray *encodingFallbacks = [NSMutableArray array];
         unsigned count = m_responseContentDispositionEncodingFallbackArray.size();
         for (unsigned i = 0; i != count; ++i) {
-            CFStringRef encodingName = m_responseContentDispositionEncodingFallbackArray[i].createCFString();
-            unsigned long nsEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding(encodingName));
-            CFRelease(encodingName);
+            RetainPtr<CFStringRef> encodingName = m_responseContentDispositionEncodingFallbackArray[i].createCFString();
+            unsigned long nsEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding(encodingName.get()));
+
             if (nsEncoding != kCFStringEncodingInvalidId)
                 [encodingFallbacks addObject:[NSNumber numberWithUnsignedLong:nsEncoding]];
         }
index 6aa76f6..f9710b2 100644 (file)
@@ -478,7 +478,7 @@ void adjustMIMETypeIfNecessary(CFURLResponseRef cfResponse)
     }
     
     if (!result) {
-        static CFStringRef defaultMIMETypeString = WebCore::defaultMIMEType().createCFString();
+        static CFStringRef defaultMIMETypeString = WebCore::defaultMIMEType().createCFString().leakRef();
         result = defaultMIMETypeString;
     }
 
index 261a93b..1b616eb 100644 (file)
@@ -46,8 +46,7 @@ RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::creat
 template<>
 RetainPtr<CFLocaleRef> AtomicStringKeyedMRUCache<RetainPtr<CFLocaleRef> >::createValueForKey(const AtomicString& localeIdentifier)
 {
-    RetainPtr<CFStringRef> cfLocaleIdentifier(AdoptCF, localeIdentifier.string().createCFString());
-    RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCreate(kCFAllocatorDefault, cfLocaleIdentifier.get()));
+    RetainPtr<CFLocaleRef> locale = adoptCF(CFLocaleCreate(kCFAllocatorDefault, localeIdentifier.string().createCFString().get()));
 
     return CFStringIsHyphenationAvailableForLocale(locale.get()) ? locale : 0;
 }
index d7cda79..2697e76 100644 (file)
@@ -23,8 +23,8 @@
 #include <wtf/text/WTFString.h>
 
 #if USE(CF)
-
 #include <CoreFoundation/CoreFoundation.h>
+#include <wtf/RetainPtr.h>
 
 namespace WTF {
 
@@ -51,7 +51,7 @@ String::String(CFStringRef str)
     }
 }
 
-CFStringRef String::createCFString() const
+RetainPtr<CFStringRef> String::createCFString() const
 {
     if (!m_impl)
         return CFSTR("");
index 7a2d82e..1da561b 100644 (file)
@@ -26,6 +26,7 @@
 #include <CoreFoundation/CoreFoundation.h>
 #include <wtf/MainThread.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
 #include <wtf/Threading.h>
 
 #if PLATFORM(MAC)
@@ -132,7 +133,7 @@ namespace StringWrapperCFAllocator {
 
 }
 
-CFStringRef StringImpl::createCFString()
+RetainPtr<CFStringRef> StringImpl::createCFString()
 {
     if (!m_length || !isMainThread()) {
         if (is8Bit())
@@ -153,7 +154,7 @@ CFStringRef StringImpl::createCFString()
     // CoreFoundation might not have to allocate anything, we clear currentString in case we did not execute allocate().
     StringWrapperCFAllocator::currentString = 0;
 
-    return string;
+    return adoptCF(string);
 }
 
 // On StringImpl creation we could check if the allocator is the StringWrapperCFAllocator.
index 6f5e953..2f088a7 100644 (file)
 #include <wtf/text/StringImpl.h>
 
 #include "FoundationExtras.h"
+#include <wtf/RetainPtr.h>
 
 namespace WTF {
 
 StringImpl::operator NSString *()
 {
-    return HardAutorelease(createCFString());
+    return HardAutorelease(createCFString().leakRef());
 }
 
 }
index 312412f..a704749 100644 (file)
@@ -284,7 +284,7 @@ CString TextCodecMac::encode(const UChar* characters, size_t length, Unencodable
     // Encoding will change the yen sign back into a backslash.
     String copy(characters, length);
     copy.replace('\\', m_backslashAsCurrencySymbol);
-    RetainPtr<CFStringRef> cfs(AdoptCF, copy.createCFString());
+    RetainPtr<CFStringRef> cfs = copy.createCFString();
 
     CFIndex startPos = 0;
     CFIndex charactersLeft = CFStringGetLength(cfs.get());
index a5ca9b7..0d251df 100644 (file)
@@ -51,8 +51,7 @@ bool SearchPopupMenuWin::enabled()
 #if USE(CF)
 static RetainPtr<CFStringRef> autosaveKey(const String& name)
 {
-    String key = "com.apple.WebKit.searchField:" + name;
-    return RetainPtr<CFStringRef>(AdoptCF, key.createCFString());
+    return String("com.apple.WebKit.searchField:" + name).createCFString();
 }
 #endif
 
@@ -67,10 +66,8 @@ void SearchPopupMenuWin::saveRecentSearches(const AtomicString& name, const Vect
     size_t size = searchItems.size();
     if (size) {
         items.adoptCF(CFArrayCreateMutable(0, size, &kCFTypeArrayCallBacks));
-        for (size_t i = 0; i < size; ++i) {
-            RetainPtr<CFStringRef> item(AdoptCF, searchItems[i].createCFString());
-            CFArrayAppendValue(items.get(), item.get());
-        }
+        for (size_t i = 0; i < size; ++i)
+            CFArrayAppendValue(items.get(), searchItems[i].createCFString().get());
     }
 
     CFPreferencesSetAppValue(autosaveKey(name).get(), items.get(), kCFPreferencesCurrentApplication);
index 5863e92..9000d81 100644 (file)
@@ -1,3 +1,17 @@
+2012-10-29  Anders Carlsson  <andersca@apple.com>
+
+        String::createCFString should return a RetainPtr
+        https://bugs.webkit.org/show_bug.cgi?id=100419
+
+        Reviewed by Andreas Kling.
+
+        Update callers of String::createCFString.
+
+        * WebCoreSupport/WebInspectorClientCF.cpp:
+        (createKeyForPreferences):
+        (populateSetting):
+        (storeSetting):
+
 2012-09-05  Sam Weinig  <sam@webkit.org>
 
         Part 2 of removing PlatformString.h, remove PlatformString.h
index 83747f2..337daca 100644 (file)
@@ -63,15 +63,14 @@ using namespace WebCore;
 
 static const char* inspectorStartsAttachedSetting = "inspectorStartsAttached";
 
-static inline CFStringRef createKeyForPreferences(const String& key)
+static inline RetainPtr<CFStringRef> createKeyForPreferences(const String& key)
 {
-    RetainPtr<CFStringRef> keyCFString(AdoptCF, key.createCFString());
-    return CFStringCreateWithFormat(0, 0, CFSTR("WebKit Web Inspector Setting - %@"), keyCFString.get());
+    return adoptCF(CFStringCreateWithFormat(0, 0, CFSTR("WebKit Web Inspector Setting - %@"), key.createCFString().get()));
 }
 
 static void populateSetting(const String& key, String* setting)
 {
-    RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
+    RetainPtr<CFStringRef> preferencesKey = createKeyForPreferences(key);
     RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(preferencesKey.get(), kCFPreferencesCurrentApplication));
 
     if (!value)
@@ -88,12 +87,7 @@ static void populateSetting(const String& key, String* setting)
 
 static void storeSetting(const String& key, const String& setting)
 {
-    RetainPtr<CFPropertyListRef> objectToStore;
-    objectToStore.adoptCF(setting.createCFString());
-    ASSERT(objectToStore);
-
-    RetainPtr<CFStringRef> preferencesKey(AdoptCF, createKeyForPreferences(key));
-    CFPreferencesSetAppValue(preferencesKey.get(), objectToStore.get(), kCFPreferencesCurrentApplication);
+    CFPreferencesSetAppValue(createKeyForPreferences(key).get(), setting.createCFString().get(), kCFPreferencesCurrentApplication);
 }
 
 bool WebInspectorClient::sendMessageToFrontend(const String& message)
index 11d50b1..4fa6e93 100644 (file)
@@ -1,3 +1,33 @@
+2012-10-29  Anders Carlsson  <andersca@apple.com>
+
+        String::createCFString should return a RetainPtr
+        https://bugs.webkit.org/show_bug.cgi?id=100419
+
+        Reviewed by Andreas Kling.
+
+        Update callers of String::createCFString.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::dispatchDidFailToStartPlugin):
+        * WebDatabaseManager.cpp:
+        (WebDatabaseManager::dispatchDidModifyDatabase):
+        * WebHistory.cpp:
+        (WebHistory::visitedURL):
+        (WebHistory::itemForURLString):
+        * WebHistoryItem.cpp:
+        (WebHistoryItem::dictionaryRepresentation):
+        * WebIconDatabase.cpp:
+        (WebIconDatabase::iconDatabaseNotificationUserInfoURLKey):
+        (postDidAddIconNotification):
+        * WebLocalizableStrings.cpp:
+        (createWebKitBundle):
+        (copyLocalizedStringFromBundle):
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings):
+        * WebView.cpp:
+        (WebView::setCacheModel):
+        (WebView::notifyPreferencesChanged):
+
 2012-10-24  Brady Eidson  <beidson@apple.com>
 
         Add a strategy for loader customization.
index 0e4b106..5f28350 100644 (file)
@@ -792,24 +792,20 @@ void WebFrameLoaderClient::dispatchDidFailToStartPlugin(const PluginView* plugin
         KURL pluginPageURL = frame->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(pluginView->pluginsPage()));
         if (pluginPageURL.protocolIsInHTTPFamily()) {
             static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInPageURLStringKey);
-            RetainPtr<CFStringRef> str(AdoptCF, pluginPageURL.string().createCFString());
-            CFDictionarySetValue(userInfo.get(), key, str.get());
+            CFDictionarySetValue(userInfo.get(), key, pluginPageURL.string().createCFString().get());
         }
     }
 
     if (!pluginView->mimeType().isNull()) {
         static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorMIMETypeKey);
-
-        RetainPtr<CFStringRef> str(AdoptCF, pluginView->mimeType().createCFString());
-        CFDictionarySetValue(userInfo.get(), key, str.get());
+        CFDictionarySetValue(userInfo.get(), key, pluginView->mimeType().createCFString().get());
     }
 
     if (pluginView->plugin()) {
         String pluginName = pluginView->plugin()->name();
         if (!pluginName.isNull()) {
             static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInNameKey);
-            RetainPtr<CFStringRef> str(AdoptCF, pluginName.createCFString());
-            CFDictionarySetValue(userInfo.get(), key, str.get());
+            CFDictionarySetValue(userInfo.get(), key, pluginName.createCFString().get());
         }
     }
 
index 6e687f1..15872e3 100644 (file)
@@ -401,8 +401,7 @@ void WebDatabaseManager::dispatchDidModifyDatabase(SecurityOrigin* origin, const
     RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
 
     static CFStringRef databaseNameKey = MarshallingHelpers::LPCOLESTRToCFStringRef(WebDatabaseNameKey);
-    RetainPtr<CFStringRef> str(AdoptCF, databaseName.createCFString());
-    CFDictionarySetValue(userInfo.get(), databaseNameKey, str.get());
+    CFDictionarySetValue(userInfo.get(), databaseNameKey, databaseName.createCFString().get());
 
     COMPtr<CFDictionaryPropertyBag> userInfoBag = CFDictionaryPropertyBag::createInstance();
     userInfoBag->setDictionary(userInfo.get());
index 1f7a572..a7310b8 100644 (file)
@@ -693,9 +693,9 @@ HRESULT WebHistory::addItem(IWebHistoryItem* entry, bool discardDuplicate, bool*
 
 void WebHistory::visitedURL(const KURL& url, const String& title, const String& httpMethod, bool wasFailure, bool increaseVisitCount)
 {
-    RetainPtr<CFStringRef> urlString(AdoptCF, url.string().createCFString());
+    RetainPtr<CFStringRef> urlString = url.string().createCFString();
 
-    IWebHistoryItem* entry = (IWebHistoryItem*) CFDictionaryGetValue(m_entriesByURL.get(), urlString.get());
+    IWebHistoryItem* entry = (IWebHistoryItem*)CFDictionaryGetValue(m_entriesByURL.get(), urlString.get());
     if (entry) {
         COMPtr<IWebHistoryItemPrivate> entryPrivate(Query, entry);
         if (!entryPrivate)
@@ -786,11 +786,10 @@ HRESULT WebHistory::removeItemForURLString(CFStringRef urlString)
 
 COMPtr<IWebHistoryItem> WebHistory::itemForURLString(const String& urlString) const
 {
-    RetainPtr<CFStringRef> urlCFString(AdoptCF, urlString.createCFString());
-    if (!urlCFString)
+    if (!urlString)
         return 0;
     COMPtr<IWebHistoryItem> item;
-    if (FAILED(itemForURLString(urlCFString.get(), &item)))
+    if (FAILED(itemForURLString(urlString.createCFString().get(), &item)))
         return 0;
     return item;
 }
index a264308..8bfe9bd 100644 (file)
@@ -214,7 +214,7 @@ HRESULT STDMETHODCALLTYPE WebHistoryItem::dictionaryRepresentation(void** dictio
 
     if (!m_historyItem->urlString().isEmpty()) {
         keys[keyCount] = urlKey;
-        values[keyCount++] = m_historyItem->urlString().createCFString();
+        values[keyCount++] = m_historyItem->urlString().createCFString().leakRef();
     }
 
     keys[keyCount] = lastVisitedDateKey;
@@ -222,7 +222,7 @@ HRESULT STDMETHODCALLTYPE WebHistoryItem::dictionaryRepresentation(void** dictio
 
     if (!m_historyItem->title().isEmpty()) {
         keys[keyCount] = titleKey;
-        values[keyCount++] = m_historyItem->title().createCFString();
+        values[keyCount++] = m_historyItem->title().createCFString().leakRef();
     }
 
     keys[keyCount] = visitCountKey;
@@ -245,7 +245,7 @@ HRESULT STDMETHODCALLTYPE WebHistoryItem::dictionaryRepresentation(void** dictio
         ASSERT(size);
         CFStringRef* items = new CFStringRef[size];
         for (size_t i = 0; i < size; ++i)
-            items[i] = redirectURLs->at(i).createCFString();
+            items[i] = redirectURLs->at(i).createCFString().leakRef();
         CFArrayRef result = CFArrayCreate(0, (const void**)items, size, &kCFTypeArrayCallBacks);
         for (size_t i = 0; i < size; ++i)
             CFRelease(items[i]);
index 25d7ec0..05a9490 100644 (file)
@@ -366,7 +366,7 @@ BSTR WebIconDatabase::iconDatabaseDidAddIconNotification()
 
 CFStringRef WebIconDatabase::iconDatabaseNotificationUserInfoURLKey()
 {
-    static CFStringRef iconUserInfoURLKey = String(WebIconNotificationUserInfoURLKey).createCFString();
+    static CFStringRef iconUserInfoURLKey = String(WebIconNotificationUserInfoURLKey).createCFString().leakRef();
     return iconUserInfoURLKey;
 }
 
@@ -387,8 +387,7 @@ static void postDidAddIconNotification(const String& pageURL, WebIconDatabase* i
     RetainPtr<CFMutableDictionaryRef> dictionary(AdoptCF, 
     CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
 
-    RetainPtr<CFStringRef> url(AdoptCF, pageURL.createCFString());
-    CFDictionaryAddValue(dictionary.get(), WebIconDatabase::iconDatabaseNotificationUserInfoURLKey(), url.get());
+    CFDictionaryAddValue(dictionary.get(), WebIconDatabase::iconDatabaseNotificationUserInfoURLKey(), pageURL.createCFString().get());
 
     COMPtr<CFDictionaryPropertyBag> userInfo = CFDictionaryPropertyBag::createInstance();
     userInfo->setDictionary(dictionary.get());
index fd61a01..dfb714b 100644 (file)
@@ -132,12 +132,10 @@ static CFBundleRef createWebKitBundle()
         return 0;
 
     String bundlePathString(pathStr);
-    CFStringRef bundlePathCFString = bundlePathString.createCFString();
-    if (!bundlePathCFString)
+    if (!bundlePathString)
         return 0;
 
-    CFURLRef bundleURLRef = CFURLCreateWithFileSystemPath(0, bundlePathCFString, kCFURLWindowsPathStyle, true);
-    CFRelease(bundlePathCFString);
+    CFURLRef bundleURLRef = CFURLCreateWithFileSystemPath(0, bundlePathString.createCFString().get(), kCFURLWindowsPathStyle, true);
     if (!bundleURLRef)
         return 0;
 
@@ -168,8 +166,7 @@ static CFStringRef copyLocalizedStringFromBundle(WebLocalizableStringsBundle* st
     if (!bundle)
         return notFound;
 
-    RetainPtr<CFStringRef> keyString(AdoptCF, key.createCFString());
-    CFStringRef result = CFCopyLocalizedStringWithDefaultValue(keyString.get(), 0, bundle, notFound, 0);
+    CFStringRef result = CFCopyLocalizedStringWithDefaultValue(key.createCFString().get(), 0, bundle, notFound, 0);
 
     ASSERT_WITH_MESSAGE(result != notFound, "could not find localizable string %s in bundle", key);
     return result;
index 5634a15..8967b0b 100644 (file)
@@ -196,7 +196,7 @@ void WebPreferences::initializeDefaultSettings()
     CFDictionaryAddValue(defaults, CFSTR(WebKitDefaultFixedFontSizePreferenceKey), CFSTR("13"));
 
     String defaultDefaultEncoding(WEB_UI_STRING("ISO-8859-1", "The default, default character encoding"));
-    CFDictionaryAddValue(defaults, CFSTR(WebKitDefaultTextEncodingNamePreferenceKey), defaultDefaultEncoding.createCFString());
+    CFDictionaryAddValue(defaults, CFSTR(WebKitDefaultTextEncodingNamePreferenceKey), defaultDefaultEncoding.createCFString().get());
 
     CFDictionaryAddValue(defaults, CFSTR(WebKitUserStyleSheetEnabledPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebKitUserStyleSheetLocationPreferenceKey), CFSTR(""));
index 6b1bade..3a1b74e 100644 (file)
@@ -471,7 +471,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
     RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
     RetainPtr<CFStringRef> cfurlCacheDirectory(AdoptCF, wkCopyFoundationCacheDirectory(0));
     if (!cfurlCacheDirectory)
-        cfurlCacheDirectory.adoptCF(WebCore::localUserSpecificStorageDirectory().createCFString());
+        cfurlCacheDirectory = WebCore::localUserSpecificStorageDirectory().createCFString();
 
     // As a fudge factor, use 1000 instead of 1024, in case the reported byte 
     // count doesn't align exactly to a megabyte boundary.
@@ -4712,8 +4712,7 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
         if (FAILED(hr))
             return hr;
 
-        RetainPtr<CFStringRef> urlString(AdoptCF, toString(str).createCFString());
-        RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithString(kCFAllocatorDefault, urlString.get(), 0));
+        RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithString(kCFAllocatorDefault, toString(str).createCFString().get(), 0));
 
         // Check if the passed in string is a path and convert it to a URL.
         // FIXME: This is a workaround for nightly builds until we can get Safari to pass 
index 8f1f437..49c5709 100644 (file)
@@ -1,3 +1,33 @@
+2012-10-29  Anders Carlsson  <andersca@apple.com>
+
+        String::createCFString should return a RetainPtr
+        https://bugs.webkit.org/show_bug.cgi?id=100419
+
+        Reviewed by Andreas Kling.
+
+        Update callers of String::createCFString.
+
+        * Platform/mac/ModuleMac.mm:
+        (WebKit::Module::load):
+        * PluginProcess/mac/PluginProcessMac.mm:
+        (WebKit::initializeSandbox):
+        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+        (WebKit::NetscapePluginModule::getPluginInfo):
+        (WebKit::NetscapePluginModule::createPluginMIMETypesPreferences):
+        * UIProcess/cf/WebBackForwardListCF.cpp:
+        (WebKit::WebBackForwardList::createCFDictionaryRepresentation):
+        * UIProcess/cf/WebPageProxyCF.cpp:
+        (WebKit::WebPageProxy::sessionStateData):
+        (WebKit::autosaveKey):
+        (WebKit::WebPageProxy::saveRecentSearches):
+        * WebProcess/ResourceCache/WebResourceCacheManager.cpp:
+        (WebKit::WebResourceCacheManager::clearCacheForOrigin):
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::cachedResponseForURL):
+        * WebProcess/win/WebProcessWin.cpp:
+        (WebKit::WebProcess::platformSetCacheModel):
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2012-10-30  Kondapally Kalyan  <kalyan.kondapally@intel.com>
 
         Regression(r132647)-Enable WebGL in EwkView.
index 4a35b6a..3687531 100644 (file)
@@ -30,12 +30,11 @@ namespace WebKit {
 
 bool Module::load()
 {
-    RetainPtr<CFStringRef> bundlePath(AdoptCF, m_path.createCFString());
-    RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath.get(), kCFURLPOSIXPathStyle, FALSE));
+    RetainPtr<CFURLRef> bundleURL = adoptCF(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, m_path.createCFString().get(), kCFURLPOSIXPathStyle, FALSE));
     if (!bundleURL)
         return false;
 
-    RetainPtr<CFBundleRef> bundle(AdoptCF, CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
+    RetainPtr<CFBundleRef> bundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
     if (!bundle)
         return false;
 
index de7d583..671f20d 100644 (file)
@@ -279,8 +279,7 @@ static void initializeSandbox(const String& pluginPath, const String& sandboxPro
     if (sandboxProfileDirectoryPath.isEmpty())
         return;
 
-    RetainPtr<CFStringRef> cfPluginPath = adoptCF(pluginPath.createCFString());
-    RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, cfPluginPath.get(), kCFURLPOSIXPathStyle, false));
+    RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
     if (!pluginURL)
         return;
 
@@ -292,8 +291,7 @@ static void initializeSandbox(const String& pluginPath, const String& sandboxPro
     if (!bundleIdentifier)
         return;
 
-    RetainPtr<CFStringRef> cfSandboxProfileDirectoryPath = adoptCF(sandboxProfileDirectoryPath.createCFString());
-    RetainPtr<CFURLRef> sandboxProfileDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, cfSandboxProfileDirectoryPath.get(), kCFURLPOSIXPathStyle, TRUE));
+    RetainPtr<CFURLRef> sandboxProfileDirectory = adoptCF(CFURLCreateWithFileSystemPath(0, sandboxProfileDirectoryPath.createCFString().get(), kCFURLPOSIXPathStyle, TRUE));
 
     RetainPtr<CFStringRef> sandboxFileName = CFStringCreateWithFormat(0, 0, CFSTR("%@.sb"), bundleIdentifier);
     RetainPtr<CFURLRef> sandboxURL = adoptCF(CFURLCreateWithFileSystemPathRelativeToBase(0, sandboxFileName.get(), kCFURLPOSIXPathStyle, FALSE, sandboxProfileDirectory.get()));
index 81b38e0..3dc377c 100644 (file)
@@ -352,11 +352,10 @@ static bool getPluginInfoFromCarbonResources(CFBundleRef bundle, PluginModuleInf
 
 bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
 {
-    RetainPtr<CFStringRef> bundlePath(AdoptCF, pluginPath.createCFString());
-    RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath.get(), kCFURLPOSIXPathStyle, false));
+    RetainPtr<CFURLRef> bundleURL = adoptCF(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
     
     // Try to initialize the bundle.
-    RetainPtr<CFBundleRef> bundle(AdoptCF, CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
+    RetainPtr<CFBundleRef> bundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
     if (!bundle)
         return false;
     
@@ -395,11 +394,9 @@ bool NetscapePluginModule::getPluginInfo(const String& pluginPath, PluginModuleI
 
 bool NetscapePluginModule::createPluginMIMETypesPreferences(const String& pluginPath)
 {
-    RetainPtr<CFStringRef> bundlePath(AdoptCF, pluginPath.createCFString());
-    RetainPtr<CFURLRef> bundleURL(AdoptCF, CFURLCreateWithFileSystemPath(kCFAllocatorDefault, bundlePath.get(), kCFURLPOSIXPathStyle, false));
+    RetainPtr<CFURLRef> bundleURL = adoptCF(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
     
-    // Try to initialize the bundle.
-    RetainPtr<CFBundleRef> bundle(AdoptCF, CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
+    RetainPtr<CFBundleRef> bundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, bundleURL.get()));
     if (!bundle)
         return false;
 
index cdff344..7c1f240 100644 (file)
@@ -94,9 +94,9 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx
             continue;
         }
         
-        RetainPtr<CFStringRef> url(AdoptCF, m_entries[i]->url().createCFString());
-        RetainPtr<CFStringRef> title(AdoptCF, m_entries[i]->title().createCFString());
-        RetainPtr<CFStringRef> originalURL(AdoptCF, m_entries[i]->originalURL().createCFString());
+        RetainPtr<CFStringRef> url = m_entries[i]->url().createCFString();
+        RetainPtr<CFStringRef> title = m_entries[i]->title().createCFString();
+        RetainPtr<CFStringRef> originalURL = m_entries[i]->originalURL().createCFString();
 
         // FIXME: This uses the CoreIPC data encoding format, which means that whenever we change the CoreIPC encoding we need to bump the CurrentSessionStateDataVersion
         // constant in WebPageProxyCF.cpp. The CoreIPC data format is meant to be an implementation detail, and not something that should be written to disk.
index 79dd8ce..fac02c1 100644 (file)
@@ -65,7 +65,7 @@ PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilte
         if (provisionalURL.isEmpty())
             provisionalURL = m_mainFrame->provisionalURL();
         if (!provisionalURL.isEmpty()) {
-            provisionalURLString.adoptCF(provisionalURL.createCFString());
+            provisionalURLString = provisionalURL.createCFString();
             keys[numValues] = ProvisionalURLKey();
             values[numValues] = provisionalURLString.get();
             ++numValues;
@@ -179,8 +179,7 @@ void WebPageProxy::restoreFromSessionStateData(WebData* webData)
 
 static RetainPtr<CFStringRef> autosaveKey(const String& name)
 {
-    String key = "com.apple.WebKit.searchField:" + name;
-    return RetainPtr<CFStringRef>(AdoptCF, key.createCFString());
+    return String("com.apple.WebKit.searchField:" + name).createCFString();
 }
 
 void WebPageProxy::saveRecentSearches(const String& name, const Vector<String>& searchItems)
@@ -192,10 +191,8 @@ void WebPageProxy::saveRecentSearches(const String& name, const Vector<String>&
 
     if (size_t size = searchItems.size()) {
         items.adoptCF(CFArrayCreateMutable(0, size, &kCFTypeArrayCallBacks));
-        for (size_t i = 0; i < size; ++i) {
-            RetainPtr<CFStringRef> item(AdoptCF, searchItems[i].createCFString());
-            CFArrayAppendValue(items.get(), item.get());
-        }
+        for (size_t i = 0; i < size; ++i)
+            CFArrayAppendValue(items.get(), searchItems[i].createCFString().get());
     }
 
     CFPreferencesSetAppValue(autosaveKey(name).get(), items.get(), kCFPreferencesCurrentApplication);
index 6810f0a..395649c 100644 (file)
@@ -118,8 +118,7 @@ void WebResourceCacheManager::clearCacheForOrigin(SecurityOriginData originData,
 #if USE(CFURLCACHE)
     if (resourceCachesToClear != InMemoryResourceCachesOnly) { 
         RetainPtr<CFMutableArrayRef> hostArray(AdoptCF, CFArrayCreateMutable(0, 0, &kCFTypeArrayCallBacks));
-        RetainPtr<CFStringRef> host(AdoptCF, origin->host().createCFString());
-        CFArrayAppendValue(hostArray.get(), host.get());
+        CFArrayAppendValue(hostArray.get(), origin->host().createCFString().get());
 
         clearCFURLCacheForHostNames(hostArray.get());
     }
index 6294f00..c6f5b67 100644 (file)
@@ -270,8 +270,7 @@ static RetainPtr<CFCachedURLResponseRef> cachedResponseForURL(WebPage* webPage,
     wkSetRequestStorageSession(ResourceHandle::currentStorageSession(), request.get());
 #endif
 
-    RetainPtr<CFStringRef> userAgent(AdoptCF, webPage->userAgent().createCFString());
-    CFURLRequestSetHTTPHeaderFieldValue(request.get(), CFSTR("User-Agent"), userAgent.get());
+    CFURLRequestSetHTTPHeaderFieldValue(request.get(), CFSTR("User-Agent"), webPage->userAgent().createCFString().get());
 
     RetainPtr<CFURLCacheRef> cache;
 #if USE(CFURLSTORAGESESSIONS)
index 25dbc36..da4b56d 100644 (file)
@@ -79,7 +79,7 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
         cfurlCacheDirectory.adoptCF(wkCopyFoundationCacheDirectory(0));
 
     if (!cfurlCacheDirectory)
-        cfurlCacheDirectory.adoptCF(WebCore::localUserSpecificStorageDirectory().createCFString());
+        cfurlCacheDirectory = WebCore::localUserSpecificStorageDirectory().createCFString();
 
     // As a fudge factor, use 1000 instead of 1024, in case the reported byte 
     // count doesn't align exactly to a megabyte boundary.
@@ -148,13 +148,12 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     if (defaultStorageSession)
         return;
 
-    RetainPtr<CFStringRef> cachePath(AdoptCF, parameters.diskCacheDirectory.createCFString());
-    if (!cachePath)
+    if (!parameters.diskCacheDirectory)
         return;
 
     CFIndex cacheDiskCapacity = parameters.cfURLCacheDiskCapacity;
     CFIndex cacheMemoryCapacity = parameters.cfURLCacheMemoryCapacity;
-    RetainPtr<CFURLCacheRef> uiProcessCache(AdoptCF, CFURLCacheCreate(kCFAllocatorDefault, cacheMemoryCapacity, cacheDiskCapacity, cachePath.get()));
+    RetainPtr<CFURLCacheRef> uiProcessCache(AdoptCF, CFURLCacheCreate(kCFAllocatorDefault, cacheMemoryCapacity, cacheDiskCapacity, parameters.diskCacheDirectory.createCFString().get()));
     CFURLCacheSetSharedURLCache(uiProcessCache.get());
 #endif // USE(CFNETWORK)
 }
index 2a84928..478bf51 100644 (file)
@@ -1,3 +1,15 @@
+2012-10-29  Anders Carlsson  <andersca@apple.com>
+
+        String::createCFString should return a RetainPtr
+        https://bugs.webkit.org/show_bug.cgi?id=100419
+
+        Reviewed by Andreas Kling.
+
+        Update callers of String::createCFString.
+
+        * WebKitTestRunner/InjectedBundle/mac/InjectedBundlePageMac.mm:
+        (WTR::InjectedBundlePage::platformDidStartProvisionalLoadForFrame):
+
 2012-10-30  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
 
         [WK2][WTR] WebKitTestRunner needs testRunner.queueLoadHTMLString
index 46c273f..b0cb4e0 100644 (file)
@@ -85,8 +85,7 @@ void InjectedBundlePage::platformDidStartProvisionalLoadForFrame(WKBundleFrameRe
         StringBuilder builder;
         builder.appendLiteral("CRASHING TEST: ");
         builder.append(testPath);
-        RetainPtr<CFStringRef> cfString(AdoptCF, builder.toString().createCFString());
-        WKSetCrashReportApplicationSpecificInformation(cfString.get());
+        WKSetCrashReportApplicationSpecificInformation(builder.toString().createCFString().get());
     }
 #endif
 }