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

Side by Side Diff: lib/subscriptionClasses.js

Issue 29350382: Issue 4353 - Remove deprecated __proto__ syntax (Closed)
Patch Set: Missed a file... Created Sept. 1, 2016, 11:52 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
« lib/coreUtils.js ('K') | « lib/filterNotifier.js ('k') | 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-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 /** 18 /**
19 * @fileOverview Definition of Subscription class and its subclasses. 19 * @fileOverview Definition of Subscription class and its subclasses.
20 */ 20 */
21 21
22 let {ActiveFilter, BlockingFilter, WhitelistFilter, ElemHideBase} = require("fil terClasses"); 22 let {ActiveFilter, BlockingFilter, WhitelistFilter, ElemHideBase} = require("fil terClasses");
23 let {FilterNotifier} = require("filterNotifier"); 23 let {FilterNotifier} = require("filterNotifier");
24 let {desc} = require("coreUtils");
24 25
25 /** 26 /**
26 * Abstract base class for filter subscriptions 27 * Abstract base class for filter subscriptions
27 * 28 *
28 * @param {String} url download location of the subscription 29 * @param {String} url download location of the subscription
29 * @param {String} [title] title of the filter subscription 30 * @param {String} [title] title of the filter subscription
30 * @constructor 31 * @constructor
31 */ 32 */
32 function Subscription(url, title) 33 function Subscription(url, title)
33 { 34 {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 * @param {String} [title] see Subscription() 223 * @param {String} [title] see Subscription()
223 * @constructor 224 * @constructor
224 * @augments Subscription 225 * @augments Subscription
225 */ 226 */
226 function SpecialSubscription(url, title) 227 function SpecialSubscription(url, title)
227 { 228 {
228 Subscription.call(this, url, title); 229 Subscription.call(this, url, title);
229 } 230 }
230 exports.SpecialSubscription = SpecialSubscription; 231 exports.SpecialSubscription = SpecialSubscription;
231 232
232 SpecialSubscription.prototype = 233 SpecialSubscription.prototype = Object.create(Subscription.prototype, desc({
233 {
234 __proto__: Subscription.prototype,
235
236 /** 234 /**
237 * Filter types that should be added to this subscription by default 235 * Filter types that should be added to this subscription by default
238 * (entries should correspond to keys in SpecialSubscription.defaultsMap). 236 * (entries should correspond to keys in SpecialSubscription.defaultsMap).
239 * @type string[] 237 * @type string[]
240 */ 238 */
241 defaults: null, 239 defaults: null,
242 240
243 /** 241 /**
244 * Tests whether a filter should be added to this group by default 242 * Tests whether a filter should be added to this group by default
245 * @param {Filter} filter filter to be tested 243 * @param {Filter} filter filter to be tested
(...skipping 19 matching lines...) Expand all
265 * See Subscription.serialize() 263 * See Subscription.serialize()
266 */ 264 */
267 serialize: function(buffer) 265 serialize: function(buffer)
268 { 266 {
269 Subscription.prototype.serialize.call(this, buffer); 267 Subscription.prototype.serialize.call(this, buffer);
270 if (this.defaults && this.defaults.length) 268 if (this.defaults && this.defaults.length)
271 buffer.push("defaults=" + this.defaults.filter((type) => type in SpecialSu bscription.defaultsMap).join(" ")); 269 buffer.push("defaults=" + this.defaults.filter((type) => type in SpecialSu bscription.defaultsMap).join(" "));
272 if (this._lastDownload) 270 if (this._lastDownload)
273 buffer.push("lastDownload=" + this._lastDownload); 271 buffer.push("lastDownload=" + this._lastDownload);
274 } 272 }
275 }; 273 }));
276 274
277 SpecialSubscription.defaultsMap = { 275 SpecialSubscription.defaultsMap = Object.create(null, desc({
278 __proto__: null,
279 "whitelist": WhitelistFilter, 276 "whitelist": WhitelistFilter,
280 "blocking": BlockingFilter, 277 "blocking": BlockingFilter,
281 "elemhide": ElemHideBase 278 "elemhide": ElemHideBase
282 }; 279 }));
283 280
284 /** 281 /**
285 * Creates a new user-defined filter group. 282 * Creates a new user-defined filter group.
286 * @param {String} [title] title of the new filter group 283 * @param {String} [title] title of the new filter group
287 * @result {SpecialSubscription} 284 * @result {SpecialSubscription}
288 */ 285 */
289 SpecialSubscription.create = function(title) 286 SpecialSubscription.create = function(title)
290 { 287 {
291 let url; 288 let url;
292 do 289 do
(...skipping 27 matching lines...) Expand all
320 * @param {String} [title] see Subscription() 317 * @param {String} [title] see Subscription()
321 * @constructor 318 * @constructor
322 * @augments Subscription 319 * @augments Subscription
323 */ 320 */
324 function RegularSubscription(url, title) 321 function RegularSubscription(url, title)
325 { 322 {
326 Subscription.call(this, url, title || url); 323 Subscription.call(this, url, title || url);
327 } 324 }
328 exports.RegularSubscription = RegularSubscription; 325 exports.RegularSubscription = RegularSubscription;
329 326
330 RegularSubscription.prototype = 327 RegularSubscription.prototype = Object.create(Subscription.prototype, desc({
331 {
332 __proto__: Subscription.prototype,
333
334 _homepage: null, 328 _homepage: null,
335 _lastDownload: 0, 329 _lastDownload: 0,
336 330
337 /** 331 /**
338 * Filter subscription homepage if known 332 * Filter subscription homepage if known
339 * @type String 333 * @type String
340 */ 334 */
341 get homepage() 335 homepage: {
342 { 336 get: function()
343 return this._homepage;
344 },
345 set homepage(value)
346 {
347 if (value != this._homepage)
348 { 337 {
349 let oldValue = this._homepage; 338 return this._homepage;
350 this._homepage = value; 339 },
351 FilterNotifier.triggerListeners("subscription.homepage", this, value, oldV alue); 340 set: function(value)
341 {
342 if (value != this._homepage)
343 {
344 let oldValue = this._homepage;
345 this._homepage = value;
346 FilterNotifier.triggerListeners("subscription.homepage", this, value, ol dValue);
347 }
348 return this._homepage;
352 } 349 }
353 return this._homepage;
354 }, 350 },
355 351
356 /** 352 /**
357 * Time of the last subscription download (in seconds since the beginning of t he epoch) 353 * Time of the last subscription download (in seconds since the beginning of t he epoch)
358 * @type Number 354 * @type Number
359 */ 355 */
360 get lastDownload() 356 lastDownload: {
361 { 357 get: function()
362 return this._lastDownload;
363 },
364 set lastDownload(value)
365 {
366 if (value != this._lastDownload)
367 { 358 {
368 let oldValue = this._lastDownload; 359 return this._lastDownload;
369 this._lastDownload = value; 360 },
370 FilterNotifier.triggerListeners("subscription.lastDownload", this, value, oldValue); 361 set: function(value)
362 {
363 if (value != this._lastDownload)
364 {
365 let oldValue = this._lastDownload;
366 this._lastDownload = value;
367 FilterNotifier.triggerListeners("subscription.lastDownload", this, value , oldValue);
368 }
369 return this._lastDownload;
371 } 370 }
372 return this._lastDownload;
373 }, 371 },
374 372
375 /** 373 /**
376 * See Subscription.serialize() 374 * See Subscription.serialize()
377 */ 375 */
378 serialize: function(buffer) 376 serialize: function(buffer)
379 { 377 {
380 Subscription.prototype.serialize.call(this, buffer); 378 Subscription.prototype.serialize.call(this, buffer);
381 if (this._homepage) 379 if (this._homepage)
382 buffer.push("homepage=" + this._homepage); 380 buffer.push("homepage=" + this._homepage);
383 if (this._lastDownload) 381 if (this._lastDownload)
384 buffer.push("lastDownload=" + this._lastDownload); 382 buffer.push("lastDownload=" + this._lastDownload);
385 } 383 }
386 }; 384 }));
387 385
388 /** 386 /**
389 * Class for filter subscriptions updated externally (by other extension) 387 * Class for filter subscriptions updated externally (by other extension)
390 * @param {String} url see Subscription() 388 * @param {String} url see Subscription()
391 * @param {String} [title] see Subscription() 389 * @param {String} [title] see Subscription()
392 * @constructor 390 * @constructor
393 * @augments RegularSubscription 391 * @augments RegularSubscription
394 */ 392 */
395 function ExternalSubscription(url, title) 393 function ExternalSubscription(url, title)
396 { 394 {
397 RegularSubscription.call(this, url, title); 395 RegularSubscription.call(this, url, title);
398 } 396 }
399 exports.ExternalSubscription = ExternalSubscription; 397 exports.ExternalSubscription = ExternalSubscription;
400 398
401 ExternalSubscription.prototype = 399 ExternalSubscription.prototype = Object.create(RegularSubscription.prototype, de sc({
402 {
403 __proto__: RegularSubscription.prototype,
404
405 /** 400 /**
406 * See Subscription.serialize() 401 * See Subscription.serialize()
407 */ 402 */
408 serialize: function(buffer) 403 serialize: function(buffer)
409 { 404 {
410 throw new Error("Unexpected call, external subscriptions should not be seria lized"); 405 throw new Error("Unexpected call, external subscriptions should not be seria lized");
411 } 406 }
412 }; 407 }));
413 408
414 /** 409 /**
415 * Class for filter subscriptions updated externally (by other extension) 410 * Class for filter subscriptions updated externally (by other extension)
416 * @param {String} url see Subscription() 411 * @param {String} url see Subscription()
417 * @param {String} [title] see Subscription() 412 * @param {String} [title] see Subscription()
418 * @constructor 413 * @constructor
419 * @augments RegularSubscription 414 * @augments RegularSubscription
420 */ 415 */
421 function DownloadableSubscription(url, title) 416 function DownloadableSubscription(url, title)
422 { 417 {
423 RegularSubscription.call(this, url, title); 418 RegularSubscription.call(this, url, title);
424 } 419 }
425 exports.DownloadableSubscription = DownloadableSubscription; 420 exports.DownloadableSubscription = DownloadableSubscription;
426 421
427 DownloadableSubscription.prototype = 422 DownloadableSubscription.prototype = Object.create(RegularSubscription.prototype , desc({
428 {
429 __proto__: RegularSubscription.prototype,
430
431 _downloadStatus: null, 423 _downloadStatus: null,
432 _lastCheck: 0, 424 _lastCheck: 0,
433 _errors: 0, 425 _errors: 0,
434 426
435 /** 427 /**
436 * Status of the last download (ID of a string) 428 * Status of the last download (ID of a string)
437 * @type String 429 * @type String
438 */ 430 */
439 get downloadStatus() 431 downloadStatus: {
440 { 432 get: function()
441 return this._downloadStatus; 433 {
442 }, 434 return this._downloadStatus;
443 set downloadStatus(value) 435 },
444 { 436 set: function(value)
445 let oldValue = this._downloadStatus; 437 {
446 this._downloadStatus = value; 438 let oldValue = this._downloadStatus;
447 FilterNotifier.triggerListeners("subscription.downloadStatus", this, value, oldValue); 439 this._downloadStatus = value;
448 return this._downloadStatus; 440 FilterNotifier.triggerListeners("subscription.downloadStatus", this, value , oldValue);
441 return this._downloadStatus;
442 }
449 }, 443 },
450 444
451 /** 445 /**
452 * Time of the last successful download (in seconds since the beginning of the 446 * Time of the last successful download (in seconds since the beginning of the
453 * epoch). 447 * epoch).
454 */ 448 */
455 lastSuccess: 0, 449 lastSuccess: 0,
456 450
457 /** 451 /**
458 * Time when the subscription was considered for an update last time (in secon ds 452 * Time when the subscription was considered for an update last time (in secon ds
459 * since the beginning of the epoch). This will be used to increase softExpira tion 453 * since the beginning of the epoch). This will be used to increase softExpira tion
460 * if the user doesn't use Adblock Plus for some time. 454 * if the user doesn't use Adblock Plus for some time.
461 * @type Number 455 * @type Number
462 */ 456 */
463 get lastCheck() 457 lastCheck: {
464 { 458 get: function()
465 return this._lastCheck;
466 },
467 set lastCheck(value)
468 {
469 if (value != this._lastCheck)
470 { 459 {
471 let oldValue = this._lastCheck; 460 return this._lastCheck;
472 this._lastCheck = value; 461 },
473 FilterNotifier.triggerListeners("subscription.lastCheck", this, value, old Value); 462 set: function(value)
463 {
464 if (value != this._lastCheck)
465 {
466 let oldValue = this._lastCheck;
467 this._lastCheck = value;
468 FilterNotifier.triggerListeners("subscription.lastCheck", this, value, o ldValue);
469 }
470 return this._lastCheck;
474 } 471 }
475 return this._lastCheck;
476 }, 472 },
477 473
478 /** 474 /**
479 * Hard expiration time of the filter subscription (in seconds since the begin ning of the epoch) 475 * Hard expiration time of the filter subscription (in seconds since the begin ning of the epoch)
480 * @type Number 476 * @type Number
481 */ 477 */
482 expires: 0, 478 expires: 0,
483 479
484 /** 480 /**
485 * Soft expiration time of the filter subscription (in seconds since the begin ning of the epoch) 481 * Soft expiration time of the filter subscription (in seconds since the begin ning of the epoch)
486 * @type Number 482 * @type Number
487 */ 483 */
488 softExpiration: 0, 484 softExpiration: 0,
489 485
490 /** 486 /**
491 * Number of download failures since last success 487 * Number of download failures since last success
492 * @type Number 488 * @type Number
493 */ 489 */
494 get errors() 490 errors: {
495 { 491 get: function()
496 return this._errors;
497 },
498 set errors(value)
499 {
500 if (value != this._errors)
501 { 492 {
502 let oldValue = this._errors; 493 return this._errors;
503 this._errors = value; 494 },
504 FilterNotifier.triggerListeners("subscription.errors", this, value, oldVal ue); 495 set: function(value)
496 {
497 if (value != this._errors)
498 {
499 let oldValue = this._errors;
500 this._errors = value;
501 FilterNotifier.triggerListeners("subscription.errors", this, value, oldV alue);
502 }
503 return this._errors;
505 } 504 }
506 return this._errors;
507 }, 505 },
508 506
509 /** 507 /**
510 * Version of the subscription data retrieved on last successful download 508 * Version of the subscription data retrieved on last successful download
511 * @type Number 509 * @type Number
512 */ 510 */
513 version: 0, 511 version: 0,
514 512
515 /** 513 /**
516 * Minimal Adblock Plus version required for this subscription 514 * Minimal Adblock Plus version required for this subscription
(...skipping 25 matching lines...) Expand all
542 buffer.push("softExpiration=" + this.softExpiration); 540 buffer.push("softExpiration=" + this.softExpiration);
543 if (this.errors) 541 if (this.errors)
544 buffer.push("errors=" + this.errors); 542 buffer.push("errors=" + this.errors);
545 if (this.version) 543 if (this.version)
546 buffer.push("version=" + this.version); 544 buffer.push("version=" + this.version);
547 if (this.requiredVersion) 545 if (this.requiredVersion)
548 buffer.push("requiredVersion=" + this.requiredVersion); 546 buffer.push("requiredVersion=" + this.requiredVersion);
549 if (this.downloadCount) 547 if (this.downloadCount)
550 buffer.push("downloadCount=" + this.downloadCount); 548 buffer.push("downloadCount=" + this.downloadCount);
551 } 549 }
552 }; 550 }));
OLDNEW
« lib/coreUtils.js ('K') | « lib/filterNotifier.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld