Bug 832032 - Don't create a PluginStreamListener for initial plugin streams before OnStartRequest. r=josh, a=bajaj
authorJohn Schoenick <jschoenick@mozilla.com>
Thu, 17 Jan 2013 14:50:25 -0800
changeset 127371 71e945235fd2c4333ac2b0617bd34c6fac93c0dc
parent 127370 5bbf98e5690ae396851da638871e7e2baff9615a
child 127372 c8641ce92c72edd5a17b74cde60c3f0049daef7e
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh, bajaj
bugs832032
milestone20.0a2
Bug 832032 - Don't create a PluginStreamListener for initial plugin streams before OnStartRequest. r=josh, a=bajaj
content/base/src/nsObjectLoadingContent.cpp
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -782,21 +782,19 @@ nsObjectLoadingContent::InstantiatePlugi
     }
 
     // If we have a URI but didn't open a channel yet (eAllowPluginSkipChannel)
     // or we did load with a channel but are re-instantiating, re-open the
     // channel. OpenChannel() performs security checks, and this plugin has
     // already passed content policy in LoadObject.
     if ((mURI && !mChannelLoaded) || (mChannelLoaded && !aIsLoading)) {
       NS_ASSERTION(!mChannel, "should not have an existing channel here");
-      if (MakePluginListener()) {
-        // We intentionally ignore errors here, leaving it up to the plugin to
-        // deal with not having an initial stream.
-        OpenChannel();
-      }
+      // We intentionally ignore errors here, leaving it up to the plugin to
+      // deal with not having an initial stream.
+      OpenChannel();
     }
   }
 
   return NS_OK;
 }
 
 void
 nsObjectLoadingContent::NotifyOwnerDocumentActivityChanged()
@@ -826,22 +824,27 @@ nsObjectLoadingContent::OnStartRequest(n
     // happens when a new load starts before the previous one got here
     return NS_BINDING_ABORTED;
   }
 
   NS_ASSERTION(!mChannelLoaded, "mChannelLoaded set already?");
   // If we already switched to type plugin, this channel can just be passed to
   // the final listener.
   if (mType == eType_Plugin) {
-    if (!mInstanceOwner || !mFinalListener) {
+    if (!mInstanceOwner) {
       // We drop mChannel when stopping plugins, so something is wrong
       NS_NOTREACHED("Opened a channel in plugin mode, but don't have a plugin");
       return NS_BINDING_ABORTED;
     }
-    return mFinalListener->OnStartRequest(aRequest, nullptr);
+    if (MakePluginListener()) {
+      return mFinalListener->OnStartRequest(aRequest, nullptr);
+    } else {
+      NS_NOTREACHED("Failed to create PluginStreamListener, aborting channel");
+      return NS_BINDING_ABORTED;
+    }
   }
 
   // Otherwise we should be state loading, and call LoadObject with the channel
   if (mType != eType_Loading) {
     NS_NOTREACHED("Should be type loading at this point");
     return NS_BINDING_ABORTED;
   }
   NS_ASSERTION(!mFinalListener, "mFinalListener exists already?");
@@ -2001,17 +2004,18 @@ nsObjectLoadingContent::CloseChannel()
     // Null the values before potentially-reentering, and ensure they survive
     // the call
     nsCOMPtr<nsIChannel> channelGrip(mChannel);
     nsCOMPtr<nsIStreamListener> listenerGrip(mFinalListener);
     mChannel = nullptr;
     mFinalListener = nullptr;
     channelGrip->Cancel(NS_BINDING_ABORTED);
     if (listenerGrip) {
-      // mFinalListener is only set by LoadObject after OnStartRequest
+      // mFinalListener is only set by LoadObject after OnStartRequest, or
+      // by OnStartRequest in the case of late-opened plugin streams
       listenerGrip->OnStopRequest(channelGrip, nullptr, NS_BINDING_ABORTED);
     }
   }
   return NS_OK;
 }
 
 nsresult
 nsObjectLoadingContent::OpenChannel()