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

Delta Between Two Patch Sets: lib/synchronizer.js

Issue 29375915: Issue 4878 - Start using ESLint for adblockpluscore (Closed)
Left Patch Set: Rebased. Created Feb. 28, 2017, 3:55 p.m.
Right Patch Set: Removed unused imports Created March 15, 2017, 3:11 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/subscriptionClasses.js ('k') | test/.eslintrc.json » ('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 file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 /** 20 /**
21 * @fileOverview Manages synchronization of filter subscriptions. 21 * @fileOverview Manages synchronization of filter subscriptions.
22 */ 22 */
23 23
24 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
25 Cu.import("resource://gre/modules/Services.jsm");
26
27 const {Downloader, Downloadable, 24 const {Downloader, Downloadable,
28 MILLIS_IN_SECOND, MILLIS_IN_MINUTE, 25 MILLIS_IN_SECOND, MILLIS_IN_MINUTE,
29 MILLIS_IN_HOUR, MILLIS_IN_DAY} = require("downloader"); 26 MILLIS_IN_HOUR, MILLIS_IN_DAY} = require("downloader");
30 const {Filter, CommentFilter} = require("filterClasses"); 27 const {Filter} = require("filterClasses");
31 const {FilterStorage} = require("filterStorage"); 28 const {FilterStorage} = require("filterStorage");
32 const {FilterNotifier} = require("filterNotifier"); 29 const {FilterNotifier} = require("filterNotifier");
33 const {Prefs} = require("prefs"); 30 const {Prefs} = require("prefs");
34 const {Subscription, DownloadableSubscription} = require("subscriptionClasses"); 31 const {Subscription, DownloadableSubscription} = require("subscriptionClasses");
35 const {Utils} = require("utils"); 32 const {Utils} = require("utils");
36 33
37 let INITIAL_DELAY = 1 * MILLIS_IN_MINUTE; 34 const INITIAL_DELAY = 1 * MILLIS_IN_MINUTE;
38 let CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; 35 const CHECK_INTERVAL = 1 * MILLIS_IN_HOUR;
39 let DEFAULT_EXPIRATION_INTERVAL = 5 * MILLIS_IN_DAY; 36 const DEFAULT_EXPIRATION_INTERVAL = 5 * MILLIS_IN_DAY;
Wladimir Palant 2017/03/02 14:07:06 The values declared above are actual constants.
kzar 2017/03/08 12:33:54 Done.
40 37
41 /** 38 /**
42 * The object providing actual downloading functionality. 39 * The object providing actual downloading functionality.
43 * @type {Downloader} 40 * @type {Downloader}
44 */ 41 */
45 let downloader = null; 42 let downloader = null;
46 43
47 /** 44 /**
48 * This object is responsible for downloading filter subscriptions whenever 45 * This object is responsible for downloading filter subscriptions whenever
49 * necessary. 46 * necessary.
(...skipping 24 matching lines...) Expand all
74 * @param {string} url URL of the subscription 71 * @param {string} url URL of the subscription
75 * @return {boolean} 72 * @return {boolean}
76 */ 73 */
77 isExecuting(url) 74 isExecuting(url)
78 { 75 {
79 return downloader.isDownloading(url); 76 return downloader.isDownloading(url);
80 }, 77 },
81 78
82 /** 79 /**
83 * Starts the download of a subscription. 80 * Starts the download of a subscription.
84 * @param {DownloadableSubscription} subscription Subscription to be 81 * @param {DownloadableSubscription} subscription
85 * downloaded 82 * Subscription to be downloaded
86 * @param {boolean} manual true for a manually started download 83 * @param {boolean} manual
87 * (should not trigger fallback requests) 84 * true for a manually started download (should not trigger fallback
Wladimir Palant 2017/03/02 14:07:06 Messy indentation here.
kzar 2017/03/08 12:33:53 Done.
85 * requests)
88 */ 86 */
89 execute(subscription, manual) 87 execute(subscription, manual)
90 { 88 {
91 downloader.download(this._getDownloadable(subscription, manual)); 89 downloader.download(this._getDownloadable(subscription, manual));
92 }, 90 },
93 91
94 /** 92 /**
95 * Yields Downloadable instances for all subscriptions that can be downloaded. 93 * Yields Downloadable instances for all subscriptions that can be downloaded.
96 */ 94 */
97 *_getDownloadables() 95 *_getDownloadables()
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 { 333 {
336 if (onShutdown.done) 334 if (onShutdown.done)
337 return; 335 return;
338 336
339 if (!(subscription.url in FilterStorage.knownSubscriptions)) 337 if (!(subscription.url in FilterStorage.knownSubscriptions))
340 return; 338 return;
341 339
342 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText); 340 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText);
343 if (match && match[1] == "301" && // Moved permanently 341 if (match && match[1] == "301" && // Moved permanently
344 match[2] && /^https?:\/\//i.test(match[2])) 342 match[2] && /^https?:\/\//i.test(match[2]))
343 {
345 redirectCallback(match[2]); 344 redirectCallback(match[2]);
345 }
346 else if (match && match[1] == "410") // Gone 346 else if (match && match[1] == "410") // Gone
347 { 347 {
348 let data = "[Adblock]\n" + 348 let data = "[Adblock]\n" +
349 subscription.filters.map(f => f.text).join("\n"); 349 subscription.filters.map(f => f.text).join("\n");
350 redirectCallback("data:text/plain," + encodeURIComponent(data)); 350 redirectCallback("data:text/plain," + encodeURIComponent(data));
351 } 351 }
352 }, false); 352 }, false);
353 request.send(null); 353 request.send(null);
354 } 354 }
355 } 355 }
356 } 356 }
357 }; 357 };
358 Synchronizer.init(); 358 Synchronizer.init();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld