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

Side by Side Diff: lib/subscriptionClasses.js

Issue 29375915: Issue 4878 - Start using ESLint for adblockpluscore (Closed)
Patch Set: Addressed Sebastian's initial feedback Created Feb. 21, 2017, 6:12 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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-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";
19
18 /** 20 /**
19 * @fileOverview Definition of Subscription class and its subclasses. 21 * @fileOverview Definition of Subscription class and its subclasses.
20 */ 22 */
21 23
22 let {ActiveFilter, BlockingFilter, WhitelistFilter, ElemHideBase} = require("fil terClasses"); 24 let {ActiveFilter, BlockingFilter,
25 WhitelistFilter, ElemHideBase} = require("filterClasses");
23 let {FilterNotifier} = require("filterNotifier"); 26 let {FilterNotifier} = require("filterNotifier");
24 let {desc, extend} = require("coreUtils"); 27 let {desc, extend} = require("coreUtils");
25 28
26 /** 29 /**
27 * Abstract base class for filter subscriptions 30 * Abstract base class for filter subscriptions
28 * 31 *
29 * @param {String} url download location of the subscription 32 * @param {string} url download location of the subscription
30 * @param {String} [title] title of the filter subscription 33 * @param {string} [title] title of the filter subscription
31 * @constructor 34 * @constructor
32 */ 35 */
33 function Subscription(url, title) 36 function Subscription(url, title)
34 { 37 {
35 this.url = url; 38 this.url = url;
36 this.filters = []; 39 this.filters = [];
37 if (title) 40 if (title)
38 this._title = title; 41 this._title = title;
39 Subscription.knownSubscriptions[url] = this; 42 Subscription.knownSubscriptions[url] = this;
40 } 43 }
41 exports.Subscription = Subscription; 44 exports.Subscription = Subscription;
42 45
43 Subscription.prototype = 46 Subscription.prototype =
44 { 47 {
45 /** 48 /**
46 * Download location of the subscription 49 * Download location of the subscription
47 * @type String 50 * @type {string}
48 */ 51 */
49 url: null, 52 url: null,
50 53
51 /** 54 /**
52 * Filters contained in the filter subscription 55 * Filters contained in the filter subscription
53 * @type Filter[] 56 * @type {Filter[]}
54 */ 57 */
55 filters: null, 58 filters: null,
56 59
57 _title: null, 60 _title: null,
58 _fixedTitle: false, 61 _fixedTitle: false,
59 _disabled: false, 62 _disabled: false,
60 63
61 /** 64 /**
62 * Title of the filter subscription 65 * Title of the filter subscription
63 * @type String 66 * @type {string}
64 */ 67 */
65 get title() 68 get title()
66 { 69 {
67 return this._title; 70 return this._title;
68 }, 71 },
69 set title(value) 72 set title(value)
70 { 73 {
71 if (value != this._title) 74 if (value != this._title)
72 { 75 {
73 let oldValue = this._title; 76 let oldValue = this._title;
74 this._title = value; 77 this._title = value;
75 FilterNotifier.triggerListeners("subscription.title", this, value, oldValu e); 78 FilterNotifier.triggerListeners("subscription.title",
79 this, value, oldValue);
76 } 80 }
77 return this._title; 81 return this._title;
78 }, 82 },
79 83
80 /** 84 /**
81 * Determines whether the title should be editable 85 * Determines whether the title should be editable
82 * @type Boolean 86 * @type {boolean}
83 */ 87 */
84 get fixedTitle() 88 get fixedTitle()
85 { 89 {
86 return this._fixedTitle; 90 return this._fixedTitle;
87 }, 91 },
88 set fixedTitle(value) 92 set fixedTitle(value)
89 { 93 {
90 if (value != this._fixedTitle) 94 if (value != this._fixedTitle)
91 { 95 {
92 let oldValue = this._fixedTitle; 96 let oldValue = this._fixedTitle;
93 this._fixedTitle = value; 97 this._fixedTitle = value;
94 FilterNotifier.triggerListeners("subscription.fixedTitle", this, value, ol dValue); 98 FilterNotifier.triggerListeners("subscription.fixedTitle",
99 this, value, oldValue);
95 } 100 }
96 return this._fixedTitle; 101 return this._fixedTitle;
97 }, 102 },
98 103
99 /** 104 /**
100 * Defines whether the filters in the subscription should be disabled 105 * Defines whether the filters in the subscription should be disabled
101 * @type Boolean 106 * @type {boolean}
102 */ 107 */
103 get disabled() 108 get disabled()
104 { 109 {
105 return this._disabled; 110 return this._disabled;
106 }, 111 },
107 set disabled(value) 112 set disabled(value)
108 { 113 {
109 if (value != this._disabled) 114 if (value != this._disabled)
110 { 115 {
111 let oldValue = this._disabled; 116 let oldValue = this._disabled;
112 this._disabled = value; 117 this._disabled = value;
113 FilterNotifier.triggerListeners("subscription.disabled", this, value, oldV alue); 118 FilterNotifier.triggerListeners("subscription.disabled",
119 this, value, oldValue);
114 } 120 }
115 return this._disabled; 121 return this._disabled;
116 }, 122 },
117 123
118 /** 124 /**
119 * Serializes the subscription to an array of strings for writing out on the d isk. 125 * Serializes the subscription to an array of strings for writing
126 * out on the disk.
120 * @param {string[]} buffer buffer to push the serialization results into 127 * @param {string[]} buffer buffer to push the serialization results into
121 */ 128 */
122 serialize: function(buffer) 129 serialize(buffer)
123 { 130 {
124 buffer.push("[Subscription]"); 131 buffer.push("[Subscription]");
125 buffer.push("url=" + this.url); 132 buffer.push("url=" + this.url);
126 if (this._title) 133 if (this._title)
127 buffer.push("title=" + this._title); 134 buffer.push("title=" + this._title);
128 if (this._fixedTitle) 135 if (this._fixedTitle)
129 buffer.push("fixedTitle=true"); 136 buffer.push("fixedTitle=true");
130 if (this._disabled) 137 if (this._disabled)
131 buffer.push("disabled=true"); 138 buffer.push("disabled=true");
132 }, 139 },
133 140
134 serializeFilters: function(buffer) 141 serializeFilters(buffer)
135 { 142 {
136 for (let filter of this.filters) 143 for (let filter of this.filters)
137 buffer.push(filter.text.replace(/\[/g, "\\[")); 144 buffer.push(filter.text.replace(/\[/g, "\\["));
138 }, 145 },
139 146
140 toString: function() 147 toString()
141 { 148 {
142 let buffer = []; 149 let buffer = [];
143 this.serialize(buffer); 150 this.serialize(buffer);
144 return buffer.join("\n"); 151 return buffer.join("\n");
145 } 152 }
146 }; 153 };
147 154
148 /** 155 /**
149 * Cache for known filter subscriptions, maps URL to subscription objects. 156 * Cache for known filter subscriptions, maps URL to subscription objects.
150 * @type Object 157 * @type {Object}
151 */ 158 */
152 Subscription.knownSubscriptions = Object.create(null); 159 Subscription.knownSubscriptions = Object.create(null);
153 160
154 /** 161 /**
155 * Returns a subscription from its URL, creates a new one if necessary. 162 * Returns a subscription from its URL, creates a new one if necessary.
156 * @param {String} url URL of the subscription 163 * @param {string} url URL of the subscription
157 * @return {Subscription} subscription or null if the subscription couldn't be c reated 164 * @return {Subscription} subscription or null if the subscription couldn't be
165 * created
158 */ 166 */
159 Subscription.fromURL = function(url) 167 Subscription.fromURL = function(url)
160 { 168 {
161 if (url in Subscription.knownSubscriptions) 169 if (url in Subscription.knownSubscriptions)
162 return Subscription.knownSubscriptions[url]; 170 return Subscription.knownSubscriptions[url];
163 171
164 if (url[0] != "~") 172 if (url[0] != "~")
165 return new DownloadableSubscription(url, null); 173 return new DownloadableSubscription(url, null);
166 else 174 return new SpecialSubscription(url);
167 return new SpecialSubscription(url);
168 }; 175 };
169 176
170 /** 177 /**
171 * Deserializes a subscription 178 * Deserializes a subscription
172 * 179 *
173 * @param {Object} obj map of serialized properties and their values 180 * @param {Object} obj map of serialized properties and their values
174 * @return {Subscription} subscription or null if the subscription couldn't be c reated 181 * @return {Subscription} subscription or null if the subscription couldn't be
182 * created
175 */ 183 */
176 Subscription.fromObject = function(obj) 184 Subscription.fromObject = function(obj)
177 { 185 {
178 let result; 186 let result;
179 if (obj.url[0] != "~") 187 if (obj.url[0] != "~")
180 { 188 {
181 // URL is valid - this is a downloadable subscription 189 // URL is valid - this is a downloadable subscription
182 result = new DownloadableSubscription(obj.url, obj.title); 190 result = new DownloadableSubscription(obj.url, obj.title);
183 if ("downloadStatus" in obj) 191 if ("downloadStatus" in obj)
184 result._downloadStatus = obj.downloadStatus; 192 result._downloadStatus = obj.downloadStatus;
(...skipping 27 matching lines...) Expand all
212 if ("fixedTitle" in obj) 220 if ("fixedTitle" in obj)
213 result._fixedTitle = (obj.fixedTitle == "true"); 221 result._fixedTitle = (obj.fixedTitle == "true");
214 if ("disabled" in obj) 222 if ("disabled" in obj)
215 result._disabled = (obj.disabled == "true"); 223 result._disabled = (obj.disabled == "true");
216 224
217 return result; 225 return result;
218 }; 226 };
219 227
220 /** 228 /**
221 * Class for special filter subscriptions (user's filters) 229 * Class for special filter subscriptions (user's filters)
222 * @param {String} url see Subscription() 230 * @param {string} url see Subscription()
223 * @param {String} [title] see Subscription() 231 * @param {string} [title] see Subscription()
224 * @constructor 232 * @constructor
225 * @augments Subscription 233 * @augments Subscription
226 */ 234 */
227 function SpecialSubscription(url, title) 235 function SpecialSubscription(url, title)
228 { 236 {
229 Subscription.call(this, url, title); 237 Subscription.call(this, url, title);
230 } 238 }
231 exports.SpecialSubscription = SpecialSubscription; 239 exports.SpecialSubscription = SpecialSubscription;
232 240
233 SpecialSubscription.prototype = extend(Subscription, { 241 SpecialSubscription.prototype = extend(Subscription, {
234 /** 242 /**
235 * Filter types that should be added to this subscription by default 243 * Filter types that should be added to this subscription by default
236 * (entries should correspond to keys in SpecialSubscription.defaultsMap). 244 * (entries should correspond to keys in SpecialSubscription.defaultsMap).
237 * @type string[] 245 * @type {string[]}
238 */ 246 */
239 defaults: null, 247 defaults: null,
240 248
241 /** 249 /**
242 * Tests whether a filter should be added to this group by default 250 * Tests whether a filter should be added to this group by default
243 * @param {Filter} filter filter to be tested 251 * @param {Filter} filter filter to be tested
244 * @return {Boolean} 252 * @return {boolean}
245 */ 253 */
246 isDefaultFor: function(filter) 254 isDefaultFor(filter)
247 { 255 {
248 if (this.defaults && this.defaults.length) 256 if (this.defaults && this.defaults.length)
249 { 257 {
250 for (let type of this.defaults) 258 for (let type of this.defaults)
251 { 259 {
252 if (filter instanceof SpecialSubscription.defaultsMap[type]) 260 if (filter instanceof SpecialSubscription.defaultsMap[type])
253 return true; 261 return true;
254 if (!(filter instanceof ActiveFilter) && type == "blacklist") 262 if (!(filter instanceof ActiveFilter) && type == "blacklist")
255 return true; 263 return true;
256 } 264 }
257 } 265 }
258 266
259 return false; 267 return false;
260 }, 268 },
261 269
262 /** 270 /**
263 * See Subscription.serialize() 271 * See Subscription.serialize()
272 * @param {string[]} buffer buffer to push the serialization results into
264 */ 273 */
265 serialize: function(buffer) 274 serialize(buffer)
266 { 275 {
267 Subscription.prototype.serialize.call(this, buffer); 276 Subscription.prototype.serialize.call(this, buffer);
268 if (this.defaults && this.defaults.length) 277 if (this.defaults && this.defaults.length)
269 buffer.push("defaults=" + this.defaults.filter((type) => type in SpecialSu bscription.defaultsMap).join(" ")); 278 {
279 buffer.push("defaults=" + this.defaults.
280 filter((type) => type in SpecialSubscription.defaultsMap).join(" "));
Sebastian Noack 2017/02/21 09:19:31 If you break after the dot, it looks weird and is
kzar 2017/02/21 10:37:02 Done.
281 }
270 if (this._lastDownload) 282 if (this._lastDownload)
271 buffer.push("lastDownload=" + this._lastDownload); 283 buffer.push("lastDownload=" + this._lastDownload);
272 } 284 }
273 }); 285 });
274 286
275 SpecialSubscription.defaultsMap = Object.create(null, desc({ 287 SpecialSubscription.defaultsMap = Object.create(null, desc({
276 "whitelist": WhitelistFilter, 288 whitelist: WhitelistFilter,
277 "blocking": BlockingFilter, 289 blocking: BlockingFilter,
278 "elemhide": ElemHideBase 290 elemhide: ElemHideBase
279 })); 291 }));
280 292
281 /** 293 /**
282 * Creates a new user-defined filter group. 294 * Creates a new user-defined filter group.
283 * @param {String} [title] title of the new filter group 295 * @param {string} [title] title of the new filter group
284 * @result {SpecialSubscription} 296 * @return {SpecialSubscription}
285 */ 297 */
286 SpecialSubscription.create = function(title) 298 SpecialSubscription.create = function(title)
287 { 299 {
288 let url; 300 let url;
289 do 301 do
290 { 302 url = "~user~" + Math.round(Math.random() * 1000000);
291 url = "~user~" + Math.round(Math.random()*1000000); 303 while (url in Subscription.knownSubscriptions);
292 } while (url in Subscription.knownSubscriptions);
293 return new SpecialSubscription(url, title); 304 return new SpecialSubscription(url, title);
294 }; 305 };
295 306
296 /** 307 /**
297 * Creates a new user-defined filter group and adds the given filter to it. 308 * Creates a new user-defined filter group and adds the given filter to it.
298 * This group will act as the default group for this filter type. 309 * This group will act as the default group for this filter type.
310 * @param {Filter} filter
311 * @return {SpecialSubscription}
299 */ 312 */
300 SpecialSubscription.createForFilter = function(/**Filter*/ filter) /**SpecialSub scription*/ 313 SpecialSubscription.createForFilter = function(filter)
301 { 314 {
302 let subscription = SpecialSubscription.create(); 315 let subscription = SpecialSubscription.create();
303 subscription.filters.push(filter); 316 subscription.filters.push(filter);
304 for (let type in SpecialSubscription.defaultsMap) 317 for (let type in SpecialSubscription.defaultsMap)
305 { 318 {
306 if (filter instanceof SpecialSubscription.defaultsMap[type]) 319 if (filter instanceof SpecialSubscription.defaultsMap[type])
307 subscription.defaults = [type]; 320 subscription.defaults = [type];
308 } 321 }
309 if (!subscription.defaults) 322 if (!subscription.defaults)
310 subscription.defaults = ["blocking"]; 323 subscription.defaults = ["blocking"];
311 return subscription; 324 return subscription;
312 }; 325 };
313 326
314 /** 327 /**
315 * Abstract base class for regular filter subscriptions (both internally and ext ernally updated) 328 * Abstract base class for regular filter subscriptions (both
316 * @param {String} url see Subscription() 329 * internally and externally updated)
317 * @param {String} [title] see Subscription() 330 * @param {string} url see Subscription()
331 * @param {string} [title] see Subscription()
318 * @constructor 332 * @constructor
319 * @augments Subscription 333 * @augments Subscription
320 */ 334 */
321 function RegularSubscription(url, title) 335 function RegularSubscription(url, title)
322 { 336 {
323 Subscription.call(this, url, title || url); 337 Subscription.call(this, url, title || url);
324 } 338 }
325 exports.RegularSubscription = RegularSubscription; 339 exports.RegularSubscription = RegularSubscription;
326 340
327 RegularSubscription.prototype = extend(Subscription, { 341 RegularSubscription.prototype = extend(Subscription, {
328 _homepage: null, 342 _homepage: null,
329 _lastDownload: 0, 343 _lastDownload: 0,
330 344
331 /** 345 /**
332 * Filter subscription homepage if known 346 * Filter subscription homepage if known
333 * @type String 347 * @type {string}
334 */ 348 */
335 get homepage() 349 get homepage()
336 { 350 {
337 return this._homepage; 351 return this._homepage;
338 }, 352 },
339 set homepage(value) 353 set homepage(value)
340 { 354 {
341 if (value != this._homepage) 355 if (value != this._homepage)
342 { 356 {
343 let oldValue = this._homepage; 357 let oldValue = this._homepage;
344 this._homepage = value; 358 this._homepage = value;
345 FilterNotifier.triggerListeners("subscription.homepage", this, value, oldV alue); 359 FilterNotifier.triggerListeners("subscription.homepage",
360 this, value, oldValue);
346 } 361 }
347 return this._homepage; 362 return this._homepage;
348 }, 363 },
349 364
350 /** 365 /**
351 * Time of the last subscription download (in seconds since the beginning of t he epoch) 366 * Time of the last subscription download (in seconds since the
352 * @type Number 367 * beginning of the epoch)
368 * @type {Number}
353 */ 369 */
354 get lastDownload() 370 get lastDownload()
355 { 371 {
356 return this._lastDownload; 372 return this._lastDownload;
357 }, 373 },
358 set lastDownload(value) 374 set lastDownload(value)
359 { 375 {
360 if (value != this._lastDownload) 376 if (value != this._lastDownload)
361 { 377 {
362 let oldValue = this._lastDownload; 378 let oldValue = this._lastDownload;
363 this._lastDownload = value; 379 this._lastDownload = value;
364 FilterNotifier.triggerListeners("subscription.lastDownload", this, value, oldValue); 380 FilterNotifier.triggerListeners("subscription.lastDownload",
381 this, value, oldValue);
365 } 382 }
366 return this._lastDownload; 383 return this._lastDownload;
367 }, 384 },
368 385
369 /** 386 /**
370 * See Subscription.serialize() 387 * See Subscription.serialize()
388 * @param {string[]} buffer
371 */ 389 */
372 serialize: function(buffer) 390 serialize(buffer)
373 { 391 {
374 Subscription.prototype.serialize.call(this, buffer); 392 Subscription.prototype.serialize.call(this, buffer);
375 if (this._homepage) 393 if (this._homepage)
376 buffer.push("homepage=" + this._homepage); 394 buffer.push("homepage=" + this._homepage);
377 if (this._lastDownload) 395 if (this._lastDownload)
378 buffer.push("lastDownload=" + this._lastDownload); 396 buffer.push("lastDownload=" + this._lastDownload);
379 } 397 }
380 }); 398 });
381 399
382 /** 400 /**
383 * Class for filter subscriptions updated externally (by other extension) 401 * Class for filter subscriptions updated externally (by other extension)
384 * @param {String} url see Subscription() 402 * @param {string} url see Subscription()
385 * @param {String} [title] see Subscription() 403 * @param {string} [title] see Subscription()
386 * @constructor 404 * @constructor
387 * @augments RegularSubscription 405 * @augments RegularSubscription
388 */ 406 */
389 function ExternalSubscription(url, title) 407 function ExternalSubscription(url, title)
390 { 408 {
391 RegularSubscription.call(this, url, title); 409 RegularSubscription.call(this, url, title);
392 } 410 }
393 exports.ExternalSubscription = ExternalSubscription; 411 exports.ExternalSubscription = ExternalSubscription;
394 412
395 ExternalSubscription.prototype = extend(RegularSubscription, { 413 ExternalSubscription.prototype = extend(RegularSubscription, {
396 /** 414 /**
397 * See Subscription.serialize() 415 * See Subscription.serialize()
416 * @param {string[]} buffer
398 */ 417 */
399 serialize: function(buffer) 418 serialize(buffer)
400 { 419 {
401 throw new Error("Unexpected call, external subscriptions should not be seria lized"); 420 throw new Error(
421 "Unexpected call, external subscriptions should not be serialized"
422 );
402 } 423 }
403 }); 424 });
404 425
405 /** 426 /**
406 * Class for filter subscriptions updated externally (by other extension) 427 * Class for filter subscriptions updated externally (by other extension)
407 * @param {String} url see Subscription() 428 * @param {string} url see Subscription()
408 * @param {String} [title] see Subscription() 429 * @param {string} [title] see Subscription()
409 * @constructor 430 * @constructor
410 * @augments RegularSubscription 431 * @augments RegularSubscription
411 */ 432 */
412 function DownloadableSubscription(url, title) 433 function DownloadableSubscription(url, title)
413 { 434 {
414 RegularSubscription.call(this, url, title); 435 RegularSubscription.call(this, url, title);
415 } 436 }
416 exports.DownloadableSubscription = DownloadableSubscription; 437 exports.DownloadableSubscription = DownloadableSubscription;
417 438
418 DownloadableSubscription.prototype = extend(RegularSubscription, { 439 DownloadableSubscription.prototype = extend(RegularSubscription, {
419 _downloadStatus: null, 440 _downloadStatus: null,
420 _lastCheck: 0, 441 _lastCheck: 0,
421 _errors: 0, 442 _errors: 0,
422 443
423 /** 444 /**
424 * Status of the last download (ID of a string) 445 * Status of the last download (ID of a string)
425 * @type String 446 * @type {string}
426 */ 447 */
427 get downloadStatus() 448 get downloadStatus()
428 { 449 {
429 return this._downloadStatus; 450 return this._downloadStatus;
430 }, 451 },
431 set downloadStatus(value) 452 set downloadStatus(value)
432 { 453 {
433 let oldValue = this._downloadStatus; 454 let oldValue = this._downloadStatus;
434 this._downloadStatus = value; 455 this._downloadStatus = value;
435 FilterNotifier.triggerListeners("subscription.downloadStatus", this, value, oldValue); 456 FilterNotifier.triggerListeners("subscription.downloadStatus",
457 this, value, oldValue);
436 return this._downloadStatus; 458 return this._downloadStatus;
437 }, 459 },
438 460
439 /** 461 /**
440 * Time of the last successful download (in seconds since the beginning of the 462 * Time of the last successful download (in seconds since the beginning of the
441 * epoch). 463 * epoch).
442 */ 464 */
443 lastSuccess: 0, 465 lastSuccess: 0,
444 466
445 /** 467 /**
446 * Time when the subscription was considered for an update last time (in secon ds 468 * Time when the subscription was considered for an update last time
447 * since the beginning of the epoch). This will be used to increase softExpira tion 469 * (in seconds since the beginning of the epoch). This will be used
448 * if the user doesn't use Adblock Plus for some time. 470 * to increase softExpiration if the user doesn't use Adblock Plus
449 * @type Number 471 * for some time.
472 * @type {Number}
450 */ 473 */
451 get lastCheck() 474 get lastCheck()
452 { 475 {
453 return this._lastCheck; 476 return this._lastCheck;
454 }, 477 },
455 set lastCheck(value) 478 set lastCheck(value)
456 { 479 {
457 if (value != this._lastCheck) 480 if (value != this._lastCheck)
458 { 481 {
459 let oldValue = this._lastCheck; 482 let oldValue = this._lastCheck;
460 this._lastCheck = value; 483 this._lastCheck = value;
461 FilterNotifier.triggerListeners("subscription.lastCheck", this, value, old Value); 484 FilterNotifier.triggerListeners("subscription.lastCheck",
485 this, value, oldValue);
462 } 486 }
463 return this._lastCheck; 487 return this._lastCheck;
464 }, 488 },
465 489
466 /** 490 /**
467 * Hard expiration time of the filter subscription (in seconds since the begin ning of the epoch) 491 * Hard expiration time of the filter subscription (in seconds since
468 * @type Number 492 * the beginning of the epoch)
493 * @type {Number}
469 */ 494 */
470 expires: 0, 495 expires: 0,
471 496
472 /** 497 /**
473 * Soft expiration time of the filter subscription (in seconds since the begin ning of the epoch) 498 * Soft expiration time of the filter subscription (in seconds since
474 * @type Number 499 * the beginning of the epoch)
500 * @type {Number}
475 */ 501 */
476 softExpiration: 0, 502 softExpiration: 0,
477 503
478 /** 504 /**
479 * Number of download failures since last success 505 * Number of download failures since last success
480 * @type Number 506 * @type {Number}
481 */ 507 */
482 get errors() 508 get errors()
483 { 509 {
484 return this._errors; 510 return this._errors;
485 }, 511 },
486 set errors(value) 512 set errors(value)
487 { 513 {
488 if (value != this._errors) 514 if (value != this._errors)
489 { 515 {
490 let oldValue = this._errors; 516 let oldValue = this._errors;
491 this._errors = value; 517 this._errors = value;
492 FilterNotifier.triggerListeners("subscription.errors", this, value, oldVal ue); 518 FilterNotifier.triggerListeners("subscription.errors", this,
519 value, oldValue);
493 } 520 }
494 return this._errors; 521 return this._errors;
495 }, 522 },
496 523
497 /** 524 /**
498 * Version of the subscription data retrieved on last successful download 525 * Version of the subscription data retrieved on last successful download
499 * @type Number 526 * @type {Number}
500 */ 527 */
501 version: 0, 528 version: 0,
502 529
503 /** 530 /**
504 * Minimal Adblock Plus version required for this subscription 531 * Minimal Adblock Plus version required for this subscription
505 * @type String 532 * @type {string}
506 */ 533 */
507 requiredVersion: null, 534 requiredVersion: null,
508 535
509 /** 536 /**
510 * Number indicating how often the object was downloaded. 537 * Number indicating how often the object was downloaded.
511 * @type Number 538 * @type {Number}
512 */ 539 */
513 downloadCount: 0, 540 downloadCount: 0,
514 541
515 /** 542 /**
516 * See Subscription.serialize() 543 * See Subscription.serialize()
544 * @param {string[]} buffer
517 */ 545 */
518 serialize: function(buffer) 546 serialize(buffer)
519 { 547 {
520 RegularSubscription.prototype.serialize.call(this, buffer); 548 RegularSubscription.prototype.serialize.call(this, buffer);
521 if (this.downloadStatus) 549 if (this.downloadStatus)
522 buffer.push("downloadStatus=" + this.downloadStatus); 550 buffer.push("downloadStatus=" + this.downloadStatus);
523 if (this.lastSuccess) 551 if (this.lastSuccess)
524 buffer.push("lastSuccess=" + this.lastSuccess); 552 buffer.push("lastSuccess=" + this.lastSuccess);
525 if (this.lastCheck) 553 if (this.lastCheck)
526 buffer.push("lastCheck=" + this.lastCheck); 554 buffer.push("lastCheck=" + this.lastCheck);
527 if (this.expires) 555 if (this.expires)
528 buffer.push("expires=" + this.expires); 556 buffer.push("expires=" + this.expires);
529 if (this.softExpiration) 557 if (this.softExpiration)
530 buffer.push("softExpiration=" + this.softExpiration); 558 buffer.push("softExpiration=" + this.softExpiration);
531 if (this.errors) 559 if (this.errors)
532 buffer.push("errors=" + this.errors); 560 buffer.push("errors=" + this.errors);
533 if (this.version) 561 if (this.version)
534 buffer.push("version=" + this.version); 562 buffer.push("version=" + this.version);
535 if (this.requiredVersion) 563 if (this.requiredVersion)
536 buffer.push("requiredVersion=" + this.requiredVersion); 564 buffer.push("requiredVersion=" + this.requiredVersion);
537 if (this.downloadCount) 565 if (this.downloadCount)
538 buffer.push("downloadCount=" + this.downloadCount); 566 buffer.push("downloadCount=" + this.downloadCount);
539 } 567 }
540 }); 568 });
OLDNEW

Powered by Google App Engine
This is Rietveld