Title: [116917] trunk/Source/WebCore
Revision
116917
Author
[email protected]
Date
2012-05-13 22:26:17 -0700 (Sun, 13 May 2012)

Log Message

Listeners map uses raw pointers, but should use OwnPtr
https://bugs.webkit.org/show_bug.cgi?id=86298

Reviewed by Dan Bernstein.

* bindings/js/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::~PageScriptDebugServer): Removed call
to deleteAllValues since the destructor now takes care of this
(WebCore::PageScriptDebugServer::addListener): Changed idiom of the add
function call here to use adoptPtr.
(WebCore::PageScriptDebugServer::removeListener): Added a now-needed
call to get and removed a now-uneeeded call to delete.
* bindings/js/PageScriptDebugServer.h: Changed the key type of
PageListenersMap to OwnPtr.

* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::~ScriptDebugServer): Removed code to delete
the values in m_pageListenersMap. This map was never used and so I have
removed it.
* bindings/js/ScriptDebugServer.h: Removed the type PageListenersMap
and the unused data member, m_pageListenersMap.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (116916 => 116917)


--- trunk/Source/WebCore/ChangeLog	2012-05-14 05:23:37 UTC (rev 116916)
+++ trunk/Source/WebCore/ChangeLog	2012-05-14 05:26:17 UTC (rev 116917)
@@ -1,3 +1,27 @@
+2012-05-13  Darin Adler  <[email protected]>
+
+        Listeners map uses raw pointers, but should use OwnPtr
+        https://bugs.webkit.org/show_bug.cgi?id=86298
+
+        Reviewed by Dan Bernstein.
+
+        * bindings/js/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::~PageScriptDebugServer): Removed call
+        to deleteAllValues since the destructor now takes care of this
+        (WebCore::PageScriptDebugServer::addListener): Changed idiom of the add
+        function call here to use adoptPtr.
+        (WebCore::PageScriptDebugServer::removeListener): Added a now-needed
+        call to get and removed a now-uneeeded call to delete.
+        * bindings/js/PageScriptDebugServer.h: Changed the key type of
+        PageListenersMap to OwnPtr.
+
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::~ScriptDebugServer): Removed code to delete
+        the values in m_pageListenersMap. This map was never used and so I have
+        removed it.
+        * bindings/js/ScriptDebugServer.h: Removed the type PageListenersMap
+        and the unused data member, m_pageListenersMap.
+
 2012-05-13  Yoshifumi Inoue  <[email protected]>
 
         [Forms] Move ValidityState methods implementation to another place

Modified: trunk/Source/WebCore/bindings/js/PageScriptDebugServer.cpp (116916 => 116917)


--- trunk/Source/WebCore/bindings/js/PageScriptDebugServer.cpp	2012-05-14 05:23:37 UTC (rev 116916)
+++ trunk/Source/WebCore/bindings/js/PageScriptDebugServer.cpp	2012-05-14 05:26:17 UTC (rev 116917)
@@ -75,7 +75,6 @@
 
 PageScriptDebugServer::~PageScriptDebugServer()
 {
-    deleteAllValues(m_pageListenersMap);
 }
 
 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page)
@@ -83,11 +82,9 @@
     ASSERT_ARG(listener, listener);
     ASSERT_ARG(page, page);
 
-    PageListenersMap::AddResult result = m_pageListenersMap.add(page, 0);
-    if (result.isNewEntry)
-        result.iterator->second = new ListenerSet;
-
-    ListenerSet* listeners = result.iterator->second;
+    OwnPtr<ListenerSet>& listeners = m_pageListenersMap.add(page, nullptr).iterator->second;
+    if (!listeners)
+        listeners = adoptPtr(new ListenerSet);
     listeners->add(listener);
 
     recompileAllJSFunctionsSoon();
@@ -103,11 +100,10 @@
     if (it == m_pageListenersMap.end())
         return;
 
-    ListenerSet* listeners = it->second;
+    ListenerSet* listeners = it->second.get();
     listeners->remove(listener);
     if (listeners->isEmpty()) {
         m_pageListenersMap.remove(it);
-        delete listeners;
         didRemoveLastListener(page);
     }
 }

Modified: trunk/Source/WebCore/bindings/js/PageScriptDebugServer.h (116916 => 116917)


--- trunk/Source/WebCore/bindings/js/PageScriptDebugServer.h	2012-05-14 05:23:37 UTC (rev 116916)
+++ trunk/Source/WebCore/bindings/js/PageScriptDebugServer.h	2012-05-14 05:26:17 UTC (rev 116917)
@@ -54,7 +54,7 @@
     virtual void recompileAllJSFunctions(Timer<ScriptDebugServer>*);
 
 private:
-    typedef HashMap<Page*, ListenerSet*> PageListenersMap;
+    typedef HashMap<Page*, OwnPtr<ListenerSet> > PageListenersMap;
 
     PageScriptDebugServer();
     virtual ~PageScriptDebugServer();

Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp (116916 => 116917)


--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-05-14 05:23:37 UTC (rev 116916)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-05-14 05:26:17 UTC (rev 116917)
@@ -65,7 +65,6 @@
 
 ScriptDebugServer::~ScriptDebugServer()
 {
-    deleteAllValues(m_pageListenersMap);
 }
 
 String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber)

Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.h (116916 => 116917)


--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.h	2012-05-14 05:23:37 UTC (rev 116916)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.h	2012-05-14 05:26:17 UTC (rev 116917)
@@ -133,11 +133,9 @@
     virtual void didExecuteProgram(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno);
     virtual void didReachBreakpoint(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno);
 
-    typedef HashMap<Page*, ListenerSet*> PageListenersMap;
     typedef HashMap<long, ScriptBreakpoint> LineToBreakpointMap;
     typedef HashMap<intptr_t, LineToBreakpointMap> SourceIdToBreakpointsMap;
 
-    PageListenersMap m_pageListenersMap;
     bool m_callingListeners;
     PauseOnExceptionsState m_pauseOnExceptionsState;
     bool m_pauseOnNextStatement;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to