⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 102085 in webkit


Ignore:
Timestamp:
Dec 5, 2011, 6:55:47 PM (15 years ago)
Author:
Darin Adler
Message:

Use HashMap<OwnPtr> in CrossOriginPreflightResultCache
https://bugs.webkit.org/show_bug.cgi?id=73785

Reviewed by Andreas Kling.

  • loader/CrossOriginPreflightResultCache.cpp:

(WebCore::CrossOriginPreflightResultCache::appendEntry): Changed code to use set
instead of add, since it wants to replace existing entries. Also removed leakPtr
and removed the FIXME that documented the memory leak now fixed here.
(WebCore::CrossOriginPreflightResultCache::canSkipPreflight): Removed unneeded
std:: prefix here and also unneeded explicit delete call.
(WebCore::CrossOriginPreflightResultCache::empty): Removed unneeded deleteAllValues
call here.

  • loader/CrossOriginPreflightResultCache.h: Make mapped value of the

CrossOriginPreflightResultHashMap be OwnPtr instead of raw pointer.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102081 r102085  
     12011-12-05  Darin Adler  <darin@apple.com>
     2
     3        Use HashMap<OwnPtr> in CrossOriginPreflightResultCache
     4        https://bugs.webkit.org/show_bug.cgi?id=73785
     5
     6        Reviewed by Andreas Kling.
     7
     8        * loader/CrossOriginPreflightResultCache.cpp:
     9        (WebCore::CrossOriginPreflightResultCache::appendEntry): Changed code to use set
     10        instead of add, since it wants to replace existing entries. Also removed leakPtr
     11        and removed the FIXME that documented the memory leak now fixed here.
     12        (WebCore::CrossOriginPreflightResultCache::canSkipPreflight): Removed unneeded
     13        std:: prefix here and also unneeded explicit delete call.
     14        (WebCore::CrossOriginPreflightResultCache::empty): Removed unneeded deleteAllValues
     15        call here.
     16
     17        * loader/CrossOriginPreflightResultCache.h: Make mapped value of the
     18        CrossOriginPreflightResultHashMap be OwnPtr instead of raw pointer.
     19
    1202011-12-05  Darin Adler  <darin@apple.com>
    221
  • trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp

    r93886 r102085  
    160160{
    161161    ASSERT(isMainThread());
    162     CrossOriginPreflightResultCacheItem* resultPtr = preflightResult.leakPtr();
    163     pair<CrossOriginPreflightResultHashMap::iterator, bool> addResult = m_preflightHashMap.add(make_pair(origin, url), resultPtr);
    164     if (!addResult.second) {
    165         // FIXME: We need to delete the old value before replacing with the new one.
    166         addResult.first->second = resultPtr;
    167     }
     162    m_preflightHashMap.set(make_pair(origin, url), preflightResult);
    168163}
    169164
     
    171166{
    172167    ASSERT(isMainThread());
    173     CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.find(std::make_pair(origin, url));
     168    CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.find(make_pair(origin, url));
    174169    if (cacheIt == m_preflightHashMap.end())
    175170        return false;
     
    178173        return true;
    179174
    180     delete cacheIt->second;
    181175    m_preflightHashMap.remove(cacheIt);
    182176    return false;
     
    186180{
    187181    ASSERT(isMainThread());
    188     deleteAllValues(m_preflightHashMap);
    189182    m_preflightHashMap.clear();
    190183}
  • trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h

    r93886 r102085  
    7979        CrossOriginPreflightResultCache() { }
    8080
    81         typedef HashMap<std::pair<String, KURL>, CrossOriginPreflightResultCacheItem*> CrossOriginPreflightResultHashMap;
     81        typedef HashMap<std::pair<String, KURL>, OwnPtr<CrossOriginPreflightResultCacheItem> > CrossOriginPreflightResultHashMap;
    8282
    8383        CrossOriginPreflightResultHashMap m_preflightHashMap;
Note: See TracChangeset for help on using the changeset viewer.