Bug 1352572 - Remove nsPluginHost::PostURL(isFile) parameter; r?bsmedberg draft
authorLie Ryan <lie.1296@gmail.com>
Wed, 12 Apr 2017 03:39:14 +0000
changeset 561407 9aced235a8077ff46f200fe80dc39609dcefd697
parent 561406 6e64d2bde954babc88eb257aab24d22a988c6440
child 561408 335208d05091ca820e5298c6775a8aeb29bdba18
push id53723
push userbmo:lie.1296@gmail.com
push dateWed, 12 Apr 2017 16:27:44 +0000
reviewersbsmedberg
bugs1352572
milestone55.0a1
Bug 1352572 - Remove nsPluginHost::PostURL(isFile) parameter; r?bsmedberg MozReview-Commit-ID: HvuEv87ND7G
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginHost.h
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -427,18 +427,17 @@ MakeNewNPAPIStreamInternal(NPP npp, cons
     {
       if (NS_FAILED(pluginHost->GetURL(inst, relativeURL, target, listener,
                                        nullptr, nullptr, false)))
         return NPERR_GENERIC_ERROR;
       break;
     }
   case eNPPStreamTypeInternal_Post:
     {
-      NPBool file = false;
-      if (NS_FAILED(pluginHost->PostURL(inst, relativeURL, len, buf, file,
+      if (NS_FAILED(pluginHost->PostURL(inst, relativeURL, len, buf,
                                         target, listener, nullptr, nullptr,
                                         false, 0, nullptr)))
         return NPERR_GENERIC_ERROR;
       break;
     }
   default:
     NS_ERROR("how'd I get here");
   }
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -504,17 +504,16 @@ nsresult nsPluginHost::GetURLWithHeaders
   }
   return rv;
 }
 
 nsresult nsPluginHost::PostURL(nsISupports* pluginInst,
                                const char* url,
                                uint32_t postDataLen,
                                const char* postData,
-                               bool isFile,
                                const char* target,
                                nsNPAPIPluginStreamListener* streamListener,
                                const char* altHost,
                                const char* referrer,
                                bool forceJSEnabled,
                                uint32_t postHeadersLength,
                                const char* postHeaders)
 {
@@ -524,55 +523,34 @@ nsresult nsPluginHost::PostURL(nsISuppor
   // by a null target) if we also have a nsNPAPIPluginStreamListener
   // to talk to also
   if (!target && !streamListener)
     return NS_ERROR_ILLEGAL_VALUE;
 
   nsNPAPIPluginInstance* instance = static_cast<nsNPAPIPluginInstance*>(pluginInst);
 
   nsCOMPtr<nsIInputStream> postStream;
-  if (isFile) {
-    nsCOMPtr<nsIFile> file;
-    rv = CreateTempFileToPost(postData, getter_AddRefs(file));
-    if (NS_FAILED(rv))
-      return rv;
-
-    nsCOMPtr<nsIInputStream> fileStream;
-    rv = NS_NewLocalFileInputStream(getter_AddRefs(fileStream),
-                                    file,
-                                    PR_RDONLY,
-                                    0600,
-                                    nsIFileInputStream::DELETE_ON_CLOSE |
-                                    nsIFileInputStream::CLOSE_ON_EOF);
-    if (NS_FAILED(rv))
-      return rv;
-
-    rv = NS_NewBufferedInputStream(getter_AddRefs(postStream), fileStream, 8192);
-    if (NS_FAILED(rv))
-      return rv;
-  } else {
-    char *dataToPost;
-    uint32_t newDataToPostLen;
-    ParsePostBufferToFixHeaders(postData, postDataLen, &dataToPost, &newDataToPostLen);
-    if (!dataToPost)
-      return NS_ERROR_UNEXPECTED;
-
-    nsCOMPtr<nsIStringInputStream> sis = do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
-    if (!sis) {
-      free(dataToPost);
-      return rv;
-    }
-
-    // data allocated by ParsePostBufferToFixHeaders() is managed and
-    // freed by the string stream.
-    postDataLen = newDataToPostLen;
-    sis->AdoptData(dataToPost, postDataLen);
-    postStream = sis;
+  char *dataToPost;
+  uint32_t newDataToPostLen;
+  ParsePostBufferToFixHeaders(postData, postDataLen, &dataToPost, &newDataToPostLen);
+  if (!dataToPost)
+    return NS_ERROR_UNEXPECTED;
+
+  nsCOMPtr<nsIStringInputStream> sis = do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
+  if (!sis) {
+    free(dataToPost);
+    return rv;
   }
 
+  // data allocated by ParsePostBufferToFixHeaders() is managed and
+  // freed by the string stream.
+  postDataLen = newDataToPostLen;
+  sis->AdoptData(dataToPost, postDataLen);
+  postStream = sis;
+
   if (target) {
     RefPtr<nsPluginInstanceOwner> owner = instance->GetOwner();
     if (owner) {
       rv = owner->GetURL(url, target, postStream,
                          (void*)postHeaders, postHeadersLength, true);
     }
   }
 
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -125,17 +125,16 @@ public:
                   nsNPAPIPluginStreamListener* streamListener,
                   const char* altHost,
                   const char* referrer,
                   bool forceJSEnabled);
   nsresult PostURL(nsISupports* pluginInst,
                    const char* url,
                    uint32_t postDataLen,
                    const char* postData,
-                   bool isFile,
                    const char* target,
                    nsNPAPIPluginStreamListener* streamListener,
                    const char* altHost,
                    const char* referrer,
                    bool forceJSEnabled,
                    uint32_t postHeadersLength,
                    const char* postHeaders);