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

Side by Side Diff: messageResponder.js

Issue 29552642: Issue 5750 - Always require subscriptionInit, avoid "critical dependency" (Closed)
Patch Set: Created Sept. 22, 2017, 12:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 SpecialSubscription 42 SpecialSubscription
43 } = require("subscriptionClasses"); 43 } = require("subscriptionClasses");
44 44
45 port.on("types.get", (message, sender) => 45 port.on("types.get", (message, sender) =>
46 { 46 {
47 let filterTypes = Array.from(require("requestBlocker").filterTypes); 47 let filterTypes = Array.from(require("requestBlocker").filterTypes);
48 filterTypes.push(...filterTypes.splice(filterTypes.indexOf("OTHER"), 1)); 48 filterTypes.push(...filterTypes.splice(filterTypes.indexOf("OTHER"), 1));
49 return filterTypes; 49 return filterTypes;
50 }); 50 });
51 51
52 // Some modules doesn't exist on Firefox. Moreover,
53 // require() throws an exception on Firefox in that case.
54 // However, try/catch causes the whole function to to be
55 // deoptimized on V8. So we wrap it into another function.
56 function tryRequire(module)
57 {
58 try
59 {
60 return require(module);
61 }
62 catch (e)
63 {
64 return null;
65 }
66 }
67
68 function convertObject(keys, obj) 52 function convertObject(keys, obj)
69 { 53 {
70 let result = {}; 54 let result = {};
71 for (let key of keys) 55 for (let key of keys)
72 { 56 {
73 if (key in obj) 57 if (key in obj)
74 result[key] = obj[key]; 58 result[key] = obj[key];
75 } 59 }
76 return result; 60 return result;
77 } 61 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 listenerFilters = Object.create(null); 143 listenerFilters = Object.create(null);
160 changeListeners.set(page, listenerFilters); 144 changeListeners.set(page, listenerFilters);
161 } 145 }
162 return listenerFilters; 146 return listenerFilters;
163 } 147 }
164 148
165 port.on("app.get", (message, sender) => 149 port.on("app.get", (message, sender) =>
166 { 150 {
167 if (message.what == "issues") 151 if (message.what == "issues")
168 { 152 {
169 let subscriptionInit = tryRequire("subscriptionInit"); 153 let subscriptionInit = require("subscriptionInit");
170 let result = subscriptionInit ? subscriptionInit.reinitialized : false; 154 let result = subscriptionInit ? subscriptionInit.reinitialized : false;
171 return {filterlistsReinitialized: result}; 155 return {filterlistsReinitialized: result};
172 } 156 }
173 157
174 if (message.what == "doclink") 158 if (message.what == "doclink")
175 return Utils.getDocLink(message.link); 159 return Utils.getDocLink(message.link);
176 160
177 if (message.what == "localeInfo") 161 if (message.what == "localeInfo")
178 { 162 {
179 let bidiDir; 163 let bidiDir;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (message.url) 425 if (message.url)
442 subscriptions = [Subscription.fromURL(message.url)]; 426 subscriptions = [Subscription.fromURL(message.url)];
443 427
444 for (let subscription of subscriptions) 428 for (let subscription of subscriptions)
445 { 429 {
446 if (subscription instanceof DownloadableSubscription) 430 if (subscription instanceof DownloadableSubscription)
447 Synchronizer.execute(subscription, true); 431 Synchronizer.execute(subscription, true);
448 } 432 }
449 }); 433 });
450 })(this); 434 })(this);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld