[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:14:52 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 3d51301540e98b87f6624f0d3ff14759fb7a5f9d
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jul 15 23:08:34 2010 +0000

    Handle failed loads correctly
    https://bugs.webkit.org/show_bug.cgi?id=42418
    
    Reviewed by Sam Weinig.
    
    * WebProcess/Plugins/DummyPlugin.cpp:
    (WebKit::DummyPlugin::streamDidFail):
    * WebProcess/Plugins/DummyPlugin.h:
    Add empty stub.
    
    * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
    (WebKit::NetscapePlugin::streamDidFail):
    Call NetscapePluginStream::didFail.
    
    * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
    (WebKit::NetscapePluginStream::didReceiveResponse):
    Take a reference to the plug-in stream in case starting it causes it to be destroyed.
    
    (WebKit::NetscapePluginStream::didFail):
    Take a reference to the plug-in stream in case stopping it causes it to be destroyed.
    
    (WebKit::NetscapePluginStream::destroy):
    Cancel the stream.
    
    (WebKit::NetscapePluginStream::start):
    If we fail to start the stream, cancel the load.
    
    (WebKit::NetscapePluginStream::cancel):
    Call NetscapePlugin::cancelStreamLoad.
    
    (WebKit::NetscapePluginStream::notifyAndDestroyStream):
    Don't call cancel here. notifyAndDestroyStream can be called when we don't want to cancel the
    load, such as when it's already failed to load.
    
    * WebProcess/Plugins/Netscape/NetscapePluginStream.h:
    Add didFail.
    
    * WebProcess/Plugins/Plugin.h:
    Add pure virtual streamDidFail member function.
    
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::Stream::Stream):
    Initialize m_streamWasCancelled to false.
    
    (WebKit::PluginView::Stream::cancel):
    Set m_streamWasCancelled to true.
    
    (WebKit::PluginView::Stream::didFail):
    Call Plugin::streamDidFail.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63484 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 9ab3f42..bd70df0 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,55 @@
+2010-07-15  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Handle failed loads correctly
+        https://bugs.webkit.org/show_bug.cgi?id=42418
+
+        * WebProcess/Plugins/DummyPlugin.cpp:
+        (WebKit::DummyPlugin::streamDidFail):
+        * WebProcess/Plugins/DummyPlugin.h:
+        Add empty stub.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::streamDidFail):
+        Call NetscapePluginStream::didFail.
+    
+        * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
+        (WebKit::NetscapePluginStream::didReceiveResponse):
+        Take a reference to the plug-in stream in case starting it causes it to be destroyed.
+        
+        (WebKit::NetscapePluginStream::didFail):
+        Take a reference to the plug-in stream in case stopping it causes it to be destroyed.
+
+        (WebKit::NetscapePluginStream::destroy):
+        Cancel the stream.
+
+        (WebKit::NetscapePluginStream::start):
+        If we fail to start the stream, cancel the load.
+
+        (WebKit::NetscapePluginStream::cancel):
+        Call NetscapePlugin::cancelStreamLoad.
+
+        (WebKit::NetscapePluginStream::notifyAndDestroyStream):
+        Don't call cancel here. notifyAndDestroyStream can be called when we don't want to cancel the
+        load, such as when it's already failed to load.
+
+        * WebProcess/Plugins/Netscape/NetscapePluginStream.h:
+        Add didFail.
+
+        * WebProcess/Plugins/Plugin.h:
+        Add pure virtual streamDidFail member function.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::Stream::Stream):
+        Initialize m_streamWasCancelled to false.
+
+        (WebKit::PluginView::Stream::cancel):
+        Set m_streamWasCancelled to true.
+
+        (WebKit::PluginView::Stream::didFail):
+        Call Plugin::streamDidFail.
+
 2010-07-15  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Anders Carlsson.
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
index 5392e1a..c97f6ba 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.cpp
@@ -83,4 +83,8 @@ void DummyPlugin::streamDidReceiveResponse(uint64_t streamID, const WebCore::KUR
 {
 }
 
+void DummyPlugin::streamDidFail(uint64_t streamID, bool wasCancelled)
+{
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/DummyPlugin.h b/WebKit2/WebProcess/Plugins/DummyPlugin.h
index ecd027a..2040a12 100644
--- a/WebKit2/WebProcess/Plugins/DummyPlugin.h
+++ b/WebKit2/WebProcess/Plugins/DummyPlugin.h
@@ -51,6 +51,8 @@ private:
     virtual void didEvaluateJavaScript(uint64_t requestID, const WebCore::String& requestURLString, const WebCore::String& result);
     virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::KURL& responseURL, uint32_t streamLength, 
                                           uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
+    virtual void streamDidFail(uint64_t streamID, bool wasCancelled);
+
     virtual PluginController* controller();
 };
 
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
index 6ebc67e..99306b5 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
@@ -337,6 +337,12 @@ void NetscapePlugin::streamDidReceiveResponse(uint64_t streamID, const KURL& res
         pluginStream->didReceiveResponse(responseURL, streamLength, lastModifiedTime, mimeType, headers);
 }
 
+void NetscapePlugin::streamDidFail(uint64_t streamID, bool wasCancelled)
+{
+    if (NetscapePluginStream* pluginStream = streamFromID(streamID))
+        pluginStream->didFail(wasCancelled);
+}
+
 PluginController* NetscapePlugin::controller()
 {
     return m_pluginController;
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
index 13df561..2f17566 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h
@@ -89,6 +89,7 @@ private:
     virtual void didEvaluateJavaScript(uint64_t requestID, const WebCore::String& requestURLString, const WebCore::String& result);
     virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::KURL& responseURL, uint32_t streamLength, 
                                           uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
+    virtual void streamDidFail(uint64_t streamID, bool wasCancelled);
 
     virtual PluginController* controller();
 
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
index d809153..a1ac75a 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp
@@ -58,9 +58,20 @@ NetscapePluginStream::~NetscapePluginStream()
 
 void NetscapePluginStream::didReceiveResponse(const KURL& responseURL, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers)
 {
+    // Starting the stream could cause the plug-in stream to go away so we keep a reference to it here.
+    RefPtr<NetscapePluginStream> protect(this);
+
     start(responseURL, streamLength, lastModifiedTime, mimeType, headers);
 }
 
+void NetscapePluginStream::didFail(bool wasCancelled)
+{
+    // Stopping the stream could cause the plug-in stream to go away so we keep a reference to it here.
+    RefPtr<NetscapePluginStream> protect(this);
+
+    stop(wasCancelled ? NPRES_USER_BREAK : NPRES_NETWORK_ERR);
+}
+    
 void NetscapePluginStream::sendJavaScriptStream(const String& requestURLString, const String& result)
 {
     // starting the stream or delivering the data to it might cause the plug-in stream to go away, so we keep
@@ -92,6 +103,7 @@ NPError NetscapePluginStream::destroy(NPReason reason)
     if (reason == NPRES_DONE)
         return NPERR_INVALID_PARAM;
 
+    cancel();
     stop(reason);
     return NPERR_NO_ERROR;
 }
@@ -129,7 +141,8 @@ bool NetscapePluginStream::start(const WebCore::String& responseURLString, uint3
 
     NPError error = m_plugin->NPP_NewStream(const_cast<char*>(m_mimeType.data()), &m_npStream, false, &m_transferMode);
     if (error != NPERR_NO_ERROR) {
-        // We failed to start the stream, destroy it.
+        // We failed to start the stream, cancel the load and destroy it.
+        cancel();
         notifyAndDestroyStream(NPRES_NETWORK_ERR);
         return false;
     }
@@ -138,7 +151,8 @@ bool NetscapePluginStream::start(const WebCore::String& responseURLString, uint3
     m_isStarted = true;
 
     if (!isSupportedTransferMode(m_transferMode)) {
-        // Stop the stream.
+        // Cancel the load and stop the stream.
+        cancel();
         stop(NPRES_NETWORK_ERR);
         return false;
     }
@@ -243,6 +257,11 @@ void NetscapePluginStream::stop(NPReason reason)
     notifyAndDestroyStream(reason);
 }
 
+void NetscapePluginStream::cancel()
+{
+    m_plugin->cancelStreamLoad(this);
+}
+
 void NetscapePluginStream::notifyAndDestroyStream(NPReason reason)
 {
     ASSERT(!m_isStarted);
@@ -257,9 +276,6 @@ void NetscapePluginStream::notifyAndDestroyStream(NPReason reason)
 #endif    
     }
 
-    if (reason != NPRES_DONE)
-        m_plugin->cancelStreamLoad(this);
-
     m_plugin->removePluginStream(this);
 }
 
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
index 074355b..d353c19 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapePluginStream.h
@@ -55,6 +55,7 @@ public:
 
     void didReceiveResponse(const WebCore::KURL& responseURL, uint32_t streamLength,
                             uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
+    void didFail(bool wasCancelled);
 
     void sendJavaScriptStream(const WebCore::String& requestURLString, const WebCore::String& result);
 
@@ -67,6 +68,7 @@ private:
                uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers);
     void stop(NPReason);
 
+    void cancel();
     void notifyAndDestroyStream(NPReason);
 
     void deliverData(const char* bytes, int length);
diff --git a/WebKit2/WebProcess/Plugins/Plugin.h b/WebKit2/WebProcess/Plugins/Plugin.h
index bb3e27f..979d8e9 100644
--- a/WebKit2/WebProcess/Plugins/Plugin.h
+++ b/WebKit2/WebProcess/Plugins/Plugin.h
@@ -77,6 +77,9 @@ public:
     virtual void streamDidReceiveResponse(uint64_t streamID, const WebCore::KURL& responseURL, uint32_t streamLength, 
                                           uint32_t lastModifiedTime, const WebCore::String& mimeType, const WebCore::String& headers) = 0;
 
+    // Tells the plug-in that a stream has failed to load, either because of network errors or because the load was cancelled.
+    virtual void streamDidFail(uint64_t streamID, bool wasCancelled) = 0;
+
     // Returns the plug-in controller for this plug-in.
     // FIXME: We could just have the controller be a member variable of Plugin.
     virtual PluginController* controller() = 0;
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index a98e9cb..6fb40f8 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -83,9 +83,9 @@ private:
         : m_pluginView(pluginView)
         , m_streamID(streamID)
         , m_request(request)
+        , m_streamWasCancelled(false)
     {
     }
-
     // NetscapePluginStreamLoaderClient
     virtual void didReceiveResponse(NetscapePlugInStreamLoader*, const ResourceResponse&);
     virtual void didReceiveData(NetscapePlugInStreamLoader*, const char*, int);
@@ -96,6 +96,10 @@ private:
     uint64_t m_streamID;
     const ResourceRequest m_request;
     
+    // True if the stream was explicitly cancelled by calling cancel().
+    // (As opposed to being cancelled by the user hitting the stop button for example.
+    bool m_streamWasCancelled;
+    
     RefPtr<NetscapePlugInStreamLoader> m_loader;
 };
 
@@ -117,6 +121,7 @@ void PluginView::Stream::cancel()
 {
     ASSERT(m_loader);
 
+    m_streamWasCancelled = true;
     m_loader->cancel(m_loader->cancelledError());
     m_loader = 0;
 }
@@ -170,7 +175,15 @@ void PluginView::Stream::didReceiveData(NetscapePlugInStreamLoader*, const char*
 
 void PluginView::Stream::didFail(NetscapePlugInStreamLoader*, const ResourceError& error) 
 {
-    // FIXME: Implement.
+    // 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());
+    m_pluginView->removeStream(this);
 }
 
 void PluginView::Stream::didFinishLoading(NetscapePlugInStreamLoader*)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list