Bug 832032 - Don't create a PluginStreamListener for initial plugin streams before OnStartRequest. r=josh
authorJohn Schoenick <jschoenick@mozilla.com>
Thu, 17 Jan 2013 14:50:25 -0800
changeset 119786 a7115ec2354f986fc44df4a22bad9a264430e0a1
parent 119785 ea8af024e14d05b01b0fcb8e48da0301e9007b22
child 119787 07592e6d5c2328cf8e08225dc7fb34824d9962be
push id21874
push userjschoenick@mozilla.com
push dateThu, 24 Jan 2013 21:42:34 +0000
treeherdermozilla-inbound@a7115ec2354f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs832032
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 832032 - Don't create a PluginStreamListener for initial plugin streams before OnStartRequest. r=josh
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()