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

Side by Side Diff: lib/filterStorage.js

Issue 4831974724206592: Issue 192 - Clean up from #153 (Closed)
Patch Set: Created April 14, 2014, 6:56 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
« no previous file with comments | « lib/elemHide.js ('k') | lib/io.js » ('j') | 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 <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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return; 366 return;
367 367
368 TimeLine.enter("Entered FilterStorage.loadFromDisk()"); 368 TimeLine.enter("Entered FilterStorage.loadFromDisk()");
369 this._loading = true; 369 this._loading = true;
370 370
371 let readFile = function(sourceFile, backupIndex) 371 let readFile = function(sourceFile, backupIndex)
372 { 372 {
373 TimeLine.enter("FilterStorage.loadFromDisk() -> readFile()"); 373 TimeLine.enter("FilterStorage.loadFromDisk() -> readFile()");
374 374
375 let parser = new INIParser(); 375 let parser = new INIParser();
376 IO.readFromFile(sourceFile, true, parser, function(e) 376 IO.readFromFile(sourceFile, parser, function(e)
377 { 377 {
378 TimeLine.enter("FilterStorage.loadFromDisk() read callback"); 378 TimeLine.enter("FilterStorage.loadFromDisk() read callback");
379 if (!e && parser.subscriptions.length == 0) 379 if (!e && parser.subscriptions.length == 0)
380 { 380 {
381 // No filter subscriptions in the file, this isn't right. 381 // No filter subscriptions in the file, this isn't right.
382 e = new Error("No data in the file"); 382 e = new Error("No data in the file");
383 } 383 }
384 384
385 if (e) 385 if (e)
386 Cu.reportError(e); 386 Cu.reportError(e);
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 TimeLine.enter("Entered FilterStorage.saveToDisk()"); 568 TimeLine.enter("Entered FilterStorage.saveToDisk()");
569 569
570 // Make sure the file's parent directory exists 570 // Make sure the file's parent directory exists
571 try { 571 try {
572 targetFile.parent.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECT ORY); 572 targetFile.parent.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECT ORY);
573 } catch (e) {} 573 } catch (e) {}
574 574
575 let writeFilters = function() 575 let writeFilters = function()
576 { 576 {
577 TimeLine.enter("FilterStorage.saveToDisk() -> writeFilters()"); 577 TimeLine.enter("FilterStorage.saveToDisk() -> writeFilters()");
578 IO.writeToFile(targetFile, true, this._generateFilterData(subscriptions), function(e) 578 IO.writeToFile(targetFile, this._generateFilterData(subscriptions), functi on(e)
579 { 579 {
580 TimeLine.enter("FilterStorage.saveToDisk() write callback"); 580 TimeLine.enter("FilterStorage.saveToDisk() write callback");
581 if (!explicitFile) 581 if (!explicitFile)
582 this._saving = false; 582 this._saving = false;
583 583
584 if (e) 584 if (e)
585 Cu.reportError(e); 585 Cu.reportError(e);
586 586
587 if (!explicitFile && this._needsSave) 587 if (!explicitFile && this._needsSave)
588 { 588 {
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 Subscription.knownSubscriptions = origKnownSubscriptions; 885 Subscription.knownSubscriptions = origKnownSubscriptions;
886 } 886 }
887 887
888 // Allow events to be processed every now and then. 888 // Allow events to be processed every now and then.
889 // Note: IO.readFromFile() will deal with the potential reentrance here. 889 // Note: IO.readFromFile() will deal with the potential reentrance here.
890 this.linesProcessed++; 890 this.linesProcessed++;
891 if (this.linesProcessed % 1000 == 0) 891 if (this.linesProcessed % 1000 == 0)
892 Utils.yield(); 892 Utils.yield();
893 } 893 }
894 }; 894 };
OLDNEW
« no previous file with comments | « lib/elemHide.js ('k') | lib/io.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld