Title: [102085] trunk/Source/WebCore
Revision
102085
Author
[email protected]
Date
2011-12-05 18:55:47 -0800 (Mon, 05 Dec 2011)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102084 => 102085)


--- trunk/Source/WebCore/ChangeLog	2011-12-06 02:17:22 UTC (rev 102084)
+++ trunk/Source/WebCore/ChangeLog	2011-12-06 02:55:47 UTC (rev 102085)
@@ -1,5 +1,24 @@
 2011-12-05  Darin Adler  <[email protected]>
 
+        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.
+
+2011-12-05  Darin Adler  <[email protected]>
+
         Some small improvements to ContainerNode.h
         https://bugs.webkit.org/show_bug.cgi?id=73786
 

Modified: trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp (102084 => 102085)


--- trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp	2011-12-06 02:17:22 UTC (rev 102084)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp	2011-12-06 02:55:47 UTC (rev 102085)
@@ -159,25 +159,19 @@
 void CrossOriginPreflightResultCache::appendEntry(const String& origin, const KURL& url, PassOwnPtr<CrossOriginPreflightResultCacheItem> preflightResult)
 {
     ASSERT(isMainThread());
-    CrossOriginPreflightResultCacheItem* resultPtr = preflightResult.leakPtr();
-    pair<CrossOriginPreflightResultHashMap::iterator, bool> addResult = m_preflightHashMap.add(make_pair(origin, url), resultPtr);
-    if (!addResult.second) {
-        // FIXME: We need to delete the old value before replacing with the new one.
-        addResult.first->second = resultPtr;
-    }
+    m_preflightHashMap.set(make_pair(origin, url), preflightResult);
 }
 
 bool CrossOriginPreflightResultCache::canSkipPreflight(const String& origin, const KURL& url, StoredCredentials includeCredentials, const String& method, const HTTPHeaderMap& requestHeaders)
 {
     ASSERT(isMainThread());
-    CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.find(std::make_pair(origin, url));
+    CrossOriginPreflightResultHashMap::iterator cacheIt = m_preflightHashMap.find(make_pair(origin, url));
     if (cacheIt == m_preflightHashMap.end())
         return false;
 
     if (cacheIt->second->allowsRequest(includeCredentials, method, requestHeaders))
         return true;
 
-    delete cacheIt->second;
     m_preflightHashMap.remove(cacheIt);
     return false;
 }
@@ -185,7 +179,6 @@
 void CrossOriginPreflightResultCache::empty()
 {
     ASSERT(isMainThread());
-    deleteAllValues(m_preflightHashMap);
     m_preflightHashMap.clear();
 }
 

Modified: trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h (102084 => 102085)


--- trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h	2011-12-06 02:17:22 UTC (rev 102084)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.h	2011-12-06 02:55:47 UTC (rev 102085)
@@ -78,7 +78,7 @@
     private:
         CrossOriginPreflightResultCache() { }
 
-        typedef HashMap<std::pair<String, KURL>, CrossOriginPreflightResultCacheItem*> CrossOriginPreflightResultHashMap;
+        typedef HashMap<std::pair<String, KURL>, OwnPtr<CrossOriginPreflightResultCacheItem> > CrossOriginPreflightResultHashMap;
 
         CrossOriginPreflightResultHashMap m_preflightHashMap;
     };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to