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

Side by Side Diff: lib/filterStorage.js

Issue 5450822905233408: Issue 417 - Reinitializing removed filter lists (Core/Firefox) (Closed)
Patch Set: Created May 26, 2014, 10:22 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 filter.hitCount = 0; 352 filter.hitCount = 0;
353 filter.lastHit = 0; 353 filter.lastHit = 0;
354 } 354 }
355 }, 355 },
356 356
357 _loading: false, 357 _loading: false,
358 358
359 /** 359 /**
360 * Loads all subscriptions from the disk 360 * Loads all subscriptions from the disk
361 * @param {nsIFile} [sourceFile] File to read from 361 * @param {nsIFile} [sourceFile] File to read from
362 * @param {Function} [errorCallback] Function to be executed in case of an err or
362 */ 363 */
363 loadFromDisk: function(sourceFile) 364 loadFromDisk: function(sourceFile, errorCallback)
364 { 365 {
365 if (this._loading) 366 if (this._loading)
366 return; 367 return;
367 368
368 TimeLine.enter("Entered FilterStorage.loadFromDisk()"); 369 TimeLine.enter("Entered FilterStorage.loadFromDisk()");
369 this._loading = true; 370 this._loading = true;
370 371
371 let readFile = function(sourceFile, backupIndex) 372 let readFile = function(sourceFile, backupIndex)
372 { 373 {
373 TimeLine.enter("FilterStorage.loadFromDisk() -> readFile()"); 374 TimeLine.enter("FilterStorage.loadFromDisk() -> readFile()");
(...skipping 20 matching lines...) Expand all
394 let [, part1, part2] = /^(.*)(\.\w+)$/.exec(sourceFile.leafName) || [null, sourceFile.leafName, ""]; 395 let [, part1, part2] = /^(.*)(\.\w+)$/.exec(sourceFile.leafName) || [null, sourceFile.leafName, ""];
395 396
396 sourceFile = sourceFile.clone(); 397 sourceFile = sourceFile.clone();
397 sourceFile.leafName = part1 + "-backup" + (++backupIndex) + part2; 398 sourceFile.leafName = part1 + "-backup" + (++backupIndex) + part2;
398 399
399 IO.statFile(sourceFile, function(e, statData) 400 IO.statFile(sourceFile, function(e, statData)
400 { 401 {
401 if (!e && statData.exists) 402 if (!e && statData.exists)
402 readFile(sourceFile, backupIndex); 403 readFile(sourceFile, backupIndex);
403 else 404 else
404 doneReading(parser); 405 {
406 // The file is empty and loading the backup failed
407 if (typeof errorCallback == "function")
408 errorCallback();
409 else
410 doneReading(parser);
411 }
Wladimir Palant 2014/05/26 15:08:46 This callback is unnecessary and actually harmful
Thomas Greiner 2014/05/26 17:45:38 Done.
405 }); 412 });
406 TimeLine.leave("FilterStorage.loadFromDisk() read callback done"); 413 TimeLine.leave("FilterStorage.loadFromDisk() read callback done");
407 return; 414 return;
408 } 415 }
409 } 416 }
410 doneReading(parser); 417 doneReading(parser);
411 }.bind(this), "FilterStorageRead"); 418 }.bind(this), "FilterStorageRead");
412 419
413 TimeLine.leave("FilterStorage.loadFromDisk() <- readFile()", "FilterStorag eRead"); 420 TimeLine.leave("FilterStorage.loadFromDisk() <- readFile()", "FilterStorag eRead");
414 }.bind(this); 421 }.bind(this);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 Subscription.knownSubscriptions = origKnownSubscriptions; 892 Subscription.knownSubscriptions = origKnownSubscriptions;
886 } 893 }
887 894
888 // Allow events to be processed every now and then. 895 // Allow events to be processed every now and then.
889 // Note: IO.readFromFile() will deal with the potential reentrance here. 896 // Note: IO.readFromFile() will deal with the potential reentrance here.
890 this.linesProcessed++; 897 this.linesProcessed++;
891 if (this.linesProcessed % 1000 == 0) 898 if (this.linesProcessed % 1000 == 0)
892 Utils.yield(); 899 Utils.yield();
893 } 900 }
894 }; 901 };
OLDNEW
« lib/filterListener.js ('K') | « lib/filterListener.js ('k') | lib/ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld