Changeset 128809 in webkit


Ignore:
Timestamp:
Sep 17, 2012 2:43:53 PM (12 years ago)
Author:
Patrick Gansterer
Message:

[WIN] Use BString in favour of BSTR to improve memory management
https://bugs.webkit.org/show_bug.cgi?id=93128

Reviewed by Anders Carlsson.

BString automatically calls SysFreeString() in its destructor which helps
avoiding memory leaks. So it should be used instead of BSTR directly.
Add operator& to BString to allow its usage for out parameters too (like COMPtr).
This fixes already a few memory leaks in the existing code.

  • platform/win/BString.cpp:

(WebCore::BString::~BString):
(WebCore::BString::adoptBSTR):
(WebCore::BString::clear):
(WebCore):

  • platform/win/BString.h:

(BString):
(WebCore::BString::operator&):

Location:
trunk/Source
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128804 r128809  
     12012-09-17  Patrick Gansterer  <paroga@webkit.org>
     2
     3        [WIN] Use BString in favour of BSTR to improve memory management
     4        https://bugs.webkit.org/show_bug.cgi?id=93128
     5
     6        Reviewed by Anders Carlsson.
     7
     8        BString automatically calls SysFreeString() in its destructor which helps
     9        avoiding memory leaks. So it should be used instead of BSTR directly.
     10        Add operator& to BString to allow its usage for out parameters too (like COMPtr).
     11        This fixes already a few memory leaks in the existing code.
     12
     13        * platform/win/BString.cpp:
     14        (WebCore::BString::~BString):
     15        (WebCore::BString::adoptBSTR):
     16        (WebCore::BString::clear):
     17        (WebCore):
     18        * platform/win/BString.h:
     19        (BString):
     20        (WebCore::BString::operator&):
     21
    1222012-09-17  Tony Chang  <tony@chromium.org>
    223
  • trunk/Source/WebCore/platform/win/BString.cpp

    r127757 r128809  
    107107BString::~BString()
    108108{
    109     SysFreeString(m_bstr);
     109    clear();
    110110}
    111111
     
    120120void BString::adoptBSTR(BSTR bstr)
    121121{
    122     if (m_bstr)
    123         SysFreeString(m_bstr);
     122    clear();
    124123    m_bstr = bstr;
     124}
     125
     126void BString::clear()
     127{
     128    SysFreeString(m_bstr);
    125129}
    126130
  • trunk/Source/WebCore/platform/win/BString.h

    r127191 r128809  
    5353
    5454        void adoptBSTR(BSTR);
     55        void clear();
    5556
    5657        BString(const BString&);
     
    5859        BString& operator=(const BSTR&);
    5960
     61        BSTR* operator&() { ASSERT(!m_bstr); return &m_bstr; }
    6062        operator BSTR() const { return m_bstr; }
    6163
  • trunk/Source/WebKit/win/DefaultPolicyDelegate.cpp

    r127757 r128809  
    2828#include "DefaultPolicyDelegate.h"
    2929
     30#include <WebCore/BString.h>
    3031#include <WebCore/COMPtr.h>
    3132#include <wtf/text/WTFString.h>
     
    117118            listener->use();
    118119        else {
    119             BSTR url;
     120            BString url;
    120121            // A file URL shouldn't fall through to here, but if it did,
    121122            // it would be a security risk to open it.
     
    125126            }
    126127            listener->ignore();
    127             SysFreeString(url);
    128128        }
    129129    }
     
    153153        canShowMIMEType = FALSE;
    154154
    155     BSTR url;
     155    BString url;
    156156    request->URL(&url);
    157157
     
    172172    else
    173173        listener->ignore();
    174     SysFreeString(url);
    175174    return S_OK;
    176175}
     
    181180    /*[in]*/ IWebFrame* frame)
    182181{
    183     BSTR errorStr;
     182    BString errorStr;
    184183    error->localizedDescription(&errorStr);
    185184
    186     BSTR frameName;
     185    BString frameName;
    187186    frame->name(&frameName);
    188187
    189188    LOG_ERROR("called unableToImplementPolicyWithError:%S inFrame:%S", errorStr ? errorStr : TEXT(""), frameName ? frameName : TEXT(""));
    190     SysFreeString(errorStr);
    191     SysFreeString(frameName);
    192189
    193190    return S_OK;
  • trunk/Source/WebKit/win/MarshallingHelpers.cpp

    r127757 r128809  
    2828#include "MarshallingHelpers.h"
    2929
     30#include <WebCore/BString.h>
    3031#include <WebCore/IntRect.h>
    3132#include <WebCore/KURL.h>
     
    4748BSTR MarshallingHelpers::KURLToBSTR(const KURL& url)
    4849{
    49     return SysAllocStringLen(url.string().characters(), url.string().length());
     50    return BString(url.string()).release();
    5051}
    5152
     
    9091BSTR MarshallingHelpers::CFStringRefToBSTR(CFStringRef str)
    9192{
    92     if (!str)
    93         return 0;
    94 
    95     const UniChar* uniChars = CFStringGetCharactersPtr(str);
    96     if (uniChars)
    97         return SysAllocStringLen((LPCTSTR)uniChars, CFStringGetLength(str));
    98 
    99     CFIndex length = CFStringGetLength(str);
    100     BSTR bstr = SysAllocStringLen(0, length);
    101     if (bstr) {
    102         CFStringGetCharacters(str, CFRangeMake(0, length), (UniChar*)bstr);
    103         bstr[length] = 0;
    104     }
    105     return bstr;
     93    return BString(str).release();
    10694}
    10795
     
    160148    for (CFIndex i=0; i<size; i++) {
    161149        CFStringRef item = (CFStringRef) CFArrayGetValueAtIndex(inArray, i);
    162         BSTR bstr = CFStringRefToBSTR(item);
    163         ::SafeArrayPutElement(sa, &count, bstr);
    164         SysFreeString(bstr);    // SafeArrayPutElement() should make a copy of the string
     150        BString bstr(item);
     151        ::SafeArrayPutElement(sa, &count, bstr); // SafeArrayPutElement() copies the string correctly.
    165152        count++;
    166153    }
     
    233220        items = new CFStringRef[len];
    234221        for (; lBound <= uBound; lBound++) {
    235             BSTR str;
     222            BString str;
    236223            hr = ::SafeArrayGetElement(inArray, &lBound, &str);
    237224            items[lBound] = BSTRToCFStringRef(str);
    238             SysFreeString(str);
    239225        }
    240226    }
  • trunk/Source/WebKit/win/WebCoreSupport/WebChromeClient.cpp

    r122676 r128809  
    411411    TimerBase::fireTimersInNestedEventLoop();
    412412
    413     BSTR resultBSTR = 0;
     413    BString resultBSTR;
    414414    if (FAILED(ui->runJavaScriptTextInputPanelWithPrompt(m_webView, BString(message), BString(defaultValue), &resultBSTR)))
    415415        return false;
    416416
    417     if (resultBSTR) {
    418         result = String(resultBSTR, SysStringLen(resultBSTR));
    419         SysFreeString(resultBSTR);
    420         return true;
    421     }
    422 
    423     return false;
     417    if (!resultBSTR)
     418        return false;
     419
     420    result = String(resultBSTR, SysStringLen(resultBSTR));
     421    return true;
    424422}
    425423
  • trunk/Source/WebKit/win/WebCoreSupport/WebEditorClient.cpp

    r117470 r128809  
    696696        if (FAILED(detailObj->location(&detail.location)))
    697697            continue;
    698         BSTR userDesc;
     698        BString userDesc;
    699699        if (FAILED(detailObj->userDescription(&userDesc)))
    700700            continue;
    701701        detail.userDescription = String(userDesc, SysStringLen(userDesc));
    702         SysFreeString(userDesc);
    703702
    704703        COMPtr<IEnumSpellingGuesses> enumGuessesObj;
     
    706705            continue;
    707706        while (true) {
    708             BSTR guess;
     707            BString guess;
    709708            if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK)
    710709                break;
    711710            detail.guesses.append(String(guess, SysStringLen(guess)));
    712             SysFreeString(guess);
    713711        }
    714712
     
    779777    while (true) {
    780778        ULONG fetched;
    781         BSTR guess;
     779        BString guess;
    782780        if (enumGuessesObj->Next(1, &guess, &fetched) != S_OK)
    783781            break;
    784782        guesses.append(String(guess, SysStringLen(guess)));
    785         SysFreeString(guess);
    786783    }
    787784}
  • trunk/Source/WebKit/win/WebFrame.cpp

    r127577 r128809  
    14431443    hr = dataSource->response(&urlResponse);
    14441444    if (SUCCEEDED(hr) && urlResponse) {
    1445         BSTR mimeTypeBStr;
     1445        BString mimeTypeBStr;
    14461446        if (SUCCEEDED(urlResponse->MIMEType(&mimeTypeBStr))) {
    14471447            String mimeType(mimeTypeBStr, SysStringLen(mimeTypeBStr));
    14481448            *result = mimeType == "text/html" || WebCore::DOMImplementation::isXMLMIMEType(mimeType);
    1449             SysFreeString(mimeTypeBStr);
    14501449        }
    14511450    }
  • trunk/Source/WebKit/win/WebHistory.cpp

    r126926 r128809  
    3737#include "WebPreferences.h"
    3838#include <CoreFoundation/CoreFoundation.h>
     39#include <WebCore/BString.h>
    3940#include <WebCore/HistoryItem.h>
    4041#include <WebCore/HistoryPropertyList.h>
     
    613614{
    614615    HRESULT hr = S_OK;
    615     BSTR urlBStr = 0;
     616    BString urlBStr;
    616617
    617618    hr = entry->URLString(&urlBStr);
     
    620621
    621622    RetainPtr<CFStringRef> urlString(AdoptCF, MarshallingHelpers::BSTRToCFStringRef(urlBStr));
    622     SysFreeString(urlBStr);
    623623
    624624    // If this exact object isn't stored, then make no change.
     
    647647        return E_FAIL;
    648648
    649     BSTR urlBStr = 0;
     649    BString urlBStr;
    650650    hr = entry->URLString(&urlBStr);
    651651    if (FAILED(hr))
     
    653653
    654654    RetainPtr<CFStringRef> urlString(AdoptCF, MarshallingHelpers::BSTRToCFStringRef(urlBStr));
    655     SysFreeString(urlBStr);
    656655
    657656    COMPtr<IWebHistoryItem> oldEntry((IWebHistoryItem*) CFDictionaryGetValue(
  • trunk/Source/WebKit/win/WebIconDatabase.cpp

    r127757 r128809  
    8585    iconDatabase().setClient(this);
    8686
    87     BSTR prefDatabasePath = 0;
     87    BString prefDatabasePath;
    8888    if (FAILED(standardPrefs->iconDatabaseLocation(&prefDatabasePath)))
    8989        LOG_ERROR("Unable to get icon database location preference");
    9090
    9191    String databasePath(prefDatabasePath, SysStringLen(prefDatabasePath));
    92     SysFreeString(prefDatabasePath);
    9392
    9493    if (databasePath.isEmpty()) {
  • trunk/Source/WebKit/win/WebNotificationCenter.cpp

    r127757 r128809  
    2929
    3030#include "WebNotification.h"
     31#include <WebCore/BString.h>
    3132#include <WebCore/COMPtr.h>
    3233#include <utility>
     
    161162    /* [in] */ IWebNotification* notification)
    162163{
    163     BSTR name;
     164    BString name;
    164165    HRESULT hr = notification->name(&name);
    165166    if (FAILED(hr))
     
    172173
    173174    postNotificationInternal(notification, name, obj.get());
    174     SysFreeString(name);
    175175
    176176    return hr;
  • trunk/Source/WebKit/win/WebPreferences.cpp

    r122280 r128809  
    350350void WebPreferences::setStringValue(CFStringRef key, LPCTSTR value)
    351351{
    352     BSTR val = stringValueForKey(key);
     352    BString val;
     353    val.adoptBSTR(stringValueForKey(key));
    353354    if (val && !wcscmp(val, value))
    354355        return;
    355     SysFreeString(val);
    356356   
    357357    RetainPtr<CFStringRef> valueRef(AdoptCF,
  • trunk/Source/WebKit/win/WebView.cpp

    r128403 r128809  
    200200}
    201201
     202static inline AtomicString toAtomicString(BSTR bstr)
     203{
     204    return AtomicString(bstr, SysStringLen(bstr));
     205}
     206
     207static inline String toString(BSTR bstr)
     208{
     209    return String(bstr, SysStringLen(bstr));
     210}
     211
     212static inline KURL toKURL(BSTR bstr)
     213{
     214    return KURL(KURL(), toString(bstr));
     215}
     216
    202217class PreferencesChangedOrRemovedObserver : public IWebNotificationObserver {
    203218public:
     
    246261        return hr;
    247262
    248     BSTR nameBSTR;
    249     hr = notification->name(&nameBSTR);
    250     if (FAILED(hr))
    251         return hr;
    252263    BString name;
    253     name.adoptBSTR(nameBSTR);
     264    hr = notification->name(&name);
     265    if (FAILED(hr))
     266        return hr;
    254267
    255268    if (wcscmp(name, WebPreferences::webPreferencesChangedNotification()) == 0)
     
    727740
    728741    if (COMPtr<WebPreferences> preferences = m_preferences) {
    729         BSTR identifier = 0;
     742        BString identifier;
    730743        preferences->identifier(&identifier);
    731744
     
    734747        // Make sure we release the reference, since WebPreferences::removeReferenceForIdentifier will check for last reference to WebPreferences
    735748        preferences = 0;
    736         if (identifier) {
     749        if (identifier)
    737750            WebPreferences::removeReferenceForIdentifier(identifier);
    738             SysFreeString(identifier);
    739         }
    740751    }
    741752
     
    25142525    /* [retval][out] */ BOOL* canShow)
    25152526{
    2516     String mimeTypeStr(mimeType, SysStringLen(mimeType));
     2527    String mimeTypeStr = toString(mimeType);
    25172528
    25182529    if (!canShow)
     
    26812692    provideGeolocationTo(m_page, new WebGeolocationClient(this));
    26822693
    2683     BSTR localStoragePath;
    2684     if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath))) {
    2685         m_page->settings()->setLocalStorageDatabasePath(String(localStoragePath, SysStringLen(localStoragePath)));
    2686         SysFreeString(localStoragePath);
    2687     }
     2694    BString localStoragePath;
     2695    if (SUCCEEDED(m_preferences->localStorageDatabasePath(&localStoragePath)))
     2696        m_page->settings()->setLocalStorageDatabasePath(toString(localStoragePath));
    26882697
    26892698    if (m_uiDelegate) {
    2690         BSTR path;
    2691         if (SUCCEEDED(m_uiDelegate->ftpDirectoryTemplatePath(this, &path))) {
    2692             m_page->settings()->setFTPDirectoryTemplatePath(String(path, SysStringLen(path)));
    2693             SysFreeString(path);
    2694         }
     2699        BString path;
     2700        if (SUCCEEDED(m_uiDelegate->ftpDirectoryTemplatePath(this, &path)))
     2701            m_page->settings()->setFTPDirectoryTemplatePath(toString(path));
    26952702    }
    26962703
     
    27002707    webFrame->Release(); // The WebFrame is owned by the Frame, so release our reference to it.
    27012708
    2702     coreFrame->tree()->setName(String(frameName, SysStringLen(frameName)));
     2709    coreFrame->tree()->setName(toString(frameName));
    27032710    coreFrame->init();
    27042711    setGroupName(groupName);
     
    30583065    /* [in] */ BSTR applicationName)
    30593066{
    3060     m_applicationName = String(applicationName, SysStringLen(applicationName));
     3067    m_applicationName = toString(applicationName);
    30613068    m_userAgentStandard = String();
    30623069    return S_OK;
     
    30763083{
    30773084    m_userAgentOverridden = userAgentString;
    3078     m_userAgentCustom = String(userAgentString, SysStringLen(userAgentString));
     3085    m_userAgentCustom = toString(userAgentString);
    30793086    return S_OK;
    30803087}
     
    30973104{
    30983105    String userAgentString = userAgentForKURL(MarshallingHelpers::BSTRToKURL(url));
    3099     *userAgent = SysAllocStringLen(userAgentString.characters(), userAgentString.length());
     3106    *userAgent = BString(userAgentString).release();
    31003107    if (!*userAgent && userAgentString.length())
    31013108        return E_OUTOFMEMORY;
     
    31173124
    31183125    HRESULT hr;
    3119     BSTR oldEncoding;
     3126    BString oldEncoding;
    31203127    hr = customTextEncodingName(&oldEncoding);
    31213128    if (FAILED(hr))
     
    31243131    if (oldEncoding != encodingName && (!oldEncoding || !encodingName || wcscmp(oldEncoding, encodingName))) {
    31253132        if (Frame* coreFrame = core(m_mainFrame))
    3126             coreFrame->loader()->reloadWithOverrideEncoding(String(encodingName, SysStringLen(encodingName)));
     3133            coreFrame->loader()->reloadWithOverrideEncoding(toString(encodingName));
    31273134    }
    31283135
     
    31563163
    31573164    if (!*encodingName)
    3158         *encodingName = SysAllocStringLen(m_overrideEncoding.characters(), m_overrideEncoding.length());
     3165        *encodingName = BString(m_overrideEncoding).release();
    31593166
    31603167    if (!*encodingName && m_overrideEncoding.length())
     
    32313238    nc->removeObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast<IWebPreferences*>(m_preferences.get()));
    32323239
    3233     BSTR identifier = 0;
     3240    BString identifier;
    32343241    oldPrefs->identifier(&identifier);
    32353242    oldPrefs->didRemoveFromWebView();
     
    32383245    m_preferences = webPrefs;
    32393246
    3240     if (identifier) {
     3247    if (identifier)
    32413248        WebPreferences::removeReferenceForIdentifier(identifier);
    3242         SysFreeString(identifier);
    3243     }
    32443249
    32453250    nc->addObserver(this, WebPreferences::webPreferencesChangedNotification(), static_cast<IWebPreferences*>(m_preferences.get()));
     
    33893394        return E_INVALIDARG;
    33903395
    3391     *found = m_page->findString(String(str, SysStringLen(str)), caseFlag ? TextCaseSensitive : TextCaseInsensitive, forward ? FindDirectionForward : FindDirectionBackward, wrapFlag);
     3396    *found = m_page->findString(toString(str), caseFlag ? TextCaseSensitive : TextCaseInsensitive, forward ? FindDirectionForward : FindDirectionBackward, wrapFlag);
    33923397    return S_OK;
    33933398}
     
    34193424}
    34203425
    3421 HRESULT STDMETHODCALLTYPE WebView::executeCoreCommandByName(BSTR bName, BSTR bValue)
    3422 {
    3423     String name(bName, SysStringLen(bName));
    3424     String value(bValue, SysStringLen(bValue));
    3425 
    3426     m_page->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value);
     3426HRESULT STDMETHODCALLTYPE WebView::executeCoreCommandByName(BSTR name, BSTR value)
     3427{
     3428    m_page->focusController()->focusedOrMainFrame()->editor()->command(toString(name)).execute(toString(value));
    34273429
    34283430    return S_OK;
     
    34483450        return E_INVALIDARG;
    34493451
    3450     *matches = m_page->markAllMatchesForText(String(str, SysStringLen(str)), caseSensitive ? TextCaseSensitive : TextCaseInsensitive, highlight, limit);
     3452    *matches = m_page->markAllMatchesForText(toString(str), caseSensitive ? TextCaseSensitive : TextCaseInsensitive, highlight, limit);
    34513453    return S_OK;
    34523454}
     
    35313533    if (!m_page)
    35323534        return S_OK;
    3533     m_page->setGroupName(String(groupName, SysStringLen(groupName)));
     3535    m_page->setGroupName(toString(groupName));
    35343536    return S_OK;
    35353537}
     
    37653767        return E_POINTER;
    37663768
    3767     SchemeRegistry::registerURLSchemeAsLocal(String(scheme, ::SysStringLen(scheme)));
     3769    SchemeRegistry::registerURLSchemeAsLocal(toString(scheme));
    37683770
    37693771    return S_OK;
     
    43164318        /* [in] */ BSTR text)
    43174319{
    4318     String textString(text, ::SysStringLen(text));
    43194320    Position start = m_page->mainFrame()->selection()->selection().start();
    4320     m_page->focusController()->focusedOrMainFrame()->editor()->insertText(textString, 0);
     4321    m_page->focusController()->focusedOrMainFrame()->editor()->insertText(toString(text), 0);
    43214322    m_page->mainFrame()->selection()->setBase(start);
    43224323    return S_OK;
     
    45374538    /* [in] */ IWebNotification* notification)
    45384539{
    4539     BSTR nameBSTR;
    4540     HRESULT hr = notification->name(&nameBSTR);
    4541     if (FAILED(hr))
    4542         return hr;
    4543 
    45444540    BString name;
    4545     name.adoptBSTR(nameBSTR);
     4541    HRESULT hr = notification->name(&name);
     4542    if (FAILED(hr))
     4543        return hr;
    45464544
    45474545    if (!wcscmp(name, WebIconDatabase::iconDatabaseDidAddIconNotification()))
     
    45694567    ASSERT(preferences == m_preferences);
    45704568
    4571     BSTR str;
     4569    BString str;
    45724570    int size;
    45734571    BOOL enabled;
     
    45784576    if (FAILED(hr))
    45794577        return hr;
    4580     settings->setCursiveFontFamily(AtomicString(str, SysStringLen(str)));
    4581     SysFreeString(str);
     4578    settings->setCursiveFontFamily(toAtomicString(str));
     4579    str.clear();
    45824580
    45834581    hr = preferences->defaultFixedFontSize(&size);
     
    45904588        return hr;
    45914589    settings->setDefaultFontSize(size);
    4592    
     4590
    45934591    hr = preferences->defaultTextEncodingName(&str);
    45944592    if (FAILED(hr))
    45954593        return hr;
    4596     settings->setDefaultTextEncodingName(String(str, SysStringLen(str)));
    4597     SysFreeString(str);
     4594    settings->setDefaultTextEncodingName(toString(str));
     4595    str.clear();
    45984596
    45994597    hr = preferences->fantasyFontFamily(&str);
    46004598    if (FAILED(hr))
    46014599        return hr;
    4602     settings->setFantasyFontFamily(AtomicString(str, SysStringLen(str)));
    4603     SysFreeString(str);
     4600    settings->setFantasyFontFamily(toAtomicString(str));
     4601    str.clear();
    46044602
    46054603    hr = preferences->fixedFontFamily(&str);
    46064604    if (FAILED(hr))
    46074605        return hr;
    4608     settings->setFixedFontFamily(AtomicString(str, SysStringLen(str)));
    4609     SysFreeString(str);
     4606    settings->setFixedFontFamily(toAtomicString(str));
     4607    str.clear();
    46104608
    46114609#if ENABLE(VIDEO_TRACK)
     
    46314629        if (FAILED(hr))
    46324630            return hr;
    4633         settings->setLocalStorageDatabasePath(String(str, SysStringLen(str)));
    4634         SysFreeString(str);
     4631        settings->setLocalStorageDatabasePath(toString(str));
     4632        str.clear();
    46354633    }
    46364634
     
    46384636    if (FAILED(hr))
    46394637        return hr;
    4640     settings->setPictographFontFamily(AtomicString(str, SysStringLen(str)));
    4641     SysFreeString(str);
     4638    settings->setPictographFontFamily(toAtomicString(str));
     4639    str.clear();
    46424640
    46434641    hr = preferences->isJavaEnabled(&enabled);
     
    46844682    if (FAILED(hr))
    46854683        return hr;
    4686     settings->setSansSerifFontFamily(AtomicString(str, SysStringLen(str)));
    4687     SysFreeString(str);
     4684    settings->setSansSerifFontFamily(toAtomicString(str));
     4685    str.clear();
    46884686
    46894687    hr = preferences->serifFontFamily(&str);
    46904688    if (FAILED(hr))
    46914689        return hr;
    4692     settings->setSerifFontFamily(AtomicString(str, SysStringLen(str)));
    4693     SysFreeString(str);
     4690    settings->setSerifFontFamily(toAtomicString(str));
     4691    str.clear();
    46944692
    46954693    hr = preferences->standardFontFamily(&str);
    46964694    if (FAILED(hr))
    46974695        return hr;
    4698     settings->setStandardFontFamily(AtomicString(str, SysStringLen(str)));
    4699     SysFreeString(str);
     4696    settings->setStandardFontFamily(toAtomicString(str));
     4697    str.clear();
    47004698
    47014699    hr = preferences->loadsImagesAutomatically(&enabled);
     
    47124710            return hr;
    47134711
    4714         RetainPtr<CFStringRef> urlString(AdoptCF, String(str, SysStringLen(str)).createCFString());
     4712        RetainPtr<CFStringRef> urlString(AdoptCF, toString(str).createCFString());
    47154713        RetainPtr<CFURLRef> url(AdoptCF, CFURLCreateWithString(kCFAllocatorDefault, urlString.get(), 0));
    47164714
     
    47304728
    47314729        settings->setUserStyleSheetLocation(url.get());
    4732         SysFreeString(str);
    4733     } else {
     4730        str.clear();
     4731    } else
    47344732        settings->setUserStyleSheetLocation(KURL());
    4735     }
    47364733
    47374734    hr = preferences->shouldPrintBackgrounds(&enabled);
     
    49794976        return E_POINTER;
    49804977
    4981     String extensionStr(extension, SysStringLen(extension));
    4982 
    4983     *mimeType = BString(MIMETypeRegistry::getMIMETypeForExtension(extensionStr)).release();
     4978    *mimeType = BString(MIMETypeRegistry::getMIMETypeForExtension(toString(extension))).release();
    49844979
    49854980    return S_OK;
     
    52295224    }
    52305225
    5231     BString applicationNameBString(applicationName);
    5232     *groupName = BString(standardUserAgentWithApplicationName(String(applicationNameBString, SysStringLen(applicationNameBString)))).release();
     5226    *groupName = BString(standardUserAgentWithApplicationName(toString(applicationName))).release();
    52335227    return S_OK;
    52345228}
     
    52855279        /* [in] */ BSTR directory)
    52865280{
    5287     PluginDatabase::installedPlugins()->addExtraPluginDirectory(String(directory, SysStringLen(directory)));
     5281    PluginDatabase::installedPlugins()->addExtraPluginDirectory(toString(directory));
    52885282    return S_OK;
    52895283}
     
    61196113        m_embeddedViewMIMETypes = adoptPtr(new HashSet<String>);
    61206114
    6121     m_embeddedViewMIMETypes->add(String(mimeType, ::SysStringLen(mimeType)));
     6115    m_embeddedViewMIMETypes->add(toString(mimeType));
    61226116    return S_OK;
    61236117}
     
    61896183    m_page->setCanStartMedia(canStartPlugins);
    61906184    return S_OK;
    6191 }
    6192 
    6193 static String toString(BSTR bstr)
    6194 {
    6195     return String(bstr, SysStringLen(bstr));
    6196 }
    6197 
    6198 static KURL toKURL(BSTR bstr)
    6199 {
    6200     return KURL(KURL(), toString(bstr));
    62016185}
    62026186
     
    64166400HRESULT WebView::addOriginAccessWhitelistEntry(BSTR sourceOrigin, BSTR destinationProtocol, BSTR destinationHost, BOOL allowDestinationSubdomains)
    64176401{
    6418     SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(String(sourceOrigin, SysStringLen(sourceOrigin))), String(destinationProtocol, SysStringLen(destinationProtocol)), String(destinationHost, SysStringLen(destinationHost)), allowDestinationSubdomains);
     6402    SecurityPolicy::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(toString(sourceOrigin)), toString(destinationProtocol), toString(destinationHost), allowDestinationSubdomains);
    64196403    return S_OK;
    64206404}
     
    64226406HRESULT WebView::removeOriginAccessWhitelistEntry(BSTR sourceOrigin, BSTR destinationProtocol, BSTR destinationHost, BOOL allowDestinationSubdomains)
    64236407{
    6424     SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(String(sourceOrigin, SysStringLen(sourceOrigin))), String(destinationProtocol, SysStringLen(destinationProtocol)), String(destinationHost, SysStringLen(destinationHost)), allowDestinationSubdomains);
     6408    SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(toString(sourceOrigin)), toString(destinationProtocol), toString(destinationHost), allowDestinationSubdomains);
    64256409    return S_OK;
    64266410}
     
    65996583        return E_POINTER;
    66006584
    6601     BSTR descriptionBSTR;
    6602     if (FAILED(error->localizedDescription(&descriptionBSTR)))
    6603         return E_FAIL;
    6604     String descriptionString(descriptionBSTR, SysStringLen(descriptionBSTR));
    6605     SysFreeString(descriptionBSTR);
    6606 
    6607     RefPtr<GeolocationError> geolocationError = GeolocationError::create(GeolocationError::PositionUnavailable, descriptionString);
     6585    BString description;
     6586    if (FAILED(error->localizedDescription(&description)))
     6587        return E_FAIL;
     6588
     6589    RefPtr<GeolocationError> geolocationError = GeolocationError::create(GeolocationError::PositionUnavailable, toString(description));
    66086590    GeolocationController::from(m_page)->errorOccurred(geolocationError.get());
    66096591    return S_OK;
     
    66126594HRESULT WebView::setDomainRelaxationForbiddenForURLScheme(BOOL forbidden, BSTR scheme)
    66136595{
    6614     SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, String(scheme, SysStringLen(scheme)));
     6596    SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, toString(scheme));
    66156597    return S_OK;
    66166598}
     
    69076889        return E_FAIL;
    69086890
    6909     String compositionStr(composition, SysStringLen(composition));
     6891    String compositionStr = toString(composition);
    69106892
    69116893    Vector<CompositionUnderline> underlines;
     
    69396921        return E_FAIL;
    69406922
    6941     String compositionStr(composition, SysStringLen(composition));
     6923    String compositionStr = toString(composition);
    69426924
    69436925    if (compositionStr.isNull())
Note: See TracChangeset for help on using the changeset viewer.