Changeset 150606 in webkit


Ignore:
Timestamp:
May 23, 2013 12:46:05 PM (11 years ago)
Author:
benjamin@webkit.org
Message:

KURL::createCFURL() should return a RetainPtr<CFURLRef>
https://bugs.webkit.org/show_bug.cgi?id=116644

Patch by Benjamin Poulain <bpoulain@apple.com> on 2013-05-23
Reviewed by Andreas Kling.

For consistency with the other createCFType() APIs in WebKit, KURL should
return a RetainPtr<> instead of raw +1 CFURLRef.

No leak were discovered while making this change.

  • platform/KURL.h:
  • platform/cf/KURLCFNet.cpp:

(WebCore):
(WebCore::createCFURLFromBuffer):
(WebCore::KURL::createCFURL):
(WebCore::KURL::fileSystemPath):

  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:

(WebCore::AVFWrapper::createAssetForURL):

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::setURLForRect):

  • platform/mac/KURLMac.mm:

(WebCore):
(WebCore::KURL::operator NSURL *):
(WebCore::KURL::createCFURL):

  • platform/network/cf/CookieJarCFNet.cpp:

(WebCore::setCookiesFromDOM):
(WebCore::cookiesForDOM):
(WebCore::cookieRequestHeaderFieldValue):
(WebCore::getRawCookies):
(WebCore::deleteCookie):

  • platform/network/cf/DNSCFNet.cpp:

(WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences):

  • platform/network/cf/ProxyServerCFNet.cpp:

(WebCore::addProxyServersForURL):

  • platform/network/cf/ResourceRequestCFNet.cpp:

(WebCore::ResourceRequest::doUpdatePlatformRequest):
(WebCore::ResourceRequest::doUpdatePlatformHTTPBody):

  • platform/network/cf/ResourceResponseCFNet.cpp:

(WebCore::ResourceResponse::cfURLResponse):

  • platform/network/cf/SocketStreamHandleCFNet.cpp:

(WebCore::SocketStreamHandle::SocketStreamHandle):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150602 r150606  
     12013-05-23  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        KURL::createCFURL() should return a RetainPtr<CFURLRef>
     4        https://bugs.webkit.org/show_bug.cgi?id=116644
     5
     6        Reviewed by Andreas Kling.
     7
     8        For consistency with the other createCFType() APIs in WebKit, KURL should
     9        return a RetainPtr<> instead of raw +1 CFURLRef.
     10
     11        No leak were discovered while making this change.
     12
     13        * platform/KURL.h:
     14        * platform/cf/KURLCFNet.cpp:
     15        (WebCore):
     16        (WebCore::createCFURLFromBuffer):
     17        (WebCore::KURL::createCFURL):
     18        (WebCore::KURL::fileSystemPath):
     19        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
     20        (WebCore::AVFWrapper::createAssetForURL):
     21        * platform/graphics/cg/GraphicsContextCG.cpp:
     22        (WebCore::GraphicsContext::setURLForRect):
     23        * platform/mac/KURLMac.mm:
     24        (WebCore):
     25        (WebCore::KURL::operator NSURL *):
     26        (WebCore::KURL::createCFURL):
     27        * platform/network/cf/CookieJarCFNet.cpp:
     28        (WebCore::setCookiesFromDOM):
     29        (WebCore::cookiesForDOM):
     30        (WebCore::cookieRequestHeaderFieldValue):
     31        (WebCore::getRawCookies):
     32        (WebCore::deleteCookie):
     33        * platform/network/cf/DNSCFNet.cpp:
     34        (WebCore::DNSResolveQueue::platformProxyIsEnabledInSystemPreferences):
     35        * platform/network/cf/ProxyServerCFNet.cpp:
     36        (WebCore::addProxyServersForURL):
     37        * platform/network/cf/ResourceRequestCFNet.cpp:
     38        (WebCore::ResourceRequest::doUpdatePlatformRequest):
     39        (WebCore::ResourceRequest::doUpdatePlatformHTTPBody):
     40        * platform/network/cf/ResourceResponseCFNet.cpp:
     41        (WebCore::ResourceResponse::cfURLResponse):
     42        * platform/network/cf/SocketStreamHandleCFNet.cpp:
     43        (WebCore::SocketStreamHandle::SocketStreamHandle):
     44
    1452013-05-18  Robert Hogan  <robert@webkit.org>
    246
  • trunk/Source/WebCore/platform/KURL.h

    r148921 r150606  
    11/*
    2  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#include <wtf/Forward.h>
    3030#include <wtf/HashMap.h>
     31#include <wtf/RetainPtr.h>
    3132#include <wtf/text/WTFString.h>
    3233
     
    168169#if USE(CF)
    169170    KURL(CFURLRef);
    170     CFURLRef createCFURL() const;
     171    RetainPtr<CFURLRef> createCFURL() const;
    171172#endif
    172173
  • trunk/Source/WebCore/platform/cf/KURLCFNet.cpp

    r149255 r150606  
    11/*
    2  * Copyright (C) 2004, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2004, 2008, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636typedef Vector<char, 512> CharBuffer;
    3737
    38 CFURLRef createCFURLFromBuffer(const CharBuffer&);
     38RetainPtr<CFURLRef> createCFURLFromBuffer(const CharBuffer&);
    3939
    4040KURL::KURL(CFURLRef url)
     
    5353}
    5454
    55 CFURLRef createCFURLFromBuffer(const CharBuffer& buffer)
     55RetainPtr<CFURLRef> createCFURLFromBuffer(const CharBuffer& buffer)
    5656{
    5757    // NOTE: We use UTF-8 here since this encoding is used when computing strings when returning URL components
     
    5959    // could either be a malformed string or bytes in a different encoding, like Shift-JIS, so we fall back
    6060    // onto using ISO Latin-1 in those cases.
    61     CFURLRef result = CFURLCreateAbsoluteURLWithBytes(0, reinterpret_cast<const UInt8*>(buffer.data()), buffer.size(), kCFStringEncodingUTF8, 0, true);
     61    RetainPtr<CFURLRef> result = adoptCF(CFURLCreateAbsoluteURLWithBytes(0, reinterpret_cast<const UInt8*>(buffer.data()), buffer.size(), kCFStringEncodingUTF8, 0, true));
    6262    if (!result)
    63         result = CFURLCreateAbsoluteURLWithBytes(0, reinterpret_cast<const UInt8*>(buffer.data()), buffer.size(), kCFStringEncodingISOLatin1, 0, true);
     63        result = adoptCF(CFURLCreateAbsoluteURLWithBytes(0, reinterpret_cast<const UInt8*>(buffer.data()), buffer.size(), kCFStringEncodingISOLatin1, 0, true));
    6464    return result;
    6565}
    6666
    6767#if !PLATFORM(MAC) && !(PLATFORM(QT) && USE(QTKIT))
    68 CFURLRef KURL::createCFURL() const
     68RetainPtr<CFURLRef> KURL::createCFURL() const
    6969{
    7070    // FIXME: What should this return for invalid URLs?
     
    8080String KURL::fileSystemPath() const
    8181{
    82     RetainPtr<CFURLRef> cfURL = adoptCF(createCFURL());
     82    RetainPtr<CFURLRef> cfURL = createCFURL();
    8383    if (!cfURL)
    8484        return String();
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r149980 r150606  
    983983    ASSERT(!avAsset());
    984984
    985     RetainPtr<CFURLRef> urlRef = adoptCF(KURL(ParsedURLString, url).createCFURL());
     985    RetainPtr<CFURLRef> urlRef = KURL(ParsedURLString, url).createCFURL();
    986986
    987987    AVCFURLAssetRef assetRef = AVCFURLAssetCreateWithURLAndOptions(kCFAllocatorDefault, urlRef.get(), 0, m_notificationQueue);
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r149980 r150606  
    12901290        return;
    12911291
    1292     RetainPtr<CFURLRef> urlRef = adoptCF(link.createCFURL());
     1292    RetainPtr<CFURLRef> urlRef = link.createCFURL();
    12931293    if (!urlRef)
    12941294        return;
  • trunk/Source/WebCore/platform/mac/KURLMac.mm

    r147715 r150606  
    3535
    3636typedef Vector<char, 512> CharBuffer;
    37 extern CFURLRef createCFURLFromBuffer(const CharBuffer& buffer);
     37extern RetainPtr<CFURLRef> createCFURLFromBuffer(const CharBuffer& buffer);
    3838
    3939KURL::KURL(NSURL *url)
     
    5454KURL::operator NSURL *() const
    5555{
    56     return HardAutorelease(createCFURL());
     56    return HardAutorelease(createCFURL().leakRef());
    5757}
    5858
    5959// We use the toll-free bridge between NSURL and CFURL to
    6060// create a CFURLRef supporting both empty and null values.
    61 CFURLRef KURL::createCFURL() const
     61RetainPtr<CFURLRef> KURL::createCFURL() const
    6262{
    6363    if (isNull())
    6464        return 0;
    6565
    66     if (isEmpty())
    67         return reinterpret_cast<CFURLRef>([[NSURL alloc] initWithString:@""]);
     66    if (isEmpty()) {
     67        RetainPtr<NSURL> emptyNSURL = adoptNS([[NSURL alloc] initWithString:@""]);
     68        return reinterpret_cast<CFURLRef>(emptyNSURL.get());
     69    }
    6870
    6971    CharBuffer buffer;
  • trunk/Source/WebCore/platform/network/cf/CookieJarCFNet.cpp

    r149716 r150606  
    100100        return;
    101101
    102     RetainPtr<CFURLRef> urlCF = adoptCF(url.createCFURL());
    103     RetainPtr<CFURLRef> firstPartyForCookiesCF = adoptCF(firstParty.createCFURL());
     102    RetainPtr<CFURLRef> urlCF = url.createCFURL();
     103    RetainPtr<CFURLRef> firstPartyForCookiesCF = firstParty.createCFURL();
    104104
    105105    // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034>
     
    120120String cookiesForDOM(const NetworkStorageSession& session, const KURL&, const KURL& url)
    121121{
    122     RetainPtr<CFURLRef> urlCF = adoptCF(url.createCFURL());
     122    RetainPtr<CFURLRef> urlCF = url.createCFURL();
    123123
    124124    bool secure = url.protocolIs("https");
     
    130130String cookieRequestHeaderFieldValue(const NetworkStorageSession& session, const KURL& /*firstParty*/, const KURL& url)
    131131{
    132     RetainPtr<CFURLRef> urlCF = adoptCF(url.createCFURL());
     132    RetainPtr<CFURLRef> urlCF = url.createCFURL();
    133133
    134134    bool secure = url.protocolIs("https");
     
    148148    rawCookies.clear();
    149149
    150     RetainPtr<CFURLRef> urlCF = adoptCF(url.createCFURL());
     150    RetainPtr<CFURLRef> urlCF = url.createCFURL();
    151151
    152152    bool sendSecureCookies = url.protocolIs("https");
     
    179179    RetainPtr<CFHTTPCookieStorageRef> cookieStorage = session.cookieStorage();
    180180
    181     RetainPtr<CFURLRef> urlCF = adoptCF(url.createCFURL());
     181    RetainPtr<CFURLRef> urlCF = url.createCFURL();
    182182
    183183    bool sendSecureCookies = url.protocolIs("https");
  • trunk/Source/WebCore/platform/network/cf/DNSCFNet.cpp

    r149255 r150606  
    5656        return false;
    5757
    58     static CFURLRef httpCFURL = KURL(ParsedURLString, "http://example.com/").createCFURL();
    59     static CFURLRef httpsCFURL = KURL(ParsedURLString, "https://example.com/").createCFURL();
     58    RetainPtr<CFURLRef> httpCFURL = KURL(ParsedURLString, "http://example.com/").createCFURL();
     59    RetainPtr<CFURLRef> httpsCFURL = KURL(ParsedURLString, "https://example.com/").createCFURL();
    6060
    61     RetainPtr<CFArrayRef> httpProxyArray = adoptCF(CFNetworkCopyProxiesForURL(httpCFURL, proxySettings.get()));
    62     RetainPtr<CFArrayRef> httpsProxyArray = adoptCF(CFNetworkCopyProxiesForURL(httpsCFURL, proxySettings.get()));
     61    RetainPtr<CFArrayRef> httpProxyArray = adoptCF(CFNetworkCopyProxiesForURL(httpCFURL.get(), proxySettings.get()));
     62    RetainPtr<CFArrayRef> httpsProxyArray = adoptCF(CFNetworkCopyProxiesForURL(httpsCFURL.get(), proxySettings.get()));
    6363
    6464    CFIndex httpProxyCount = CFArrayGetCount(httpProxyArray.get());
  • trunk/Source/WebCore/platform/network/cf/ProxyServerCFNet.cpp

    r149255 r150606  
    126126        return;
    127127
    128     RetainPtr<CFURLRef> cfURL = adoptCF(url.createCFURL());
     128    RetainPtr<CFURLRef> cfURL = url.createCFURL();
    129129    RetainPtr<CFArrayRef> proxiesForURL = adoptCF(CFNetworkCopyProxiesForURL(cfURL.get(), proxySettings.get()));
    130130    if (!proxiesForURL)
  • trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp

    r149255 r150606  
    131131    CFMutableURLRequestRef cfRequest;
    132132
    133     RetainPtr<CFURLRef> url = adoptCF(ResourceRequest::url().createCFURL());
    134     RetainPtr<CFURLRef> firstPartyForCookies = adoptCF(ResourceRequest::firstPartyForCookies().createCFURL());
     133    RetainPtr<CFURLRef> url = ResourceRequest::url().createCFURL();
     134    RetainPtr<CFURLRef> firstPartyForCookies = ResourceRequest::firstPartyForCookies().createCFURL();
    135135    if (m_cfRequest) {
    136136        cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get());
     
    191191    CFMutableURLRequestRef cfRequest;
    192192
    193     RetainPtr<CFURLRef> url = adoptCF(ResourceRequest::url().createCFURL());
    194     RetainPtr<CFURLRef> firstPartyForCookies = adoptCF(ResourceRequest::firstPartyForCookies().createCFURL());
     193    RetainPtr<CFURLRef> url = ResourceRequest::url().createCFURL();
     194    RetainPtr<CFURLRef> firstPartyForCookies = ResourceRequest::firstPartyForCookies().createCFURL();
    195195    if (m_cfRequest) {
    196196        cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get());
  • trunk/Source/WebCore/platform/network/cf/ResourceResponseCFNet.cpp

    r149255 r150606  
    5151{
    5252    if (!m_cfResponse && !m_isNull) {
    53         RetainPtr<CFURLRef> url = adoptCF(m_url.createCFURL());
     53        RetainPtr<CFURLRef> url = m_url.createCFURL();
    5454
    5555        // FIXME: This creates a very incomplete CFURLResponse, which does not even have a status code.
  • trunk/Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp

    r149255 r150606  
    6767
    6868    KURL httpsURL(KURL(), "https://" + m_url.host());
    69     m_httpsURL = adoptCF(httpsURL.createCFURL());
     69    m_httpsURL = httpsURL.createCFURL();
    7070
    7171    createStreams();
Note: See TracChangeset for help on using the changeset viewer.