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: Make use of Object.getOwnPropertyDescriptor Created Sept. 2, 2016, 11:51 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
« 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 get homepage()
342 { 336 {
343 return this._homepage; 337 return this._homepage;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 * See Subscription.serialize() 370 * See Subscription.serialize()
377 */ 371 */
378 serialize: function(buffer) 372 serialize: function(buffer)
379 { 373 {
380 Subscription.prototype.serialize.call(this, buffer); 374 Subscription.prototype.serialize.call(this, buffer);
381 if (this._homepage) 375 if (this._homepage)
382 buffer.push("homepage=" + this._homepage); 376 buffer.push("homepage=" + this._homepage);
383 if (this._lastDownload) 377 if (this._lastDownload)
384 buffer.push("lastDownload=" + this._lastDownload); 378 buffer.push("lastDownload=" + this._lastDownload);
385 } 379 }
386 }; 380 }));
387 381
388 /** 382 /**
389 * Class for filter subscriptions updated externally (by other extension) 383 * Class for filter subscriptions updated externally (by other extension)
390 * @param {String} url see Subscription() 384 * @param {String} url see Subscription()
391 * @param {String} [title] see Subscription() 385 * @param {String} [title] see Subscription()
392 * @constructor 386 * @constructor
393 * @augments RegularSubscription 387 * @augments RegularSubscription
394 */ 388 */
395 function ExternalSubscription(url, title) 389 function ExternalSubscription(url, title)
396 { 390 {
397 RegularSubscription.call(this, url, title); 391 RegularSubscription.call(this, url, title);
398 } 392 }
399 exports.ExternalSubscription = ExternalSubscription; 393 exports.ExternalSubscription = ExternalSubscription;
400 394
401 ExternalSubscription.prototype = 395 ExternalSubscription.prototype = Object.create(RegularSubscription.prototype, de sc({
402 {
403 __proto__: RegularSubscription.prototype,
404
405 /** 396 /**
406 * See Subscription.serialize() 397 * See Subscription.serialize()
407 */ 398 */
408 serialize: function(buffer) 399 serialize: function(buffer)
409 { 400 {
410 throw new Error("Unexpected call, external subscriptions should not be seria lized"); 401 throw new Error("Unexpected call, external subscriptions should not be seria lized");
411 } 402 }
412 }; 403 }));
413 404
414 /** 405 /**
415 * Class for filter subscriptions updated externally (by other extension) 406 * Class for filter subscriptions updated externally (by other extension)
416 * @param {String} url see Subscription() 407 * @param {String} url see Subscription()
417 * @param {String} [title] see Subscription() 408 * @param {String} [title] see Subscription()
418 * @constructor 409 * @constructor
419 * @augments RegularSubscription 410 * @augments RegularSubscription
420 */ 411 */
421 function DownloadableSubscription(url, title) 412 function DownloadableSubscription(url, title)
422 { 413 {
423 RegularSubscription.call(this, url, title); 414 RegularSubscription.call(this, url, title);
424 } 415 }
425 exports.DownloadableSubscription = DownloadableSubscription; 416 exports.DownloadableSubscription = DownloadableSubscription;
426 417
427 DownloadableSubscription.prototype = 418 DownloadableSubscription.prototype = Object.create(RegularSubscription.prototype , desc({
428 {
429 __proto__: RegularSubscription.prototype,
430
431 _downloadStatus: null, 419 _downloadStatus: null,
432 _lastCheck: 0, 420 _lastCheck: 0,
433 _errors: 0, 421 _errors: 0,
434 422
435 /** 423 /**
436 * Status of the last download (ID of a string) 424 * Status of the last download (ID of a string)
437 * @type String 425 * @type String
438 */ 426 */
439 get downloadStatus() 427 get downloadStatus()
440 { 428 {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 buffer.push("softExpiration=" + this.softExpiration); 530 buffer.push("softExpiration=" + this.softExpiration);
543 if (this.errors) 531 if (this.errors)
544 buffer.push("errors=" + this.errors); 532 buffer.push("errors=" + this.errors);
545 if (this.version) 533 if (this.version)
546 buffer.push("version=" + this.version); 534 buffer.push("version=" + this.version);
547 if (this.requiredVersion) 535 if (this.requiredVersion)
548 buffer.push("requiredVersion=" + this.requiredVersion); 536 buffer.push("requiredVersion=" + this.requiredVersion);
549 if (this.downloadCount) 537 if (this.downloadCount)
550 buffer.push("downloadCount=" + this.downloadCount); 538 buffer.push("downloadCount=" + this.downloadCount);
551 } 539 }
552 }; 540 }));
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