Use HashMap<OwnPtr> for ProgressTracker's items
authorcaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Dec 2011 22:08:14 +0000 (22:08 +0000)
committercaio.oliveira@openbossa.org <caio.oliveira@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Dec 2011 22:08:14 +0000 (22:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75326

Reviewed by Andreas Kling.

* loader/ProgressTracker.cpp:
(WebCore::ProgressTracker::~ProgressTracker): although is empty, the destructor was
kept so in the header file we can forward declare ProgressItem and use in an OwnPtr.
(WebCore::ProgressTracker::reset):
(WebCore::ProgressTracker::incrementProgress):
(WebCore::ProgressTracker::completeProgress): removed a useless assignment to item
member just before it is deleted.
* loader/ProgressTracker.h:

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

Source/WebCore/ChangeLog
Source/WebCore/loader/ProgressTracker.cpp
Source/WebCore/loader/ProgressTracker.h

index 3f4f00d..0163479 100644 (file)
@@ -1,3 +1,19 @@
+2011-12-28  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
+
+        Use HashMap<OwnPtr> for ProgressTracker's items
+        https://bugs.webkit.org/show_bug.cgi?id=75326
+
+        Reviewed by Andreas Kling.
+
+        * loader/ProgressTracker.cpp:
+        (WebCore::ProgressTracker::~ProgressTracker): although is empty, the destructor was
+        kept so in the header file we can forward declare ProgressItem and use in an OwnPtr.
+        (WebCore::ProgressTracker::reset):
+        (WebCore::ProgressTracker::incrementProgress):
+        (WebCore::ProgressTracker::completeProgress): removed a useless assignment to item
+        member just before it is deleted.
+        * loader/ProgressTracker.h:
+
 2011-12-28  Alexis Menard  <alexis.menard@openbossa.org>
 
         getComputedStyle for border-color is not implemented.
index 6b03dca..4f2b7ec 100644 (file)
@@ -78,7 +78,6 @@ ProgressTracker::ProgressTracker()
 
 ProgressTracker::~ProgressTracker()
 {
-    deleteAllValues(m_progressItems);
 }
 
 PassOwnPtr<ProgressTracker> ProgressTracker::create()
@@ -93,7 +92,6 @@ double ProgressTracker::estimatedProgress() const
 
 void ProgressTracker::reset()
 {
-    deleteAllValues(m_progressItems);
     m_progressItems.clear();    
 
     m_totalPageAndResourceBytesToLoad = 0;
@@ -176,7 +174,7 @@ void ProgressTracker::incrementProgress(unsigned long identifier, const Resource
         item->bytesReceived = 0;
         item->estimatedLength = estimatedLength;
     } else
-        m_progressItems.set(identifier, adoptPtr(new ProgressItem(estimatedLength)).leakPtr());
+        m_progressItems.set(identifier, adoptPtr(new ProgressItem(estimatedLength)));
 }
 
 void ProgressTracker::incrementProgress(unsigned long identifier, const char*, int length)
@@ -254,10 +252,8 @@ void ProgressTracker::completeProgress(unsigned long identifier)
     // Adjust the total expected bytes to account for any overage/underage.
     long long delta = item->bytesReceived - item->estimatedLength;
     m_totalPageAndResourceBytesToLoad += delta;
-    item->estimatedLength = item->bytesReceived;
-    
+
     m_progressItems.remove(identifier);
-    delete item;
 }
 
 unsigned long ProgressTracker::createUniqueIdentifier()
index 4744983..ddacff2 100644 (file)
@@ -29,6 +29,7 @@
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
@@ -76,7 +77,7 @@ private:
     RefPtr<Frame> m_originatingProgressFrame;
     
     int m_numProgressTrackedFrames;
-    HashMap<unsigned long, ProgressItem*> m_progressItems;
+    HashMap<unsigned long, OwnPtr<ProgressItem> > m_progressItems;
 };
     
 }