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: Remove the arrow-parens rule Created March 9, 2017, 10:23 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 const {ActiveFilter, BlockingFilter,
23 let {FilterNotifier} = require("filterNotifier"); 25 WhitelistFilter, ElemHideBase} = require("filterClasses");
24 let {desc, extend} = require("coreUtils"); 26 const {FilterNotifier} = require("filterNotifier");
27 const {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
157 * @return {Subscription} subscription or null if the subscription couldn't be c reated 164 * URL of the subscription
165 * @return {Subscription}
166 * subscription or null if the subscription couldn't be created
158 */ 167 */
159 Subscription.fromURL = function(url) 168 Subscription.fromURL = function(url)
160 { 169 {
161 if (url in Subscription.knownSubscriptions) 170 if (url in Subscription.knownSubscriptions)
162 return Subscription.knownSubscriptions[url]; 171 return Subscription.knownSubscriptions[url];
163 172
164 if (url[0] != "~") 173 if (url[0] != "~")
165 return new DownloadableSubscription(url, null); 174 return new DownloadableSubscription(url, null);
166 else 175 return new SpecialSubscription(url);
167 return new SpecialSubscription(url);
168 }; 176 };
169 177
170 /** 178 /**
171 * Deserializes a subscription 179 * Deserializes a subscription
172 * 180 *
173 * @param {Object} obj map of serialized properties and their values 181 * @param {Object} obj
174 * @return {Subscription} subscription or null if the subscription couldn't be c reated 182 * map of serialized properties and their values
183 * @return {Subscription}
184 * subscription or null if the subscription couldn't be created
175 */ 185 */
176 Subscription.fromObject = function(obj) 186 Subscription.fromObject = function(obj)
177 { 187 {
178 let result; 188 let result;
179 if (obj.url[0] != "~") 189 if (obj.url[0] != "~")
180 { 190 {
181 // URL is valid - this is a downloadable subscription 191 // URL is valid - this is a downloadable subscription
182 result = new DownloadableSubscription(obj.url, obj.title); 192 result = new DownloadableSubscription(obj.url, obj.title);
183 if ("downloadStatus" in obj) 193 if ("downloadStatus" in obj)
184 result._downloadStatus = obj.downloadStatus; 194 result._downloadStatus = obj.downloadStatus;
(...skipping 27 matching lines...) Expand all
212 if ("fixedTitle" in obj) 222 if ("fixedTitle" in obj)
213 result._fixedTitle = (obj.fixedTitle == "true"); 223 result._fixedTitle = (obj.fixedTitle == "true");
214 if ("disabled" in obj) 224 if ("disabled" in obj)
215 result._disabled = (obj.disabled == "true"); 225 result._disabled = (obj.disabled == "true");
216 226
217 return result; 227 return result;
218 }; 228 };
219 229
220 /** 230 /**
221 * Class for special filter subscriptions (user's filters) 231 * Class for special filter subscriptions (user's filters)
222 * @param {String} url see Subscription() 232 * @param {string} url see Subscription()
223 * @param {String} [title] see Subscription() 233 * @param {string} [title] see Subscription()
224 * @constructor 234 * @constructor
225 * @augments Subscription 235 * @augments Subscription
226 */ 236 */
227 function SpecialSubscription(url, title) 237 function SpecialSubscription(url, title)
228 { 238 {
229 Subscription.call(this, url, title); 239 Subscription.call(this, url, title);
230 } 240 }
231 exports.SpecialSubscription = SpecialSubscription; 241 exports.SpecialSubscription = SpecialSubscription;
232 242
233 SpecialSubscription.prototype = extend(Subscription, { 243 SpecialSubscription.prototype = extend(Subscription, {
234 /** 244 /**
235 * Filter types that should be added to this subscription by default 245 * Filter types that should be added to this subscription by default
236 * (entries should correspond to keys in SpecialSubscription.defaultsMap). 246 * (entries should correspond to keys in SpecialSubscription.defaultsMap).
237 * @type string[] 247 * @type {string[]}
238 */ 248 */
239 defaults: null, 249 defaults: null,
240 250
241 /** 251 /**
242 * Tests whether a filter should be added to this group by default 252 * Tests whether a filter should be added to this group by default
243 * @param {Filter} filter filter to be tested 253 * @param {Filter} filter filter to be tested
244 * @return {Boolean} 254 * @return {boolean}
245 */ 255 */
246 isDefaultFor: function(filter) 256 isDefaultFor(filter)
247 { 257 {
248 if (this.defaults && this.defaults.length) 258 if (this.defaults && this.defaults.length)
249 { 259 {
250 for (let type of this.defaults) 260 for (let type of this.defaults)
251 { 261 {
252 if (filter instanceof SpecialSubscription.defaultsMap[type]) 262 if (filter instanceof SpecialSubscription.defaultsMap[type])
253 return true; 263 return true;
254 if (!(filter instanceof ActiveFilter) && type == "blacklist") 264 if (!(filter instanceof ActiveFilter) && type == "blacklist")
255 return true; 265 return true;
256 } 266 }
257 } 267 }
258 268
259 return false; 269 return false;
260 }, 270 },
261 271
262 /** 272 /**
263 * See Subscription.serialize() 273 * See Subscription.serialize()
264 */ 274 */
265 serialize: function(buffer) 275 serialize(buffer)
266 { 276 {
267 Subscription.prototype.serialize.call(this, buffer); 277 Subscription.prototype.serialize.call(this, buffer);
268 if (this.defaults && this.defaults.length) 278 if (this.defaults && this.defaults.length)
269 buffer.push("defaults=" + this.defaults.filter((type) => type in SpecialSu bscription.defaultsMap).join(" ")); 279 {
280 buffer.push("defaults=" +
281 this.defaults.filter(
282 type => type in SpecialSubscription.defaultsMap
283 ).join(" ")
284 );
285 }
270 if (this._lastDownload) 286 if (this._lastDownload)
271 buffer.push("lastDownload=" + this._lastDownload); 287 buffer.push("lastDownload=" + this._lastDownload);
272 } 288 }
273 }); 289 });
274 290
275 SpecialSubscription.defaultsMap = Object.create(null, desc({ 291 SpecialSubscription.defaultsMap = Object.create(null, desc({
276 "whitelist": WhitelistFilter, 292 whitelist: WhitelistFilter,
277 "blocking": BlockingFilter, 293 blocking: BlockingFilter,
278 "elemhide": ElemHideBase 294 elemhide: ElemHideBase
279 })); 295 }));
280 296
281 /** 297 /**
282 * Creates a new user-defined filter group. 298 * Creates a new user-defined filter group.
283 * @param {String} [title] title of the new filter group 299 * @param {string} [title] title of the new filter group
284 * @result {SpecialSubscription} 300 * @return {SpecialSubscription}
285 */ 301 */
286 SpecialSubscription.create = function(title) 302 SpecialSubscription.create = function(title)
287 { 303 {
288 let url; 304 let url;
289 do 305 do
290 { 306 {
291 url = "~user~" + Math.round(Math.random()*1000000); 307 url = "~user~" + Math.round(Math.random() * 1000000);
292 } while (url in Subscription.knownSubscriptions); 308 } while (url in Subscription.knownSubscriptions);
293 return new SpecialSubscription(url, title); 309 return new SpecialSubscription(url, title);
294 }; 310 };
295 311
296 /** 312 /**
297 * Creates a new user-defined filter group and adds the given filter to it. 313 * 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. 314 * This group will act as the default group for this filter type.
315 * @param {Filter} filter
316 * @return {SpecialSubscription}
299 */ 317 */
300 SpecialSubscription.createForFilter = function(/**Filter*/ filter) /**SpecialSub scription*/ 318 SpecialSubscription.createForFilter = function(filter)
301 { 319 {
302 let subscription = SpecialSubscription.create(); 320 let subscription = SpecialSubscription.create();
303 subscription.filters.push(filter); 321 subscription.filters.push(filter);
304 for (let type in SpecialSubscription.defaultsMap) 322 for (let type in SpecialSubscription.defaultsMap)
305 { 323 {
306 if (filter instanceof SpecialSubscription.defaultsMap[type]) 324 if (filter instanceof SpecialSubscription.defaultsMap[type])
307 subscription.defaults = [type]; 325 subscription.defaults = [type];
308 } 326 }
309 if (!subscription.defaults) 327 if (!subscription.defaults)
310 subscription.defaults = ["blocking"]; 328 subscription.defaults = ["blocking"];
311 return subscription; 329 return subscription;
312 }; 330 };
313 331
314 /** 332 /**
315 * Abstract base class for regular filter subscriptions (both internally and ext ernally updated) 333 * Abstract base class for regular filter subscriptions (both
316 * @param {String} url see Subscription() 334 * internally and externally updated)
317 * @param {String} [title] see Subscription() 335 * @param {string} url see Subscription()
336 * @param {string} [title] see Subscription()
318 * @constructor 337 * @constructor
319 * @augments Subscription 338 * @augments Subscription
320 */ 339 */
321 function RegularSubscription(url, title) 340 function RegularSubscription(url, title)
322 { 341 {
323 Subscription.call(this, url, title || url); 342 Subscription.call(this, url, title || url);
324 } 343 }
325 exports.RegularSubscription = RegularSubscription; 344 exports.RegularSubscription = RegularSubscription;
326 345
327 RegularSubscription.prototype = extend(Subscription, { 346 RegularSubscription.prototype = extend(Subscription, {
328 _homepage: null, 347 _homepage: null,
329 _lastDownload: 0, 348 _lastDownload: 0,
330 349
331 /** 350 /**
332 * Filter subscription homepage if known 351 * Filter subscription homepage if known
333 * @type String 352 * @type {string}
334 */ 353 */
335 get homepage() 354 get homepage()
336 { 355 {
337 return this._homepage; 356 return this._homepage;
338 }, 357 },
339 set homepage(value) 358 set homepage(value)
340 { 359 {
341 if (value != this._homepage) 360 if (value != this._homepage)
342 { 361 {
343 let oldValue = this._homepage; 362 let oldValue = this._homepage;
344 this._homepage = value; 363 this._homepage = value;
345 FilterNotifier.triggerListeners("subscription.homepage", this, value, oldV alue); 364 FilterNotifier.triggerListeners("subscription.homepage",
365 this, value, oldValue);
346 } 366 }
347 return this._homepage; 367 return this._homepage;
348 }, 368 },
349 369
350 /** 370 /**
351 * Time of the last subscription download (in seconds since the beginning of t he epoch) 371 * Time of the last subscription download (in seconds since the
352 * @type Number 372 * beginning of the epoch)
373 * @type {number}
353 */ 374 */
354 get lastDownload() 375 get lastDownload()
355 { 376 {
356 return this._lastDownload; 377 return this._lastDownload;
357 }, 378 },
358 set lastDownload(value) 379 set lastDownload(value)
359 { 380 {
360 if (value != this._lastDownload) 381 if (value != this._lastDownload)
361 { 382 {
362 let oldValue = this._lastDownload; 383 let oldValue = this._lastDownload;
363 this._lastDownload = value; 384 this._lastDownload = value;
364 FilterNotifier.triggerListeners("subscription.lastDownload", this, value, oldValue); 385 FilterNotifier.triggerListeners("subscription.lastDownload",
386 this, value, oldValue);
365 } 387 }
366 return this._lastDownload; 388 return this._lastDownload;
367 }, 389 },
368 390
369 /** 391 /**
370 * See Subscription.serialize() 392 * See Subscription.serialize()
371 */ 393 */
372 serialize: function(buffer) 394 serialize(buffer)
373 { 395 {
374 Subscription.prototype.serialize.call(this, buffer); 396 Subscription.prototype.serialize.call(this, buffer);
375 if (this._homepage) 397 if (this._homepage)
376 buffer.push("homepage=" + this._homepage); 398 buffer.push("homepage=" + this._homepage);
377 if (this._lastDownload) 399 if (this._lastDownload)
378 buffer.push("lastDownload=" + this._lastDownload); 400 buffer.push("lastDownload=" + this._lastDownload);
379 } 401 }
380 }); 402 });
381 403
382 /** 404 /**
383 * Class for filter subscriptions updated externally (by other extension) 405 * Class for filter subscriptions updated externally (by other extension)
384 * @param {String} url see Subscription() 406 * @param {string} url see Subscription()
385 * @param {String} [title] see Subscription() 407 * @param {string} [title] see Subscription()
386 * @constructor 408 * @constructor
387 * @augments RegularSubscription 409 * @augments RegularSubscription
388 */ 410 */
389 function ExternalSubscription(url, title) 411 function ExternalSubscription(url, title)
390 { 412 {
391 RegularSubscription.call(this, url, title); 413 RegularSubscription.call(this, url, title);
392 } 414 }
393 exports.ExternalSubscription = ExternalSubscription; 415 exports.ExternalSubscription = ExternalSubscription;
394 416
395 ExternalSubscription.prototype = extend(RegularSubscription, { 417 ExternalSubscription.prototype = extend(RegularSubscription, {
396 /** 418 /**
397 * See Subscription.serialize() 419 * See Subscription.serialize()
398 */ 420 */
399 serialize: function(buffer) 421 serialize(buffer)
400 { 422 {
401 throw new Error("Unexpected call, external subscriptions should not be seria lized"); 423 throw new Error(
424 "Unexpected call, external subscriptions should not be serialized"
425 );
402 } 426 }
403 }); 427 });
404 428
405 /** 429 /**
406 * Class for filter subscriptions updated externally (by other extension) 430 * Class for filter subscriptions updated externally (by other extension)
407 * @param {String} url see Subscription() 431 * @param {string} url see Subscription()
408 * @param {String} [title] see Subscription() 432 * @param {string} [title] see Subscription()
409 * @constructor 433 * @constructor
410 * @augments RegularSubscription 434 * @augments RegularSubscription
411 */ 435 */
412 function DownloadableSubscription(url, title) 436 function DownloadableSubscription(url, title)
413 { 437 {
414 RegularSubscription.call(this, url, title); 438 RegularSubscription.call(this, url, title);
415 } 439 }
416 exports.DownloadableSubscription = DownloadableSubscription; 440 exports.DownloadableSubscription = DownloadableSubscription;
417 441
418 DownloadableSubscription.prototype = extend(RegularSubscription, { 442 DownloadableSubscription.prototype = extend(RegularSubscription, {
419 _downloadStatus: null, 443 _downloadStatus: null,
420 _lastCheck: 0, 444 _lastCheck: 0,
421 _errors: 0, 445 _errors: 0,
422 446
423 /** 447 /**
424 * Status of the last download (ID of a string) 448 * Status of the last download (ID of a string)
425 * @type String 449 * @type {string}
426 */ 450 */
427 get downloadStatus() 451 get downloadStatus()
428 { 452 {
429 return this._downloadStatus; 453 return this._downloadStatus;
430 }, 454 },
431 set downloadStatus(value) 455 set downloadStatus(value)
432 { 456 {
433 let oldValue = this._downloadStatus; 457 let oldValue = this._downloadStatus;
434 this._downloadStatus = value; 458 this._downloadStatus = value;
435 FilterNotifier.triggerListeners("subscription.downloadStatus", this, value, oldValue); 459 FilterNotifier.triggerListeners("subscription.downloadStatus",
460 this, value, oldValue);
436 return this._downloadStatus; 461 return this._downloadStatus;
437 }, 462 },
438 463
439 /** 464 /**
440 * Time of the last successful download (in seconds since the beginning of the 465 * Time of the last successful download (in seconds since the beginning of the
441 * epoch). 466 * epoch).
442 */ 467 */
443 lastSuccess: 0, 468 lastSuccess: 0,
444 469
445 /** 470 /**
446 * Time when the subscription was considered for an update last time (in secon ds 471 * 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 472 * (in seconds since the beginning of the epoch). This will be used
448 * if the user doesn't use Adblock Plus for some time. 473 * to increase softExpiration if the user doesn't use Adblock Plus
449 * @type Number 474 * for some time.
475 * @type {number}
450 */ 476 */
451 get lastCheck() 477 get lastCheck()
452 { 478 {
453 return this._lastCheck; 479 return this._lastCheck;
454 }, 480 },
455 set lastCheck(value) 481 set lastCheck(value)
456 { 482 {
457 if (value != this._lastCheck) 483 if (value != this._lastCheck)
458 { 484 {
459 let oldValue = this._lastCheck; 485 let oldValue = this._lastCheck;
460 this._lastCheck = value; 486 this._lastCheck = value;
461 FilterNotifier.triggerListeners("subscription.lastCheck", this, value, old Value); 487 FilterNotifier.triggerListeners("subscription.lastCheck",
488 this, value, oldValue);
462 } 489 }
463 return this._lastCheck; 490 return this._lastCheck;
464 }, 491 },
465 492
466 /** 493 /**
467 * Hard expiration time of the filter subscription (in seconds since the begin ning of the epoch) 494 * Hard expiration time of the filter subscription (in seconds since
468 * @type Number 495 * the beginning of the epoch)
496 * @type {number}
469 */ 497 */
470 expires: 0, 498 expires: 0,
471 499
472 /** 500 /**
473 * Soft expiration time of the filter subscription (in seconds since the begin ning of the epoch) 501 * Soft expiration time of the filter subscription (in seconds since
474 * @type Number 502 * the beginning of the epoch)
503 * @type {number}
475 */ 504 */
476 softExpiration: 0, 505 softExpiration: 0,
477 506
478 /** 507 /**
479 * Number of download failures since last success 508 * Number of download failures since last success
480 * @type Number 509 * @type {number}
481 */ 510 */
482 get errors() 511 get errors()
483 { 512 {
484 return this._errors; 513 return this._errors;
485 }, 514 },
486 set errors(value) 515 set errors(value)
487 { 516 {
488 if (value != this._errors) 517 if (value != this._errors)
489 { 518 {
490 let oldValue = this._errors; 519 let oldValue = this._errors;
491 this._errors = value; 520 this._errors = value;
492 FilterNotifier.triggerListeners("subscription.errors", this, value, oldVal ue); 521 FilterNotifier.triggerListeners("subscription.errors", this,
522 value, oldValue);
493 } 523 }
494 return this._errors; 524 return this._errors;
495 }, 525 },
496 526
497 /** 527 /**
498 * Version of the subscription data retrieved on last successful download 528 * Version of the subscription data retrieved on last successful download
499 * @type Number 529 * @type {number}
500 */ 530 */
501 version: 0, 531 version: 0,
502 532
503 /** 533 /**
504 * Minimal Adblock Plus version required for this subscription 534 * Minimal Adblock Plus version required for this subscription
505 * @type String 535 * @type {string}
506 */ 536 */
507 requiredVersion: null, 537 requiredVersion: null,
508 538
509 /** 539 /**
510 * Number indicating how often the object was downloaded. 540 * Number indicating how often the object was downloaded.
511 * @type Number 541 * @type {number}
512 */ 542 */
513 downloadCount: 0, 543 downloadCount: 0,
514 544
515 /** 545 /**
516 * See Subscription.serialize() 546 * See Subscription.serialize()
517 */ 547 */
518 serialize: function(buffer) 548 serialize(buffer)
519 { 549 {
520 RegularSubscription.prototype.serialize.call(this, buffer); 550 RegularSubscription.prototype.serialize.call(this, buffer);
521 if (this.downloadStatus) 551 if (this.downloadStatus)
522 buffer.push("downloadStatus=" + this.downloadStatus); 552 buffer.push("downloadStatus=" + this.downloadStatus);
523 if (this.lastSuccess) 553 if (this.lastSuccess)
524 buffer.push("lastSuccess=" + this.lastSuccess); 554 buffer.push("lastSuccess=" + this.lastSuccess);
525 if (this.lastCheck) 555 if (this.lastCheck)
526 buffer.push("lastCheck=" + this.lastCheck); 556 buffer.push("lastCheck=" + this.lastCheck);
527 if (this.expires) 557 if (this.expires)
528 buffer.push("expires=" + this.expires); 558 buffer.push("expires=" + this.expires);
529 if (this.softExpiration) 559 if (this.softExpiration)
530 buffer.push("softExpiration=" + this.softExpiration); 560 buffer.push("softExpiration=" + this.softExpiration);
531 if (this.errors) 561 if (this.errors)
532 buffer.push("errors=" + this.errors); 562 buffer.push("errors=" + this.errors);
533 if (this.version) 563 if (this.version)
534 buffer.push("version=" + this.version); 564 buffer.push("version=" + this.version);
535 if (this.requiredVersion) 565 if (this.requiredVersion)
536 buffer.push("requiredVersion=" + this.requiredVersion); 566 buffer.push("requiredVersion=" + this.requiredVersion);
537 if (this.downloadCount) 567 if (this.downloadCount)
538 buffer.push("downloadCount=" + this.downloadCount); 568 buffer.push("downloadCount=" + this.downloadCount);
539 } 569 }
540 }); 570 });
OLDNEW

Powered by Google App Engine
This is Rietveld