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

Side by Side Diff: lib/filterStorage.js

Issue 5731880649359360: Don't delay Firefox startup (Closed)
Patch Set: Created March 13, 2014, 1: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
« no previous file with comments | « no previous file | lib/io.js » ('j') | lib/io.js » ('J')
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 10 matching lines...) Expand all
21 21
22 Cu.import("resource://gre/modules/Services.jsm"); 22 Cu.import("resource://gre/modules/Services.jsm");
23 Cu.import("resource://gre/modules/FileUtils.jsm"); 23 Cu.import("resource://gre/modules/FileUtils.jsm");
24 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 24 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
25 25
26 let {IO} = require("io"); 26 let {IO} = require("io");
27 let {Prefs} = require("prefs"); 27 let {Prefs} = require("prefs");
28 let {Filter, ActiveFilter} = require("filterClasses"); 28 let {Filter, ActiveFilter} = require("filterClasses");
29 let {Subscription, SpecialSubscription, ExternalSubscription} = require("subscri ptionClasses"); 29 let {Subscription, SpecialSubscription, ExternalSubscription} = require("subscri ptionClasses");
30 let {FilterNotifier} = require("filterNotifier"); 30 let {FilterNotifier} = require("filterNotifier");
31 let {Utils} = require("utils");
31 let {TimeLine} = require("timeline"); 32 let {TimeLine} = require("timeline");
32 33
33 /** 34 /**
34 * Version number of the filter storage file format. 35 * Version number of the filter storage file format.
35 * @type Integer 36 * @type Integer
36 */ 37 */
37 let formatVersion = 4; 38 let formatVersion = 4;
38 39
39 /** 40 /**
40 * This class reads user's filters from disk, manages them in memory and writes them back. 41 * This class reads user's filters from disk, manages them in memory and writes them back.
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 */ 784 */
784 function INIParser() 785 function INIParser()
785 { 786 {
786 this.fileProperties = this.curObj = {}; 787 this.fileProperties = this.curObj = {};
787 this.subscriptions = []; 788 this.subscriptions = [];
788 this.knownFilters = {__proto__: null}; 789 this.knownFilters = {__proto__: null};
789 this.knownSubscriptions = {__proto__: null}; 790 this.knownSubscriptions = {__proto__: null};
790 } 791 }
791 INIParser.prototype = 792 INIParser.prototype =
792 { 793 {
794 linesProcessed: 0,
793 subscriptions: null, 795 subscriptions: null,
794 knownFilters: null, 796 knownFilters: null,
795 knownSubscrptions : null, 797 knownSubscriptions : null,
796 wantObj: true, 798 wantObj: true,
797 fileProperties: null, 799 fileProperties: null,
798 curObj: null, 800 curObj: null,
799 curSection: null, 801 curSection: null,
800 userFilters: null, 802 userFilters: null,
801 803
802 process: function(val) 804 process: function(val)
803 { 805 {
804 let origKnownFilters = Filter.knownFilters; 806 let origKnownFilters = Filter.knownFilters;
805 Filter.knownFilters = this.knownFilters; 807 Filter.knownFilters = this.knownFilters;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 } 872 }
871 } 873 }
872 else if (this.wantObj === false && val) 874 else if (this.wantObj === false && val)
873 this.curObj.push(val.replace(/\\\[/g, "[")); 875 this.curObj.push(val.replace(/\\\[/g, "["));
874 } 876 }
875 finally 877 finally
876 { 878 {
877 Filter.knownFilters = origKnownFilters; 879 Filter.knownFilters = origKnownFilters;
878 Subscription.knownSubscriptions = origKnownSubscriptions; 880 Subscription.knownSubscriptions = origKnownSubscriptions;
879 } 881 }
882
883 // Allow events to be processed every now and then.
884 // Note: IO.readFromFile() will deal with the potential reentrance here.
885 this.linesProcessed++;
886 if (this.linesProcessed % 1000 == 0)
887 Utils.yield();
880 } 888 }
881 }; 889 };
OLDNEW
« no previous file with comments | « no previous file | lib/io.js » ('j') | lib/io.js » ('J')

Powered by Google App Engine
This is Rietveld