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

Delta Between Two Patch Sets: lib/child/bootstrap.js

Issue 29362609: Issue 2879 - Restructure existing process script, split it up into multiple modules (Closed) Base URL: https://hg.adblockplus.org/elemhidehelper
Left Patch Set: Created Nov. 17, 2016, 8:36 a.m.
Right Patch Set: Fixed line length Created Dec. 1, 2016, 9:39 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 | « lib/child/actor.js ('k') | lib/child/main.js » ('j') | no next file with change/comment »
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 "use strict"; 7 "use strict";
Wladimir Palant 2016/11/17 08:42:58 This is very close to lib/child/bootstrap.js we us
saroyanm 2016/11/22 14:58:31 Acknowledged.
8 8
9 (function(messageManager) 9 (function(messageManager)
10 { 10 {
11 const Cc = Components.classes; 11 const Cc = Components.classes;
12 const Ci = Components.interfaces; 12 const Ci = Components.interfaces;
13 const Cr = Components.results; 13 const Cr = Components.results;
14 const Cu = Components.utils; 14 const Cu = Components.utils;
15 15
16 let {Loader, main, unload} = Cu.import("resource://gre/modules/commonjs/toolki t/loader.js", {}); 16 let {Loader, main, unload} = Cu.import(
saroyanm 2016/11/24 17:46:10 Nit: Exceeding 80 chars.
Wladimir Palant 2016/12/01 09:40:49 Done.
17 "resource://gre/modules/commonjs/toolkit/loader.js", {}
18 );
17 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); 19 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
18 20
19 Cu.importGlobalProperties(["atob", "btoa", "File", "URL", "URLSearchParams", 21 Cu.importGlobalProperties(["atob", "btoa", "File", "URL", "URLSearchParams",
20 "TextDecoder", "TextEncoder"]); 22 "TextDecoder", "TextEncoder"]);
21 23
22 let shutdownHandlers = []; 24 let shutdownHandlers = [];
23 let onShutdown = 25 let onShutdown =
24 { 26 {
25 done: false, 27 done: false,
26 add: function(handler) 28 add: function(handler)
(...skipping 17 matching lines...) Expand all
44 46
45 let loader = Loader({ 47 let loader = Loader({
46 paths: { 48 paths: {
47 "": info.addonRoot + "lib/" 49 "": info.addonRoot + "lib/"
48 }, 50 },
49 globals: { 51 globals: {
50 Components, Cc, Ci, Cu, Cr, atob, btoa, File, URL, URLSearchParams, 52 Components, Cc, Ci, Cu, Cr, atob, btoa, File, URL, URLSearchParams,
51 TextDecoder, TextEncoder, onShutdown 53 TextDecoder, TextEncoder, onShutdown
52 }, 54 },
53 modules: { 55 modules: {
54 info, messageManager 56 info, messageManager
saroyanm 2016/11/22 14:58:31 In AdblockPlus we are defining the modules: module
Wladimir Palant 2016/11/24 14:16:29 Why? This short notation is available starting wit
saroyanm 2016/11/24 17:46:10 Oh, I was referring actually to your initial comme
55 }, 57 },
56 id: info.addonID 58 id: info.addonID
57 }); 59 });
58 onShutdown.add(() => unload(loader, "disable")) 60 onShutdown.add(() => unload(loader, "disable"))
59 61
60 main(loader, "child/main"); 62 main(loader, "child/main");
61 } 63 }
62 64
63 function shutdown(message) 65 function shutdown(message)
saroyanm 2016/11/22 14:58:31 message parameter is not being used, probably can
Wladimir Palant 2016/11/24 14:16:29 It sure can be but it is still being passed in so
64 { 66 {
65 if (onShutdown.done) 67 if (onShutdown.done)
66 return; 68 return;
67 69
68 onShutdown.done = true; 70 onShutdown.done = true;
69 for (let i = shutdownHandlers.length - 1; i >= 0; i --) 71 for (let i = shutdownHandlers.length - 1; i >= 0; i --)
70 { 72 {
71 try 73 try
72 { 74 {
73 shutdownHandlers[i](); 75 shutdownHandlers[i]();
74 } 76 }
75 catch (e) 77 catch (e)
76 { 78 {
77 Cu.reportError(e); 79 Cu.reportError(e);
78 } 80 }
79 } 81 }
80 shutdownHandlers = null; 82 shutdownHandlers = null;
81 } 83 }
82 84
83 messageManager.addMessageListener("ElemHideHelper:Shutdown", shutdown); 85 messageManager.addMessageListener("ElemHideHelper:Shutdown", shutdown);
84 onShutdown.add(() => 86 onShutdown.add(() =>
85 { 87 {
86 messageManager.removeMessageListener("ElemHideHelper:Shutdown", shutdown); 88 messageManager.removeMessageListener("ElemHideHelper:Shutdown", shutdown);
87 }); 89 });
88 90
89 init(); 91 init();
90 })(this); 92 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld