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

Delta Between Two Patch Sets: lib/commandLine.js

Issue 5288886037118976: Adblock Plus Crawler rewrite (Closed)
Left Patch Set: Created April 24, 2015, 3:38 p.m.
Right Patch Set: Addressed comments Created May 7, 2015, 12:04 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « icon64.png ('k') | lib/crawler.js » ('j') | lib/crawler.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This Source Code is subject to the terms of the Mozilla Public License 2 * This Source Code is subject to the terms of the Mozilla Public License
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
7 /** 7 /**
8 * @module commandLine 8 * @module commandLine
saroyanm 2015/05/04 18:13:43 I think this should be file overview, maybe smth l
Sebastian Noack 2015/05/04 20:39:01 If this is actually a module, then there should be
saroyanm 2015/05/05 09:36:39 fair enough.
9 */ 9 */
10 10
11 Cu.import("resource://gre/modules/Services.jsm"); 11 Cu.import("resource://gre/modules/Services.jsm");
12 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 12 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
13 13
14 let CommandLineHandler = 14 let CommandLineHandler =
15 { 15 {
16 // Starting the entry with "k" makes it have slightly higher priority than def ault command line handlers. 16 // Starting the entry with "k" makes it have slightly higher priority than def ault command line handlers.
17 classDescription: "k-abpcrawler", 17 classDescription: "k-abpcrawler",
18 contractID: "@adblockplus.org/abpcrawler/cmdline;1", 18 contractID: "@adblockplus.org/abpcrawler/cmdline;1",
19 classID: Components.ID("{973636c2-e842-11e4-b02c-1681e6b88ec1}"), 19 classID: Components.ID("{973636c2-e842-11e4-b02c-1681e6b88ec1}"),
20 xpcom_categories: ["command-line-handler"], 20 xpcom_categories: ["command-line-handler"],
21 21
22 init: function() 22 init: function()
23 { 23 {
24 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 24 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
25 registrar.registerFactory(this.classID, this.classDescription, this.contract ID, this); 25 registrar.registerFactory(this.classID, this.classDescription, this.contract ID, this);
26 26
27 let catMan = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryM anager); 27 let catMan = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryM anager);
28 for each (let category in this.xpcom_categories) 28 for (let category of this.xpcom_categories)
saroyanm 2015/05/04 18:13:43 for each in has been deprecated: https://developer
Wladimir Palant 2015/05/07 00:04:59 Done.
29 catMan.addCategoryEntry(category, this.classDescription, this.contractID, false, true); 29 catMan.addCategoryEntry(category, this.classDescription, this.contractID, false, true);
30 30
31 onShutdown.add((function() 31 onShutdown.add((function()
Sebastian Noack 2015/05/07 12:33:04 Nit: I'd rather use an arrow function instead (fun
32 { 32 {
33 for each (let category in this.xpcom_categories) 33 for (let category of this.xpcom_categories)
saroyanm 2015/05/04 18:13:43 Please use For...of instead.
Wladimir Palant 2015/05/07 00:04:59 Done.
34 catMan.deleteCategoryEntry(category, this.classDescription, false); 34 catMan.deleteCategoryEntry(category, this.classDescription, false);
35 35
36 registrar.unregisterFactory(this.classID, this); 36 registrar.unregisterFactory(this.classID, this);
37 }).bind(this)); 37 }).bind(this));
38 }, 38 },
39 39
40 createInstance: function(outer, iid) 40 createInstance: function(outer, iid)
41 { 41 {
42 if (outer) 42 if (outer)
43 throw Cr.NS_ERROR_NO_AGGREGATION; 43 throw Cr.NS_ERROR_NO_AGGREGATION;
44 return this.QueryInterface(iid); 44 return this.QueryInterface(iid);
45 }, 45 },
46 46
47 helpInfo: " -crawler-port Port that ABP Crawler should communicate to\n" , 47 helpInfo: " -crawler-port Port that ABP Crawler should communicate to\n" ,
48 48
49 handle: function(cmdline) 49 handle: function(cmdline)
50 { 50 {
51 let port = cmdline.handleFlagWithParam("crawler-port", false); 51 let port = cmdline.handleFlagWithParam("crawler-port", false);
52 if (port != null) 52 if (port != null)
53 require("main").startup(parseInt(port)); 53 require("main").startup(parseInt(port));
54 }, 54 },
55 55
56 QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler, Ci.nsIFactory ]) 56 QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler, Ci.nsIFactory ])
57 }; 57 };
58 58
59 CommandLineHandler.init(); 59 CommandLineHandler.init();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld