Title: [128271] trunk/Source/WebKit2
Revision
128271
Author
da...@apple.com
Date
2012-09-12 00:35:58 -0700 (Wed, 12 Sep 2012)

Log Message

Make NetscapePlugin::m_timers use HashMap<OwnPtr> instead of deleteAllValues
https://bugs.webkit.org/show_bug.cgi?id=96469

Reviewed by Dan Bernstein.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::scheduleTimer): Call release rather than leakPtr when
entering a timer into the map.
(WebKit::NetscapePlugin::unscheduleTimer): Take an existing timer from the map
with the take function rather than the roundabout code needed before.
(WebKit::NetscapePlugin::destroy): Remove now-unneeded call to deleteAllValues.
* WebProcess/Plugins/Netscape/NetscapePlugin.h: Change the value type for
TimerMap to OwnPtr<Timer> rather than Timer*.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (128270 => 128271)


--- trunk/Source/WebKit2/ChangeLog	2012-09-12 07:29:52 UTC (rev 128270)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-12 07:35:58 UTC (rev 128271)
@@ -1,3 +1,19 @@
+2012-09-12  Darin Adler  <da...@apple.com>
+
+        Make NetscapePlugin::m_timers use HashMap<OwnPtr> instead of deleteAllValues
+        https://bugs.webkit.org/show_bug.cgi?id=96469
+
+        Reviewed by Dan Bernstein.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::scheduleTimer): Call release rather than leakPtr when
+        entering a timer into the map.
+        (WebKit::NetscapePlugin::unscheduleTimer): Take an existing timer from the map
+        with the take function rather than the roundabout code needed before.
+        (WebKit::NetscapePlugin::destroy): Remove now-unneeded call to deleteAllValues.
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h: Change the value type for
+        TimerMap to OwnPtr<Timer> rather than Timer*.
+
 2012-09-11  Anders Carlsson  <ander...@apple.com>
 
         Accelerated compositing should always be forced when using the tiled drawing area

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (128270 => 128271)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2012-09-12 07:29:52 UTC (rev 128270)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2012-09-12 07:35:58 UTC (rev 128271)
@@ -375,21 +375,15 @@
     
     // FIXME: Based on the plug-in visibility, figure out if we should throttle the timer, or if we should start it at all.
     timer->start();
-    m_timers.set(timerID, timer.leakPtr());
+    m_timers.set(timerID, timer.release());
 
     return timerID;
 }
 
 void NetscapePlugin::unscheduleTimer(unsigned timerID)
 {
-    TimerMap::iterator it = m_timers.find(timerID);
-    if (it == m_timers.end())
-        return;
-
-    OwnPtr<Timer> timer = adoptPtr(it->second);
-    m_timers.remove(it);
-
-    timer->stop();
+    if (OwnPtr<Timer> timer = m_timers.take(timerID))
+        timer->stop();
 }
 
 double NetscapePlugin::contentsScaleFactor()
@@ -687,7 +681,6 @@
 
     platformDestroy();
 
-    deleteAllValues(m_timers);
     m_timers.clear();
 }
     

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (128270 => 128271)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2012-09-12 07:29:52 UTC (rev 128270)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2012-09-12 07:35:58 UTC (rev 128271)
@@ -308,7 +308,7 @@
 
         WebCore::RunLoop::Timer<Timer> m_timer;
     };
-    typedef HashMap<unsigned, Timer*> TimerMap;
+    typedef HashMap<unsigned, OwnPtr<Timer> > TimerMap;
     TimerMap m_timers;
     unsigned m_nextTimerID;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to