Bug 1491560 - Remove the XPCOM registration for nsCommandLine; r=mccr8
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 15 Sep 2018 05:00:49 -0400
changeset 492287 7a4dadc9c3e6198fe0c4d524631353f975df67f1
parent 492286 0834d69f3280f5903e240b8669902a7797380732
child 492288 b8d0ac50695061fb2488c48a79adb5ad20ed973e
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1491560
milestone64.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 1491560 - Remove the XPCOM registration for nsCommandLine; r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D5944
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/tests/unit/test_xpcwn_tamperproof.js
toolkit/components/commandlines/moz.build
toolkit/components/commandlines/nsCommandLine.cpp
toolkit/components/commandlines/nsCommandLine.h
toolkit/components/commandlines/test/unit/test_bug666224.js
toolkit/components/commandlines/test/unit/test_classinfo.js
toolkit/components/commandlines/test/unit_unix/test_bug410156.js
toolkit/components/commandlines/test/unit_win/test_bug410156.js
toolkit/components/remote/nsRemoteService.cpp
toolkit/xre/MacApplicationDelegate.mm
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsNativeAppSupportCocoa.mm
toolkit/xre/nsNativeAppSupportWin.cpp
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -715,16 +715,19 @@ interface nsIXPCComponents_Utils : nsISu
     void blockThreadedExecution(in nsIBlockThreadedExecutionCallback aBlockedCallback);
     void unblockThreadedExecution();
 
     /* Give a directive to the record/replay system. */
     void recordReplayDirective(in long directive);
 
     /* Create a spellchecker object. */
     nsIEditorSpellCheck createSpellChecker();
+
+    /* Create a commandline object. */
+    nsISupports createCommandLine();
 };
 
 /**
 * Interface for the 'Components' object.
 *
 * The first interface contains things that are available to non-chrome XBL code
 * that runs in a scope with an ExpandedPrincipal. The second interface
 * includes members that are only exposed to chrome.
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -37,16 +37,17 @@
 #include "nsIException.h"
 #include "nsIScriptError.h"
 #include "nsISimpleEnumerator.h"
 #include "nsPIDOMWindow.h"
 #include "nsGlobalWindow.h"
 #include "nsScriptError.h"
 #include "GeckoProfiler.h"
 #include "mozilla/EditorSpellCheck.h"
+#include "nsCommandLine.h"
 
 using namespace mozilla;
 using namespace JS;
 using namespace js;
 using namespace xpc;
 using mozilla::dom::Exception;
 
 /***************************************************************************/
@@ -3216,16 +3217,25 @@ nsXPCComponents_Utils::CreateSpellChecke
 {
     NS_ENSURE_ARG_POINTER(aSpellChecker);
     nsCOMPtr<nsIEditorSpellCheck> spellChecker =
         new mozilla::EditorSpellCheck();
     spellChecker.forget(aSpellChecker);
     return NS_OK;
 }
 
+NS_IMETHODIMP
+nsXPCComponents_Utils::CreateCommandLine(nsISupports** aCommandLine)
+{
+    NS_ENSURE_ARG_POINTER(aCommandLine);
+    nsCOMPtr<nsISupports> commandLine = new nsCommandLine();
+    commandLine.forget(aCommandLine);
+    return NS_OK;
+}
+
 /***************************************************************************/
 /***************************************************************************/
 /***************************************************************************/
 
 
 nsXPCComponentsBase::nsXPCComponentsBase(XPCWrappedNativeScope* aScope)
     :   mScope(aScope)
 {
--- a/js/xpconnect/tests/unit/test_xpcwn_tamperproof.js
+++ b/js/xpconnect/tests/unit/test_xpcwn_tamperproof.js
@@ -144,17 +144,17 @@ function test_twice(obj, options) {
 function run_test() {
   let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   test_twice(timer, {
     method: "init",
     constant: "TYPE_ONE_SHOT",
     attribute: "callback"
   });
 
-  let cmdline = Cc["@mozilla.org/toolkit/command-line;1"].createInstance(Ci.nsICommandLine);
+  let cmdline = Cu.createCommandLine();
   test_twice(cmdline, {});
 
   test_twice(Object.getPrototypeOf(cmdline), {
     method: "getArgument",
     constant: "STATE_INITIAL_LAUNCH",
     attribute: "length"
   });
 
--- a/toolkit/components/commandlines/moz.build
+++ b/toolkit/components/commandlines/moz.build
@@ -15,16 +15,20 @@ XPIDL_SOURCES += [
     'nsICommandLine.idl',
     'nsICommandLineHandler.idl',
     'nsICommandLineRunner.idl',
     'nsICommandLineValidator.idl',
 ]
 
 XPIDL_MODULE = 'commandlines'
 
+EXPORTS += [
+    'nsCommandLine.h',
+]
+
 SOURCES += [
     'nsCommandLine.cpp',
 ]
 
 FINAL_LIBRARY = 'xul'
 
 with Files('**'):
     BUG_COMPONENT = ('Toolkit', 'Startup and Profile System')
--- a/toolkit/components/commandlines/nsCommandLine.cpp
+++ b/toolkit/components/commandlines/nsCommandLine.cpp
@@ -1,33 +1,29 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsICommandLineRunner.h"
+#include "nsCommandLine.h"
 
 #include "nsICategoryManager.h"
 #include "nsICommandLineHandler.h"
 #include "nsICommandLineValidator.h"
 #include "nsIConsoleService.h"
 #include "nsIClassInfoImpl.h"
 #include "nsIDOMWindow.h"
 #include "nsIFile.h"
 #include "nsISimpleEnumerator.h"
 #include "mozilla/SimpleEnumerator.h"
 
-#include "nsCOMPtr.h"
-#include "mozilla/ModuleUtils.h"
-#include "nsISupportsImpl.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsNetUtil.h"
 #include "nsIFileProtocolHandler.h"
 #include "nsIURI.h"
 #include "nsUnicharUtils.h"
-#include "nsTArray.h"
 #include "nsTextFormatter.h"
 #include "nsXPCOMCID.h"
 #include "plstr.h"
 #include "mozilla/Attributes.h"
 
 #ifdef MOZ_WIDGET_COCOA
 #include <CoreFoundation/CoreFoundation.h>
 #include "nsILocalFileMac.h"
@@ -42,47 +38,16 @@
 #define DEBUG_COMMANDLINE
 #endif
 
 #define NS_COMMANDLINE_CID \
   { 0x23bcc750, 0xdc20, 0x460b, { 0xb2, 0xd4, 0x74, 0xd8, 0xf5, 0x8d, 0x36, 0x15 } }
 
 using mozilla::SimpleEnumerator;
 
-class nsCommandLine final : public nsICommandLineRunner
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSICOMMANDLINE
-  NS_DECL_NSICOMMANDLINERUNNER
-
-  nsCommandLine();
-
-protected:
-  ~nsCommandLine() = default;
-
-  typedef nsresult (*EnumerateHandlersCallback)(nsICommandLineHandler* aHandler,
-					nsICommandLine* aThis,
-					void *aClosure);
-  typedef nsresult (*EnumerateValidatorsCallback)(nsICommandLineValidator* aValidator,
-					nsICommandLine* aThis,
-					void *aClosure);
-
-  void appendArg(const char* arg);
-  MOZ_MUST_USE nsresult resolveShortcutURL(nsIFile* aFile, nsACString& outURL);
-  nsresult EnumerateHandlers(EnumerateHandlersCallback aCallback, void *aClosure);
-  nsresult EnumerateValidators(EnumerateValidatorsCallback aCallback, void *aClosure);
-
-  nsTArray<nsString>      mArgs;
-  uint32_t                mState;
-  nsCOMPtr<nsIFile>       mWorkingDir;
-  nsCOMPtr<nsIDOMWindow>  mWindowContext;
-  bool                    mPreventDefault;
-};
-
 nsCommandLine::nsCommandLine() :
   mState(STATE_INITIAL_LAUNCH),
   mPreventDefault(false)
 {
 
 }
 
 
@@ -612,30 +577,8 @@ EnumHelp(nsICommandLineHandler* aHandler
 
 NS_IMETHODIMP
 nsCommandLine::GetHelpText(nsACString& aResult)
 {
   EnumerateHandlers(EnumHelp, &aResult);
 
   return NS_OK;
 }
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandLine)
-
-NS_DEFINE_NAMED_CID(NS_COMMANDLINE_CID);
-
-static const mozilla::Module::CIDEntry kCommandLineCIDs[] = {
-  { &kNS_COMMANDLINE_CID, false, nullptr, nsCommandLineConstructor },
-  { nullptr }
-};
-
-static const mozilla::Module::ContractIDEntry kCommandLineContracts[] = {
-  { "@mozilla.org/toolkit/command-line;1", &kNS_COMMANDLINE_CID },
-  { nullptr }
-};
-
-static const mozilla::Module kCommandLineModule = {
-  mozilla::Module::kVersion,
-  kCommandLineCIDs,
-  kCommandLineContracts
-};
-
-NSMODULE_DEFN(CommandLineModule) = &kCommandLineModule;
new file mode 100644
--- /dev/null
+++ b/toolkit/components/commandlines/nsCommandLine.h
@@ -0,0 +1,50 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef nsCommandLine_h
+#define nsCommandLine_h
+
+#include "nsICommandLineRunner.h"
+#include "nsCOMPtr.h"
+#include "nsISupportsImpl.h"
+#include "nsTArray.h"
+
+class nsICommandLineHandler;
+class nsICommandLineValidator;
+class nsIDOMWindow;
+class nsIFile;
+
+class nsCommandLine final : public nsICommandLineRunner
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSICOMMANDLINE
+  NS_DECL_NSICOMMANDLINERUNNER
+
+  nsCommandLine();
+
+protected:
+  ~nsCommandLine() = default;
+
+  typedef nsresult (*EnumerateHandlersCallback)(nsICommandLineHandler* aHandler,
+					nsICommandLine* aThis,
+					void *aClosure);
+  typedef nsresult (*EnumerateValidatorsCallback)(nsICommandLineValidator* aValidator,
+					nsICommandLine* aThis,
+					void *aClosure);
+
+  void appendArg(const char* arg);
+  MOZ_MUST_USE nsresult resolveShortcutURL(nsIFile* aFile, nsACString& outURL);
+  nsresult EnumerateHandlers(EnumerateHandlersCallback aCallback, void *aClosure);
+  nsresult EnumerateValidators(EnumerateValidatorsCallback aCallback, void *aClosure);
+
+  nsTArray<nsString>      mArgs;
+  uint32_t                mState;
+  nsCOMPtr<nsIFile>       mWorkingDir;
+  nsCOMPtr<nsIDOMWindow>  mWindowContext;
+  bool                    mPreventDefault;
+};
+
+#endif
+
--- a/toolkit/components/commandlines/test/unit/test_bug666224.js
+++ b/toolkit/components/commandlines/test/unit/test_bug666224.js
@@ -1,6 +1,6 @@
 function run_test() {
-    var cmdLine = Cc["@mozilla.org/toolkit/command-line;1"].createInstance(Ci.nsICommandLine);
+    var cmdLine = Cu.createCommandLine();
     try {
         cmdLine.getArgument(cmdLine.length);
     } catch (e) {}
 }
--- a/toolkit/components/commandlines/test/unit/test_classinfo.js
+++ b/toolkit/components/commandlines/test/unit/test_classinfo.js
@@ -1,9 +1,8 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function run_test() {
-  var clClass = Cc["@mozilla.org/toolkit/command-line;1"];
-  var commandLine = clClass.createInstance();
+  var commandLine = Cu.createCommandLine();
   Assert.ok("length" in commandLine);
 }
--- a/toolkit/components/commandlines/test/unit_unix/test_bug410156.js
+++ b/toolkit/components/commandlines/test/unit_unix/test_bug410156.js
@@ -1,11 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function run_test() {
-  var clClass = Cc["@mozilla.org/toolkit/command-line;1"];
-  var commandLine = clClass.createInstance();
+  var commandLine = Cu.createCommandLine();
   var urlFile = do_get_file("../unit/data/test_bug410156.desktop");
   var uri = commandLine.resolveURI(urlFile.path);
   Assert.equal(uri.spec, "http://www.bug410156.com/");
 }
--- a/toolkit/components/commandlines/test/unit_win/test_bug410156.js
+++ b/toolkit/components/commandlines/test/unit_win/test_bug410156.js
@@ -1,11 +1,10 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 function run_test() {
-  var clClass = Cc["@mozilla.org/toolkit/command-line;1"];
-  var commandLine = clClass.createInstance();
+  var commandLine = Cu.createCommandLine();
   var urlFile = do_get_file("../unit/data/test_bug410156.url");
   var uri = commandLine.resolveURI(urlFile.path);
   Assert.equal(uri.spec, "http://www.bug410156.com/");
 }
--- a/toolkit/components/remote/nsRemoteService.cpp
+++ b/toolkit/components/remote/nsRemoteService.cpp
@@ -18,17 +18,17 @@
 #include "nsIServiceManager.h"
 #include "nsIAppShellService.h"
 #include "nsAppShellCID.h"
 #include "nsInterfaceHashtable.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsIWeakReference.h"
 #include "nsGTKToolkit.h"
 #include "nsICommandLineRunner.h"
-#include "nsICommandLine.h"
+#include "nsCommandLine.h"
 #include "nsString.h"
 #include "nsIFile.h"
 
 NS_IMPL_ISUPPORTS(nsRemoteService,
                   nsIRemoteService,
                   nsIObserver)
 
 NS_IMETHODIMP
@@ -150,35 +150,30 @@ FindExtensionParameterInCommand(const ch
   *aValue = nsDependentCSubstring(idStart, idEnd);
   return true;
 }
 
 const char*
 nsRemoteService::HandleCommandLine(const char* aBuffer, nsIDOMWindow* aWindow,
                                    uint32_t aTimestamp)
 {
-  nsresult rv;
-
-  nsCOMPtr<nsICommandLineRunner> cmdline
-    (do_CreateInstance("@mozilla.org/toolkit/command-line;1", &rv));
-  if (NS_FAILED(rv))
-    return "509 internal error";
+  nsCOMPtr<nsICommandLineRunner> cmdline(new nsCommandLine());
 
   // the commandline property is constructed as an array of int32_t
   // followed by a series of null-terminated strings:
   //
   // [argc][offsetargv0][offsetargv1...]<workingdir>\0<argv[0]>\0argv[1]...\0
   // (offset is from the beginning of the buffer)
 
   int32_t argc = TO_LITTLE_ENDIAN32(*reinterpret_cast<const int32_t*>(aBuffer));
   const char *wd   = aBuffer + ((argc + 1) * sizeof(int32_t));
 
   nsCOMPtr<nsIFile> lf;
-  rv = NS_NewNativeLocalFile(nsDependentCString(wd), true,
-                             getter_AddRefs(lf));
+  nsresult rv = NS_NewNativeLocalFile(nsDependentCString(wd), true,
+                                      getter_AddRefs(lf));
   if (NS_FAILED(rv))
     return "509 internal error";
 
   nsAutoCString desktopStartupID;
 
   const char **argv = (const char**) malloc(sizeof(char*) * argc);
   if (!argv) return "509 internal error";
 
--- a/toolkit/xre/MacApplicationDelegate.mm
+++ b/toolkit/xre/MacApplicationDelegate.mm
@@ -21,22 +21,23 @@
 #include "nsIServiceManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIAppStartup.h"
 #include "nsIObserverService.h"
 #include "nsISupportsPrimitives.h"
 #include "nsObjCExceptions.h"
 #include "nsIFile.h"
 #include "nsDirectoryServiceDefs.h"
-#include "nsICommandLineRunner.h"
+#include "nsCommandLine.h"
 #include "nsIMacDockSupport.h"
 #include "nsIStandaloneNativeMenu.h"
 #include "nsILocalFileMac.h"
 #include "nsString.h"
 #include "nsCommandLineServiceMac.h"
+#include "nsCommandLine.h"
 
 class AutoAutoreleasePool {
 public:
   AutoAutoreleasePool()
   {
     mLocalPool = [[NSAutoreleasePool alloc] init];
   }
   ~AutoAutoreleasePool()
@@ -202,21 +203,17 @@ ProcessPendingGetURLAppleEvents()
   if (CommandLineServiceMac::AddURLToCurrentCommandLine([urlString UTF8String]))
     return YES;
 
   nsCOMPtr<nsILocalFileMac> inFile;
   nsresult rv = NS_NewLocalFileWithCFURL((CFURLRef)url, true, getter_AddRefs(inFile));
   if (NS_FAILED(rv))
     return NO;
 
-  nsCOMPtr<nsICommandLineRunner> cmdLine(do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
-  if (!cmdLine) {
-    NS_ERROR("Couldn't create command line!");
-    return NO;
-  }
+  nsCOMPtr<nsICommandLineRunner> cmdLine(new nsCommandLinew());
 
   nsCString filePath;
   rv = inFile->GetNativePath(filePath);
   if (NS_FAILED(rv))
     return NO;
 
   nsCOMPtr<nsIFile> workingDir;
   rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir));
@@ -357,21 +354,17 @@ ProcessPendingGetURLAppleEvents()
                         range:NSMakeRange(0, [schemeString length])] == NSOrderedSame) {
       return;
     }
 
     // Add the URL to any command line we're currently setting up.
     if (CommandLineServiceMac::AddURLToCurrentCommandLine([urlString UTF8String]))
       return;
 
-    nsCOMPtr<nsICommandLineRunner> cmdLine(do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
-    if (!cmdLine) {
-      NS_ERROR("Couldn't create command line!");
-      return;
-    }
+    nsCOMPtr<nsICommandLineRunner> cmdLine(new nsCommandLine());
     nsCOMPtr<nsIFile> workingDir;
     nsresult rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir));
     if (NS_FAILED(rv))
       return;
     const char *argv[3] = {nullptr, "-url", [urlString UTF8String]};
     rv = cmdLine->Init(3, argv, workingDir, nsICommandLine::STATE_REMOTE_EXPLICIT);
     if (NS_FAILED(rv))
       return;
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -54,17 +54,17 @@
 #include "prtime.h"
 
 #include "nsIAppShellService.h"
 #include "nsIAppStartup.h"
 #include "nsIAppStartupNotifier.h"
 #include "nsIMutableArray.h"
 #include "nsICategoryManager.h"
 #include "nsIChromeRegistry.h"
-#include "nsICommandLineRunner.h"
+#include "nsCommandLine.h"
 #include "nsIComponentManager.h"
 #include "nsIComponentRegistrar.h"
 #include "nsIConsoleService.h"
 #include "nsIContentHandler.h"
 #include "nsIDialogParamBlock.h"
 #include "nsIDOMWindow.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsIIOService.h"
@@ -1590,20 +1590,17 @@ static void DumpArbitraryHelp()
   nsresult rv;
 
   ScopedLogging log;
 
   {
     ScopedXPCOMStartup xpcom;
     xpcom.Initialize();
 
-    nsCOMPtr<nsICommandLineRunner> cmdline
-      (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
-    if (!cmdline)
-      return;
+    nsCOMPtr<nsICommandLineRunner> cmdline(new nsCommandLine());
 
     nsCString text;
     rv = cmdline->GetHelpText(text);
     if (NS_SUCCEEDED(rv))
       printf("%s", text.get());
   }
 }
 
@@ -4668,18 +4665,17 @@ XREMain::XRE_mainRun()
 
   nsCOMPtr<nsICommandLineRunner> cmdLine;
 
   nsCOMPtr<nsIFile> workingDir;
   rv = NS_GetSpecialDirectory(NS_OS_CURRENT_WORKING_DIR, getter_AddRefs(workingDir));
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
   if (!mShuttingDown) {
-    cmdLine = do_CreateInstance("@mozilla.org/toolkit/command-line;1");
-    NS_ENSURE_TRUE(cmdLine, NS_ERROR_FAILURE);
+    cmdLine = new nsCommandLine();
 
     rv = cmdLine->Init(gArgc, gArgv, workingDir,
                        nsICommandLine::STATE_INITIAL_LAUNCH);
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
     /* Special-case services that need early access to the command
         line. */
     nsCOMPtr<nsIObserverService> obsService =
@@ -4735,18 +4731,17 @@ XREMain::XRE_mainRun()
     // Clear the environment variable so it won't be inherited by
     // child processes and confuse things.
     g_unsetenv ("DESKTOP_STARTUP_ID");
 #endif
 
 #ifdef XP_MACOSX
     // we re-initialize the command-line service and do appleevents munging
     // after we are sure that we're not restarting
-    cmdLine = do_CreateInstance("@mozilla.org/toolkit/command-line;1");
-    NS_ENSURE_TRUE(cmdLine, NS_ERROR_FAILURE);
+    cmdLine = new nsCommandLine();
 
     CommandLineServiceMac::SetupMacCommandLine(gArgc, gArgv, false);
 
     rv = cmdLine->Init(gArgc, gArgv,
                         workingDir, nsICommandLine::STATE_INITIAL_LAUNCH);
     NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 #endif
 
--- a/toolkit/xre/nsNativeAppSupportCocoa.mm
+++ b/toolkit/xre/nsNativeAppSupportCocoa.mm
@@ -10,17 +10,17 @@
 
 #include "nsCOMPtr.h"
 #include "nsCocoaFeatures.h"
 #include "nsNativeAppSupportBase.h"
 
 #include "nsIAppShellService.h"
 #include "nsIAppStartup.h"
 #include "nsIBaseWindow.h"
-#include "nsICommandLineRunner.h"
+#include "nsCommandLine.h"
 #include "mozIDOMWindow.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIObserver.h"
 #include "nsIServiceManager.h"
 #include "nsIWebNavigation.h"
 #include "nsIWidget.h"
@@ -162,19 +162,17 @@ nsNativeAppSupportCocoa::ReOpen()
         }
       }
     } // end if have non miniaturized
 
     if (!haveOpenWindows && !done) {
       char* argv[] = { nullptr };
 
       // use an empty command line to make the right kind(s) of window open
-      nsCOMPtr<nsICommandLineRunner> cmdLine
-        (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
-      NS_ENSURE_TRUE(cmdLine, NS_ERROR_FAILURE);
+      nsCOMPtr<nsICommandLineRunner> cmdLine(new nsCommandLine());
 
       nsresult rv;
       rv = cmdLine->Init(0, argv, nullptr,
                          nsICommandLine::STATE_REMOTE_EXPLICIT);
       NS_ENSURE_SUCCESS(rv, rv);
 
       return cmdLine->Run();
     }
--- a/toolkit/xre/nsNativeAppSupportWin.cpp
+++ b/toolkit/xre/nsNativeAppSupportWin.cpp
@@ -5,17 +5,17 @@
 
 #include "nsNativeAppSupportBase.h"
 #include "nsNativeAppSupportWin.h"
 #include "nsAppRunner.h"
 #include "nsContentUtils.h"
 #include "nsXULAppAPI.h"
 #include "nsString.h"
 #include "nsIBrowserDOMWindow.h"
-#include "nsICommandLineRunner.h"
+#include "nsCommandLine.h"
 #include "nsCOMPtr.h"
 #include "nsIComponentManager.h"
 #include "nsIServiceManager.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIWindowWatcher.h"
 #include "nsPIDOMWindow.h"
@@ -1231,22 +1231,17 @@ nsNativeAppSupportWin::HandleCommandLine
     char **argv = 0;
     // Flags, etc.
     int init = 1;
     int between, quoted, bSlashCount;
     int argc;
     const char *p;
     nsAutoCString arg;
 
-    nsCOMPtr<nsICommandLineRunner> cmdLine
-        (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
-    if (!cmdLine) {
-        NS_ERROR("Couldn't create command line!");
-        return;
-    }
+    nsCOMPtr<nsICommandLineRunner> cmdLine(new nsCommandLine());
 
     // Parse command line args according to MS spec
     // (see "Parsing C++ Command-Line Arguments" at
     // http://msdn.microsoft.com/library/devprods/vs6/visualc/vclang/_pluslang_parsing_c.2b2b_.command.2d.line_arguments.htm).
     // We loop if we've not finished the second pass through.
     while ( 1 ) {
         // Initialize if required.
         if ( init ) {
@@ -1475,17 +1470,15 @@ nsNativeAppSupportWin::OpenBrowserWindow
         }
 
         NS_ERROR("failed to hand off external URL to extant window");
     } while ( false );
 
     // open a new window if caller requested it or if anything above failed
 
     char* argv[] = { 0 };
-    nsCOMPtr<nsICommandLineRunner> cmdLine
-        (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
-    NS_ENSURE_TRUE(cmdLine, NS_ERROR_FAILURE);
+    nsCOMPtr<nsICommandLineRunner> cmdLine(new nsCommandLine());
 
     rv = cmdLine->Init(0, argv, nullptr, nsICommandLine::STATE_REMOTE_EXPLICIT);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return cmdLine->Run();
 }