[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 11:18:14 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2ea05a9fc305a311849c59388e62139de88b34b6
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Jul 17 20:20:25 2010 +0000

    Open streams should not keep a plug-in view alive
    https://bugs.webkit.org/show_bug.cgi?id=42503
    
    Reviewed by Dan Bernstein.
    
    PluginView::Stream now has a weak reference to its PluginView.
    
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::Stream::~Stream):
    Assert that the plug-in view is null.
    
    (WebKit::PluginView::Stream::didFail):
    After calling removeStream, set the plug-in view member variable to 0. This is OK to do
    since we keep a reference to the Stream, so we're sure that the call to removeStream does not
    destroy the stream.
    
    (WebKit::PluginView::Stream::didFinishLoading):
    Ditto .
    
    (WebKit::PluginView::~PluginView):
    Cancel all streams.
    
    (WebKit::PluginView::cancelAllStreams):
    Cancel all streams.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63611 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 2f55fb7..cc3f1b8 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,30 @@
+2010-07-17  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Open streams should not keep a plug-in view alive
+        https://bugs.webkit.org/show_bug.cgi?id=42503
+
+        PluginView::Stream now has a weak reference to its PluginView.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::Stream::~Stream):
+        Assert that the plug-in view is null.
+
+        (WebKit::PluginView::Stream::didFail):
+        After calling removeStream, set the plug-in view member variable to 0. This is OK to do
+        since we keep a reference to the Stream, so we're sure that the call to removeStream does not
+        destroy the stream.
+
+        (WebKit::PluginView::Stream::didFinishLoading):
+        Ditto .
+
+        (WebKit::PluginView::~PluginView):
+        Cancel all streams.
+        
+        (WebKit::PluginView::cancelAllStreams):
+        Cancel all streams.
+
 2010-07-16  Zhe Su  <suzhe at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index df16295..b77fa6b 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -72,6 +72,7 @@ public:
     {
         return adoptRef(new Stream(pluginView, streamID, request));
     }
+    ~Stream();
 
     void start();
     void cancel();
@@ -86,13 +87,14 @@ private:
         , m_streamWasCancelled(false)
     {
     }
+
     // NetscapePluginStreamLoaderClient
     virtual void didReceiveResponse(NetscapePlugInStreamLoader*, const ResourceResponse&);
     virtual void didReceiveData(NetscapePlugInStreamLoader*, const char*, int);
     virtual void didFail(NetscapePlugInStreamLoader*, const ResourceError&);
     virtual void didFinishLoading(NetscapePlugInStreamLoader*);
 
-    RefPtr<PluginView> m_pluginView;
+    PluginView* m_pluginView;
     uint64_t m_streamID;
     const ResourceRequest m_request;
     
@@ -103,6 +105,11 @@ private:
     RefPtr<NetscapePlugInStreamLoader> m_loader;
 };
 
+PluginView::Stream::~Stream()
+{
+    ASSERT(!m_pluginView);
+}
+    
 void PluginView::Stream::start()
 {
     ASSERT(!m_loader);
@@ -175,15 +182,15 @@ void PluginView::Stream::didReceiveData(NetscapePlugInStreamLoader*, const char*
 
 void PluginView::Stream::didFail(NetscapePlugInStreamLoader*, const ResourceError& error) 
 {
-    // We don't want to call streamDidFail if the stream was explicitly cancelled by the plug-in.
-    if (m_streamWasCancelled)
-        return;
-
     // Calling streamDidFail could cause us to be deleted, so we hold on to a reference here.
     RefPtr<Stream> protect(this);
 
-    m_pluginView->m_plugin->streamDidFail(m_streamID, error.isCancellation());
+    // We only want to call streamDidFail if the stream was not explicitly cancelled by the plug-in.
+    if (!m_streamWasCancelled)
+        m_pluginView->m_plugin->streamDidFail(m_streamID, error.isCancellation());
+
     m_pluginView->removeStream(this);
+    m_pluginView = 0;
 }
 
 void PluginView::Stream::didFinishLoading(NetscapePlugInStreamLoader*)
@@ -193,6 +200,7 @@ void PluginView::Stream::didFinishLoading(NetscapePlugInStreamLoader*)
 
     m_pluginView->m_plugin->streamDidFinishLoading(m_streamID);
     m_pluginView->removeStream(this);
+    m_pluginView = 0;
 }
 
 PluginView::PluginView(WebCore::HTMLPlugInElement* pluginElement, PassRefPtr<Plugin> plugin, const Plugin::Parameters& parameters)
@@ -210,12 +218,16 @@ PluginView::~PluginView()
     if (m_isWaitingUntilMediaCanStart)
         m_pluginElement->document()->removeMediaCanStartListener(this);
 
+    // Cancel all pending frame loads.
     FrameLoadMap::iterator end = m_pendingFrameLoads.end();
     for (FrameLoadMap::iterator it = m_pendingFrameLoads.begin(), end = m_pendingFrameLoads.end(); it != end; ++it)
         it->first->setLoadListener(0);
-    
+
     if (m_plugin && m_isInitialized)
         m_plugin->destroy();
+
+    // Cancel all streams.
+    cancelAllStreams();
 }
 
 void PluginView::initializePlugin()
@@ -454,6 +466,18 @@ void PluginView::removeStream(Stream* stream)
     m_streams.remove(stream->streamID());
 }
 
+void PluginView::cancelAllStreams()
+{
+    Vector<RefPtr<Stream> > streams;
+    copyValuesToVector(m_streams, streams);
+    
+    for (size_t i = 0; i < streams.size(); ++i)
+        streams[i]->cancel();
+
+    // Cancelling a stream removes it from the m_streams map, so if we cancel all streams the map should be empty.
+    ASSERT(m_streams.isEmpty());
+}
+
 void PluginView::invalidateRect(const IntRect& dirtyRect)
 {
     if (!parent() || !m_plugin || !m_isInitialized)
diff --git a/WebKit2/WebProcess/Plugins/PluginView.h b/WebKit2/WebProcess/Plugins/PluginView.h
index bff43ee..a15b0ef 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/WebKit2/WebProcess/Plugins/PluginView.h
@@ -73,7 +73,8 @@ private:
     class Stream;
     void addStream(Stream*);
     void removeStream(Stream*);
-    
+    void cancelAllStreams();
+
     // WebCore::Widget
     virtual void setFrameRect(const WebCore::IntRect&);
     virtual void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list