Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/commandLine.js

Issue 5288886037118976: Adblock Plus Crawler rewrite (Closed)
Patch Set: Addressed comments Created May 7, 2015, 12:04 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « icon64.png ('k') | lib/crawler.js » ('j') | lib/crawler.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/commandLine.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/lib/commandLine.js
@@ -0,0 +1,59 @@
+/*
+ * This Source Code is subject to the terms of the Mozilla Public License
+ * version 2.0 (the "License"). You can obtain a copy of the License at
+ * http://mozilla.org/MPL/2.0/.
+ */
+
+/**
+ * @module commandLine
+ */
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+let CommandLineHandler =
+{
+ // Starting the entry with "k" makes it have slightly higher priority than default command line handlers.
+ classDescription: "k-abpcrawler",
+ contractID: "@adblockplus.org/abpcrawler/cmdline;1",
+ classID: Components.ID("{973636c2-e842-11e4-b02c-1681e6b88ec1}"),
+ xpcom_categories: ["command-line-handler"],
+
+ init: function()
+ {
+ let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+ registrar.registerFactory(this.classID, this.classDescription, this.contractID, this);
+
+ let catMan = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
+ for (let category of this.xpcom_categories)
+ catMan.addCategoryEntry(category, this.classDescription, this.contractID, false, true);
+
+ onShutdown.add((function()
Sebastian Noack 2015/05/07 12:33:04 Nit: I'd rather use an arrow function instead (fun
+ {
+ for (let category of this.xpcom_categories)
+ catMan.deleteCategoryEntry(category, this.classDescription, false);
+
+ registrar.unregisterFactory(this.classID, this);
+ }).bind(this));
+ },
+
+ createInstance: function(outer, iid)
+ {
+ if (outer)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return this.QueryInterface(iid);
+ },
+
+ helpInfo: " -crawler-port Port that ABP Crawler should communicate to\n",
+
+ handle: function(cmdline)
+ {
+ let port = cmdline.handleFlagWithParam("crawler-port", false);
+ if (port != null)
+ require("main").startup(parseInt(port));
+ },
+
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler, Ci.nsIFactory])
+};
+
+CommandLineHandler.init();
« no previous file with comments | « icon64.png ('k') | lib/crawler.js » ('j') | lib/crawler.js » ('J')

Powered by Google App Engine
This is Rietveld