Title: [137768] trunk/Source/WebKit2
Revision
137768
Author
[email protected]
Date
2012-12-14 14:07:32 -0800 (Fri, 14 Dec 2012)

Log Message

DownloadProxyMap should keep track of outstanding DownloadProxy objects
https://bugs.webkit.org/show_bug.cgi?id=105053

Reviewed by Andreas Kling.

This is more work towards removing the m_downloads map from every WebContext object.

* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didFinish):
(WebKit::DownloadProxy::didFail):
(WebKit::DownloadProxy::didCancel):
* UIProcess/Downloads/DownloadProxyMap.cpp:
(WebKit::DownloadProxyMap::createDownloadProxy):
(WebKit):
(WebKit::DownloadProxyMap::downloadFinished):
* UIProcess/Downloads/DownloadProxyMap.h:
(DownloadProxyMap):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::createDownloadProxy):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (137767 => 137768)


--- trunk/Source/WebKit2/ChangeLog	2012-12-14 21:57:58 UTC (rev 137767)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-14 22:07:32 UTC (rev 137768)
@@ -1,3 +1,25 @@
+2012-12-14  Anders Carlsson  <[email protected]>
+
+        DownloadProxyMap should keep track of outstanding DownloadProxy objects
+        https://bugs.webkit.org/show_bug.cgi?id=105053
+
+        Reviewed by Andreas Kling.
+
+        This is more work towards removing the m_downloads map from every WebContext object.
+
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::didFinish):
+        (WebKit::DownloadProxy::didFail):
+        (WebKit::DownloadProxy::didCancel):
+        * UIProcess/Downloads/DownloadProxyMap.cpp:
+        (WebKit::DownloadProxyMap::createDownloadProxy):
+        (WebKit):
+        (WebKit::DownloadProxyMap::downloadFinished):
+        * UIProcess/Downloads/DownloadProxyMap.h:
+        (DownloadProxyMap):
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::createDownloadProxy):
+
 2012-12-14  Mark Lam  <[email protected]>
 
         Introducing the DatabaseStrategy and database servers.

Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (137767 => 137768)


--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp	2012-12-14 21:57:58 UTC (rev 137767)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp	2012-12-14 22:07:32 UTC (rev 137768)
@@ -28,6 +28,7 @@
 
 #include "AuthenticationChallengeProxy.h"
 #include "DataReference.h"
+#include "DownloadProxyMap.h"
 #include "WebContext.h"
 #include "WebData.h"
 #include "WebProcessMessages.h"
@@ -156,6 +157,7 @@
 
     // This can cause the DownloadProxy object to be deleted.
     m_webContext->downloadFinished(this);
+    DownloadProxyMap::shared().downloadFinished(this);
 }
 
 static PassRefPtr<WebData> createWebData(const CoreIPC::DataReference& data)
@@ -177,6 +179,7 @@
 
     // This can cause the DownloadProxy object to be deleted.
     m_webContext->downloadFinished(this);
+    DownloadProxyMap::shared().downloadFinished(this);
 }
 
 void DownloadProxy::didCancel(const CoreIPC::DataReference& resumeData)
@@ -187,6 +190,7 @@
 
     // This can cause the DownloadProxy object to be deleted.
     m_webContext->downloadFinished(this);
+    DownloadProxyMap::shared().downloadFinished(this);
 }
 
 #if PLATFORM(QT)

Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxyMap.cpp (137767 => 137768)


--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxyMap.cpp	2012-12-14 21:57:58 UTC (rev 137767)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxyMap.cpp	2012-12-14 22:07:32 UTC (rev 137768)
@@ -46,11 +46,19 @@
 {
 }
 
-PassRefPtr<DownloadProxy> DownloadProxyMap::createDownloadProxy(WebContext* webContext)
+DownloadProxy* DownloadProxyMap::createDownloadProxy(WebContext* webContext)
 {
     RefPtr<DownloadProxy> downloadProxy = DownloadProxy::create(webContext);
+    m_downloads.set(downloadProxy->downloadID(), downloadProxy);
 
-    return downloadProxy.release();
+    return downloadProxy.get();
 }
 
+void DownloadProxyMap::downloadFinished(DownloadProxy* downloadProxy)
+{
+    ASSERT(m_downloads.contains(downloadProxy->downloadID()));
+
+    m_downloads.remove(downloadProxy->downloadID());
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxyMap.h (137767 => 137768)


--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxyMap.h	2012-12-14 21:57:58 UTC (rev 137767)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxyMap.h	2012-12-14 22:07:32 UTC (rev 137768)
@@ -26,6 +26,7 @@
 #ifndef DownloadProxyMap_h
 #define DownloadProxyMap_h
 
+#include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassRefPtr.h>
 
@@ -40,11 +41,15 @@
 public:
     static DownloadProxyMap& shared();
 
-    PassRefPtr<DownloadProxy> createDownloadProxy(WebContext*);
+    DownloadProxy* createDownloadProxy(WebContext*);
 
+    void downloadFinished(DownloadProxy*);
+
 private:
     DownloadProxyMap();
     ~DownloadProxyMap();
+
+    HashMap<uint64_t, RefPtr<DownloadProxy> > m_downloads;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (137767 => 137768)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-14 21:57:58 UTC (rev 137767)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-12-14 22:07:32 UTC (rev 137768)
@@ -836,10 +836,10 @@
 
 DownloadProxy* WebContext::createDownloadProxy()
 {
-    RefPtr<DownloadProxy> downloadProxy = DownloadProxyMap::shared().createDownloadProxy(this);
+    DownloadProxy* downloadProxy = DownloadProxyMap::shared().createDownloadProxy(this);
     m_downloads.set(downloadProxy->downloadID(), downloadProxy);
     addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID(), this);
-    return downloadProxy.get();
+    return downloadProxy;
 }
 
 void WebContext::downloadFinished(DownloadProxy* downloadProxy)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to