Bug 745241: Clean up some plugin stream functions. r=bsmedberg
authorJosh Aas <joshmoz@gmail.com>
Sun, 15 Apr 2012 17:34:01 -0400
changeset 95036 3b35598ce292c9cfc0d6b27389198a43ad3d4bfc
parent 95035 7aa6a96404c08bc6272de85a243f0c9aa5b694a0
child 95037 b69c5c0bb7274ebf6f722873a6f5e2eb64ed3a7b
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs745241
milestone14.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 745241: Clean up some plugin stream functions. r=bsmedberg
content/base/src/nsObjectLoadingContent.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginHost.h
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -672,22 +672,24 @@ nsObjectLoadingContent::InstantiatePlugi
   nsCOMPtr<nsIPluginDocument> pDoc(do_QueryInterface(doc));
   bool fullPageMode = false;
   if (pDoc) {
     pDoc->GetWillHandleInstantiation(&fullPageMode);
   }
 
   if (fullPageMode) {
     nsCOMPtr<nsIStreamListener> stream;
-    rv = pluginHost->InstantiateFullPagePlugin(aMimeType, aURI, this, getter_AddRefs(mInstanceOwner), getter_AddRefs(stream));
+    rv = pluginHost->InstantiateFullPagePluginInstance(aMimeType, aURI, this,
+                                                       getter_AddRefs(mInstanceOwner), getter_AddRefs(stream));
     if (NS_SUCCEEDED(rv)) {
       pDoc->SetStreamListener(stream);
     }
   } else {
-    rv = pluginHost->InstantiateEmbeddedPlugin(aMimeType, aURI, this, getter_AddRefs(mInstanceOwner));
+    rv = pluginHost->InstantiateEmbeddedPluginInstance(aMimeType, aURI, this,
+                                                       getter_AddRefs(mInstanceOwner));
   }
 
   if (appShell) {
     appShell->ResumeNative();
   }
 
   if (NS_FAILED(rv)) {
     return rv;
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -939,19 +939,19 @@ nsresult nsPluginHost::CreateListenerFor
 
   // Note that we're not setting up a plugin instance here; the stream
   // listener's OnStartRequest will handle doing that.
 
   return NewEmbeddedPluginStreamListener(uri, aContent, nsnull, aListener);
 }
 
 nsresult
-nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
-                                        nsObjectLoadingContent *aContent,
-                                        nsPluginInstanceOwner** aOwner)
+nsPluginHost::InstantiateEmbeddedPluginInstance(const char *aMimeType, nsIURI* aURL,
+                                                nsObjectLoadingContent *aContent,
+                                                nsPluginInstanceOwner** aOwner)
 {
   NS_ENSURE_ARG_POINTER(aOwner);
 
 #ifdef PLUGIN_LOGGING
   nsCAutoString urlSpec;
   if (aURL)
     aURL->GetAsciiSpec(urlSpec);
 
@@ -1094,21 +1094,21 @@ nsPluginHost::InstantiateEmbeddedPlugin(
         aMimeType, rv, urlSpec2.get()));
 
   PR_LogFlush();
 #endif
 
   return NS_OK;
 }
 
-nsresult nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
-                                                 nsIURI* aURI,
-                                                 nsObjectLoadingContent *aContent,
-                                                 nsPluginInstanceOwner **aOwner,
-                                                 nsIStreamListener **aStreamListener)
+nsresult nsPluginHost::InstantiateFullPagePluginInstance(const char *aMimeType,
+                                                         nsIURI* aURI,
+                                                         nsObjectLoadingContent *aContent,
+                                                         nsPluginInstanceOwner **aOwner,
+                                                         nsIStreamListener **aStreamListener)
 {
 #ifdef PLUGIN_LOGGING
   nsCAutoString urlSpec;
   aURI->GetSpec(urlSpec);
   PLUGIN_LOG(PLUGIN_LOG_NORMAL,
   ("nsPluginHost::InstantiateFullPagePlugin Begin mime=%s, url=%s\n",
   aMimeType, urlSpec.get()));
 #endif
@@ -1140,17 +1140,17 @@ nsresult nsPluginHost::InstantiateFullPa
   if (!win) {
     return NS_ERROR_FAILURE;
   }
 
   // Set up any widget that might be required.
   instanceOwner->CreateWidget();
   instanceOwner->CallSetWindow();
 
-  rv = NewFullPagePluginStream(aURI, instance.get(), aStreamListener);
+  rv = NewFullPagePluginStreamListener(aURI, instance.get(), aStreamListener);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // Call SetWindow again in case something changed.
   instanceOwner->CallSetWindow();
 
   instanceOwner.forget(aOwner);
@@ -3241,43 +3241,38 @@ nsPluginHost::StopPluginInstance(nsNPAPI
   return NS_OK;
 }
 
 nsresult nsPluginHost::NewEmbeddedPluginStreamListener(nsIURI* aURL,
                                                        nsObjectLoadingContent *aContent,
                                                        nsNPAPIPluginInstance* aInstance,
                                                        nsIStreamListener** aListener)
 {
-  if (!aURL)
-    return NS_OK;
+  NS_ENSURE_ARG_POINTER(aURL);
 
   nsRefPtr<nsPluginStreamListenerPeer> listener = new nsPluginStreamListenerPeer();
-  if (!listener)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  nsresult rv;
-
-  // if we have an instance, everything has been set up
+
+  // If we have an instance, everything has been set up
   // if we only have an owner, then we need to pass it in
   // so the listener can set up the instance later after
-  // we've determined the mimetype of the stream
-  if (aInstance)
+  // we've determined the mimetype of the stream.
+  nsresult rv = NS_ERROR_ILLEGAL_VALUE;
+  if (aInstance) {
     rv = listener->InitializeEmbedded(aURL, aInstance, nsnull);
-  else if (aContent)
+  } else if (aContent) {
     rv = listener->InitializeEmbedded(aURL, nsnull, aContent);
-  else
-    rv = NS_ERROR_ILLEGAL_VALUE;
-
-  if (NS_SUCCEEDED(rv))
+  }
+
+  if (NS_SUCCEEDED(rv)) {
     NS_ADDREF(*aListener = listener);
+  }
 
   return rv;
 }
 
-// Called by InstantiateEmbeddedPlugin()
 nsresult nsPluginHost::NewEmbeddedPluginStream(nsIURI* aURL,
                                                nsObjectLoadingContent *aContent,
                                                nsNPAPIPluginInstance* aInstance)
 {
   nsCOMPtr<nsIStreamListener> listener;
   nsresult rv = NewEmbeddedPluginStreamListener(aURL, aContent, aInstance,
                                                 getter_AddRefs(listener));
   if (NS_SUCCEEDED(rv)) {
@@ -3303,27 +3298,23 @@ nsresult nsPluginHost::NewEmbeddedPlugin
       if (NS_SUCCEEDED(rv))
         return NS_OK;
     }
   }
 
   return rv;
 }
 
-// Called by InstantiateFullPagePlugin()
-nsresult nsPluginHost::NewFullPagePluginStream(nsIURI* aURI,
-                                               nsNPAPIPluginInstance *aInstance,
-                                               nsIStreamListener **aStreamListener)
+nsresult nsPluginHost::NewFullPagePluginStreamListener(nsIURI* aURI,
+                                                       nsNPAPIPluginInstance *aInstance,
+                                                       nsIStreamListener **aStreamListener)
 {
-  NS_ASSERTION(aStreamListener, "Stream listener out param cannot be null");
+  NS_ENSURE_ARG_POINTER(aStreamListener);
 
   nsRefPtr<nsPluginStreamListenerPeer> listener = new nsPluginStreamListenerPeer();
-  if (!listener)
-    return NS_ERROR_OUT_OF_MEMORY;
-
   nsresult rv = listener->InitializeFullPage(aURI, aInstance);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   listener.forget(aStreamListener);
 
   return NS_OK;
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -213,25 +213,25 @@ public:
 
   void DestroyRunningInstances(nsISupportsArray* aReloadDocs, nsPluginTag* aPluginTag);
 
   // Return the tag for |aLibrary| if found, nsnull if not.
   nsPluginTag* FindTagForLibrary(PRLibrary* aLibrary);
 
   // The last argument should be false if we already have an in-flight stream
   // and don't need to set up a new stream.
-  nsresult InstantiateEmbeddedPlugin(const char *aMimeType, nsIURI* aURL,
-                                     nsObjectLoadingContent *aContent,
-                                     nsPluginInstanceOwner** aOwner);
+  nsresult InstantiateEmbeddedPluginInstance(const char *aMimeType, nsIURI* aURL,
+                                             nsObjectLoadingContent *aContent,
+                                             nsPluginInstanceOwner** aOwner);
 
-  nsresult InstantiateFullPagePlugin(const char *aMimeType,
-                                     nsIURI* aURI,
-                                     nsObjectLoadingContent *aContent,
-                                     nsPluginInstanceOwner **aOwner,
-                                     nsIStreamListener **aStreamListener);
+  nsresult InstantiateFullPagePluginInstance(const char *aMimeType,
+                                             nsIURI* aURI,
+                                             nsObjectLoadingContent *aContent,
+                                             nsPluginInstanceOwner **aOwner,
+                                             nsIStreamListener **aStreamListener);
 
   // Does not accept NULL and should never fail.
   nsPluginTag* TagForPlugin(nsNPAPIPlugin* aPlugin);
 
   nsresult GetPlugin(const char *aMimeType, nsNPAPIPlugin** aPlugin);
 
 private:
   nsresult
@@ -241,19 +241,19 @@ private:
   NewEmbeddedPluginStreamListener(nsIURI* aURL, nsObjectLoadingContent *aContent,
                                   nsNPAPIPluginInstance* aInstance,
                                   nsIStreamListener** aListener);
 
   nsresult
   NewEmbeddedPluginStream(nsIURI* aURL, nsObjectLoadingContent *aContent, nsNPAPIPluginInstance* aInstance);
 
   nsresult
-  NewFullPagePluginStream(nsIURI* aURI,
-                          nsNPAPIPluginInstance *aInstance,
-                          nsIStreamListener **aStreamListener);
+  NewFullPagePluginStreamListener(nsIURI* aURI,
+                                  nsNPAPIPluginInstance *aInstance,
+                                  nsIStreamListener **aStreamListener);
 
   // Return an nsPluginTag for this type, if any.  If aCheckEnabled is
   // true, only enabled plugins will be returned.
   nsPluginTag*
   FindPluginForType(const char* aMimeType, bool aCheckEnabled);
 
   nsPluginTag*
   FindPluginEnabledForExtension(const char* aExtension, const char* &aMimeType);