Ticket #139: remove_timeline.patch
File remove_timeline.patch, 21.8 KB (added by beelzy, on 05/20/2014 at 12:31:05 PM) |
---|
-
lib/contentPolicy.js
From c1a4cfc2cdd97b25ae0c2731739891e213482352 Mon Sep 17 00:00:00 2001 From: beelzy <beelzy@gmx.de> Date: Mon, 19 May 2014 12:52:43 +0200 Subject: [PATCH] removed references to Timeline and timeline.js Updated author information --- lib/contentPolicy.js | 10 ---- lib/elemHide.js | 19 ------- lib/filterListener.js | 8 --- lib/filterStorage.js | 21 ------- lib/io.js | 28 +-------- lib/main.js | 11 ---- lib/notification.js | 5 -- lib/synchronizer.js | 5 -- lib/timeline.js | 155 -------------------------------------------------- 9 files changed, 2 insertions(+), 260 deletions(-) delete mode 100644 lib/timeline.js diff --git a/lib/contentPolicy.js b/lib/contentPolicy.js index a06e6de..a63a6e3 100644
a b 22 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 23 23 Cu.import("resource://gre/modules/Services.jsm"); 24 24 25 let {TimeLine} = require("timeline");26 25 let {Utils} = require("utils"); 27 26 let {Prefs} = require("prefs"); 28 27 let {FilterStorage} = require("filterStorage"); … … let Policy = exports.Policy = 90 89 */ 91 90 init: function() 92 91 { 93 TimeLine.enter("Entered content policy initialization");94 95 92 // type constant by type description and type description by type constant 96 93 let iface = Ci.nsIContentPolicy; 97 94 for (let typeName of contentTypes) … … let Policy = exports.Policy = 120 117 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) 121 118 this.whitelistSchemes[scheme] = true; 122 119 123 TimeLine.log("done initializing types");124 125 120 // Generate class identifier used to collapse node and register corresponding 126 121 // stylesheet. 127 TimeLine.log("registering global stylesheet");128 129 122 let offset = "a".charCodeAt(0); 130 123 for (let i = 0; i < 20; i++) 131 124 collapsedClass += String.fromCharCode(offset + Math.random() * 26); … … let Policy = exports.Policy = 138 131 { 139 132 Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService.USER_SHEET); 140 133 }) 141 TimeLine.log("done registering stylesheet");142 143 TimeLine.leave("Done initializing content policy");144 134 }, 145 135 146 136 /** -
lib/elemHide.js
diff --git a/lib/elemHide.js b/lib/elemHide.js index b5a1473..37aa3b2 100644
a b let {Prefs} = require("prefs"); 27 27 let {ElemHideException} = require("filterClasses"); 28 28 let {FilterNotifier} = require("filterNotifier"); 29 29 let {AboutHandler} = require("elemHideHitRegistration"); 30 let {TimeLine} = require("timeline");31 30 32 31 /** 33 32 * Lookup table, filters by their associated key … … let ElemHide = exports.ElemHide = 82 81 */ 83 82 init: function() 84 83 { 85 TimeLine.enter("Entered ElemHide.init()");86 84 Prefs.addListener(function(name) 87 85 { 88 86 if (name == "enabled") … … let ElemHide = exports.ElemHide = 93 91 ElemHide.unapply(); 94 92 }); 95 93 96 TimeLine.log("done adding prefs listener");97 98 94 let styleFile = IO.resolveFilePath(Prefs.data_directory); 99 95 styleFile.append("elemhide.css"); 100 96 styleURL = Services.io.newFileURI(styleFile).QueryInterface(Ci.nsIFileURL); 101 TimeLine.log("done determining stylesheet URL");102 103 TimeLine.leave("ElemHide.init() done");104 97 }, 105 98 106 99 /** … … let ElemHide = exports.ElemHide = 220 213 return; 221 214 } 222 215 223 TimeLine.enter("Entered ElemHide.apply()");224 225 216 if (!ElemHide.isDirty || !Prefs.enabled) 226 217 { 227 218 // Nothing changed, looks like we merely got enabled/disabled … … let ElemHide = exports.ElemHide = 236 227 { 237 228 Cu.reportError(e); 238 229 } 239 TimeLine.log("Applying existing stylesheet finished");240 230 } 241 231 else if (!Prefs.enabled && ElemHide.applied) 242 232 { 243 233 ElemHide.unapply(); 244 TimeLine.log("ElemHide.unapply() finished");245 234 } 246 235 247 TimeLine.leave("ElemHide.apply() done (no file changes)");248 236 return; 249 237 } 250 238 251 239 IO.writeToFile(styleURL.file, this._generateCSSContent(), function(e) 252 240 { 253 TimeLine.enter("ElemHide.apply() write callback");254 241 this._applying = false; 255 242 256 243 // _generateCSSContent is throwing NS_ERROR_NOT_AVAILABLE to indicate that … … let ElemHide = exports.ElemHide = 275 262 ElemHide.isDirty = false; 276 263 277 264 ElemHide.unapply(); 278 TimeLine.log("ElemHide.unapply() finished");279 265 280 266 if (!noFilters) 281 267 { … … let ElemHide = exports.ElemHide = 288 274 { 289 275 Cu.reportError(e); 290 276 } 291 TimeLine.log("Applying stylesheet finished");292 277 } 293 278 294 279 FilterNotifier.triggerListeners("elemhideupdate"); 295 280 } 296 TimeLine.leave("ElemHide.apply() write callback done");297 281 }.bind(this), "ElemHideWrite"); 298 282 299 283 this._applying = true; 300 284 301 TimeLine.leave("ElemHide.apply() done", "ElemHideWrite");302 285 }, 303 286 304 287 _generateCSSContent: function() 305 288 { 306 289 // Grouping selectors by domains 307 TimeLine.log("start grouping selectors");308 290 let domains = {__proto__: null}; 309 291 let hasFilters = false; 310 292 for (let key in filterByKey) … … let ElemHide = exports.ElemHide = 323 305 list[filter.selector] = key; 324 306 hasFilters = true; 325 307 } 326 TimeLine.log("done grouping selectors");327 308 328 309 if (!hasFilters) 329 310 throw Cr.NS_ERROR_NOT_AVAILABLE; -
lib/filterListener.js
diff --git a/lib/filterListener.js b/lib/filterListener.js index 3b5a209..a9b75ea 100644
a b 22 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 23 23 Cu.import("resource://gre/modules/Services.jsm"); 24 24 25 let {TimeLine} = require("timeline");26 25 let {FilterStorage} = require("filterStorage"); 27 26 let {FilterNotifier} = require("filterNotifier"); 28 27 let {ElemHide} = require("elemHide"); … … let HistoryPurgeObserver = 103 102 */ 104 103 function init() 105 104 { 106 TimeLine.enter("Entered filter listener initialization()");107 108 105 FilterNotifier.addListener(function(action, item, newValue, oldValue) 109 106 { 110 107 let match = /^(\w+)\.(.*)/.exec(action); … … function init() 122 119 flushElemHide = function() {}; // No global stylesheet in Chrome & Co. 123 120 FilterStorage.loadFromDisk(); 124 121 125 TimeLine.log("done initializing data structures");126 127 122 Services.obs.addObserver(HistoryPurgeObserver, "browser:purge-session-history", true); 128 123 onShutdown.add(function() 129 124 { 130 125 Services.obs.removeObserver(HistoryPurgeObserver, "browser:purge-session-history"); 131 126 }); 132 TimeLine.log("done adding observers");133 134 TimeLine.leave("Filter listener initialization done");135 127 } 136 128 init(); 137 129 -
lib/filterStorage.js
diff --git a/lib/filterStorage.js b/lib/filterStorage.js index 01b7328..1ff66f7 100644
a b let {Filter, ActiveFilter} = require("filterClasses"); 29 29 let {Subscription, SpecialSubscription, ExternalSubscription} = require("subscriptionClasses"); 30 30 let {FilterNotifier} = require("filterNotifier"); 31 31 let {Utils} = require("utils"); 32 let {TimeLine} = require("timeline");33 32 34 33 /** 35 34 * Version number of the filter storage file format. … … let FilterStorage = exports.FilterStorage = 365 364 if (this._loading) 366 365 return; 367 366 368 TimeLine.enter("Entered FilterStorage.loadFromDisk()");369 367 this._loading = true; 370 368 371 369 let readFile = function(sourceFile, backupIndex) 372 370 { 373 TimeLine.enter("FilterStorage.loadFromDisk() -> readFile()");374 371 375 372 let parser = new INIParser(); 376 373 IO.readFromFile(sourceFile, parser, function(e) 377 374 { 378 TimeLine.enter("FilterStorage.loadFromDisk() read callback");379 375 if (!e && parser.subscriptions.length == 0) 380 376 { 381 377 // No filter subscriptions in the file, this isn't right. … … let FilterStorage = exports.FilterStorage = 403 399 else 404 400 doneReading(parser); 405 401 }); 406 TimeLine.leave("FilterStorage.loadFromDisk() read callback done");407 402 return; 408 403 } 409 404 } 410 405 doneReading(parser); 411 406 }.bind(this), "FilterStorageRead"); 412 407 413 TimeLine.leave("FilterStorage.loadFromDisk() <- readFile()", "FilterStorageRead");414 408 }.bind(this); 415 409 416 410 var doneReading = function(parser) … … let FilterStorage = exports.FilterStorage = 441 435 this.addFilter(filter, null, undefined, true); 442 436 } 443 437 } 444 TimeLine.log("Initializing data done, triggering observers")445 438 446 439 this._loading = false; 447 440 FilterNotifier.triggerListeners("load"); … … let FilterStorage = exports.FilterStorage = 449 442 if (sourceFile != this.sourceFile) 450 443 this.saveToDisk(); 451 444 452 TimeLine.leave("FilterStorage.loadFromDisk() read callback done");453 445 }.bind(this); 454 446 455 447 let explicitFile; … … let FilterStorage = exports.FilterStorage = 471 463 this._loading = false; 472 464 FilterNotifier.triggerListeners("load"); 473 465 474 TimeLine.leave("FilterStorage.loadFromDisk() read callback done");475 466 } 476 467 else 477 468 readFile(sourceFile, 0); … … let FilterStorage = exports.FilterStorage = 483 474 callback(true); 484 475 } 485 476 486 TimeLine.leave("FilterStorage.loadFromDisk() done");487 477 }, 488 478 489 479 _generateFilterData: function(subscriptions) … … let FilterStorage = exports.FilterStorage = 565 555 return; 566 556 } 567 557 568 TimeLine.enter("Entered FilterStorage.saveToDisk()");569 570 558 // Make sure the file's parent directory exists 571 559 try { 572 560 targetFile.parent.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); … … let FilterStorage = exports.FilterStorage = 574 562 575 563 let writeFilters = function() 576 564 { 577 TimeLine.enter("FilterStorage.saveToDisk() -> writeFilters()");578 565 IO.writeToFile(targetFile, this._generateFilterData(subscriptions), function(e) 579 566 { 580 TimeLine.enter("FilterStorage.saveToDisk() write callback");581 567 if (!explicitFile) 582 568 this._saving = false; 583 569 … … let FilterStorage = exports.FilterStorage = 591 577 } 592 578 else 593 579 FilterNotifier.triggerListeners("save"); 594 TimeLine.leave("FilterStorage.saveToDisk() write callback done");595 580 }.bind(this), "FilterStorageWrite"); 596 TimeLine.leave("FilterStorage.saveToDisk() -> writeFilters()", "FilterStorageWrite");597 581 }.bind(this); 598 582 599 583 let checkBackupRequired = function(callbackNotRequired, callbackRequired) … … let FilterStorage = exports.FilterStorage = 625 609 626 610 let removeLastBackup = function(part1, part2) 627 611 { 628 TimeLine.enter("FilterStorage.saveToDisk() -> removeLastBackup()");629 612 let file = targetFile.clone(); 630 613 file.leafName = part1 + "-backup" + Prefs.patternsbackups + part2; 631 614 IO.removeFile(file, function(e) renameBackup(part1, part2, Prefs.patternsbackups - 1)); 632 TimeLine.leave("FilterStorage.saveToDisk() <- removeLastBackup()");633 615 }.bind(this); 634 616 635 617 let renameBackup = function(part1, part2, index) 636 618 { 637 TimeLine.enter("FilterStorage.saveToDisk() -> renameBackup()");638 619 if (index > 0) 639 620 { 640 621 let fromFile = targetFile.clone(); … … let FilterStorage = exports.FilterStorage = 651 632 652 633 IO.copyFile(targetFile, toFile, writeFilters); 653 634 } 654 TimeLine.leave("FilterStorage.saveToDisk() <- renameBackup()");655 635 }.bind(this); 656 636 657 637 // Do not persist external subscriptions … … let FilterStorage = exports.FilterStorage = 661 641 662 642 checkBackupRequired(writeFilters, removeLastBackup); 663 643 664 TimeLine.leave("FilterStorage.saveToDisk() done");665 644 }, 666 645 667 646 /** -
lib/io.js
diff --git a/lib/io.js b/lib/io.js index aa2effc..5bdb2d7 100644
a b let {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm", null); 24 24 let {OS} = Cu.import("resource://gre/modules/osfile.jsm", null); 25 25 let {Task} = Cu.import("resource://gre/modules/Task.jsm", null); 26 26 27 let {TimeLine} = require("timeline");28 27 let {Utils} = require("utils"); 29 28 30 29 const BUFFER_SIZE = 0x8000; // 32kB … … let IO = exports.IO = 69 68 * each line read and with a null parameter once the read operation is done. 70 69 * The callback will be called when the operation is done. 71 70 */ 72 readFromFile: function(/**nsIFile*/ file, /**Object*/ listener, /**Function*/ callback , /**String*/ timeLineID)71 readFromFile: function(/**nsIFile*/ file, /**Object*/ listener, /**Function*/ callback) 73 72 { 74 73 try 75 74 { … … let IO = exports.IO = 80 79 81 80 let onProgress = function(data) 82 81 { 83 if (timeLineID)84 {85 TimeLine.asyncStart(timeLineID);86 }87 82 88 83 let index = (processing ? -1 : Math.max(data.lastIndexOf("\n"), data.lastIndexOf("\r"))); 89 84 if (index >= 0) … … let IO = exports.IO = 125 120 else 126 121 buffer += data; 127 122 128 if (timeLineID)129 {130 TimeLine.asyncEnd(timeLineID);131 }132 123 }; 133 124 134 125 let onSuccess = function() … … let IO = exports.IO = 140 131 return; 141 132 } 142 133 143 if (timeLineID)144 {145 TimeLine.asyncStart(timeLineID);146 }147 148 134 if (buffer !== "") 149 135 listener.process(buffer); 150 136 listener.process(null); 151 137 152 if (timeLineID)153 {154 TimeLine.asyncEnd(timeLineID);155 TimeLine.asyncDone(timeLineID);156 }157 158 138 callback(null); 159 139 }; 160 140 … … let IO = exports.IO = 169 149 170 150 callback(e); 171 151 172 if (timeLineID)173 {174 TimeLine.asyncDone(timeLineID);175 }176 152 }; 177 153 178 154 let decoder = new TextDecoder(); … … let IO = exports.IO = 206 182 * Writes string data to a file in UTF-8 format asynchronously. The callback 207 183 * will be called when the write operation is done. 208 184 */ 209 writeToFile: function(/**nsIFile*/ file, /**Iterator*/ data, /**Function*/ callback , /**String*/ timeLineID)185 writeToFile: function(/**nsIFile*/ file, /**Iterator*/ data, /**Function*/ callback) 210 186 { 211 187 try 212 188 { -
lib/main.js
diff --git a/lib/main.js b/lib/main.js index f18cc05..a065de0 100644
a b 22 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 23 23 Cu.import("resource://gre/modules/Services.jsm"); 24 24 25 let {TimeLine} = require("timeline");26 27 TimeLine.enter("Adblock Plus startup");28 25 registerPublicAPI(); 29 TimeLine.log("Done registering public API");30 26 require("filterListener"); 31 TimeLine.log("Done loading filter listener");32 27 require("contentPolicy"); 33 TimeLine.log("Done loading content policy");34 28 require("synchronizer"); 35 TimeLine.log("Done loading subscription synchronizer");36 29 require("notification"); 37 TimeLine.log("Done loading notification downloader");38 30 require("sync"); 39 TimeLine.log("Done loading sync support");40 31 require("ui"); 41 TimeLine.log("Done loading UI integration code");42 TimeLine.leave("Started up");43 32 44 33 function registerPublicAPI() 45 34 { -
lib/notification.js
diff --git a/lib/notification.js b/lib/notification.js index 06e949e..b00d24c 100644
a b 21 21 22 22 Cu.import("resource://gre/modules/Services.jsm"); 23 23 24 let {TimeLine} = require("timeline");25 24 let {Prefs} = require("prefs"); 26 25 let {Downloader, Downloadable, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY} = require("downloader"); 27 26 let {Utils} = require("utils"); … … let Notification = exports.Notification = 81 80 */ 82 81 init: function() 83 82 { 84 TimeLine.enter("Entered Notification.init()");85 86 83 downloader = new Downloader(this._getDownloadables.bind(this), INITIAL_DELAY, CHECK_INTERVAL); 87 84 onShutdown.add(function() 88 85 { … … let Notification = exports.Notification = 92 89 downloader.onExpirationChange = this._onExpirationChange.bind(this); 93 90 downloader.onDownloadSuccess = this._onDownloadSuccess.bind(this); 94 91 downloader.onDownloadError = this._onDownloadError.bind(this); 95 96 TimeLine.leave("Notification.init() done");97 92 }, 98 93 99 94 /** -
lib/synchronizer.js
diff --git a/lib/synchronizer.js b/lib/synchronizer.js index 590ad73..47e400e 100644
a b 22 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 23 23 Cu.import("resource://gre/modules/Services.jsm"); 24 24 25 let {TimeLine} = require("timeline");26 25 let {Downloader, Downloadable, 27 26 MILLIS_IN_SECOND, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY} = require("downloader"); 28 27 let {Filter, CommentFilter} = require("filterClasses"); … … let Synchronizer = exports.Synchronizer = 54 53 */ 55 54 init: function() 56 55 { 57 TimeLine.enter("Entered Synchronizer.init()");58 59 56 downloader = new Downloader(this._getDownloadables.bind(this), INITIAL_DELAY, CHECK_INTERVAL); 60 57 onShutdown.add(function() 61 58 { … … let Synchronizer = exports.Synchronizer = 66 63 downloader.onDownloadStarted = this._onDownloadStarted.bind(this); 67 64 downloader.onDownloadSuccess = this._onDownloadSuccess.bind(this); 68 65 downloader.onDownloadError = this._onDownloadError.bind(this); 69 70 TimeLine.leave("Synchronizer.init() done");71 66 }, 72 67 73 68 /** -
deleted file lib/timeline.js
diff --git a/lib/timeline.js b/lib/timeline.js deleted file mode 100644 index 18c10fb..0000000
+ - 1 /*2 * This file is part of Adblock Plus <http://adblockplus.org/>,3 * Copyright (C) 2006-2014 Eyeo GmbH4 *5 * Adblock Plus is free software: you can redistribute it and/or modify6 * it under the terms of the GNU General Public License version 3 as7 * published by the Free Software Foundation.8 *9 * Adblock Plus is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.13 *14 * You should have received a copy of the GNU General Public License15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.16 */17 18 /**19 * @fileOverview Debugging module used for load time measurements.20 */21 22 let nestingCounter = 0;23 let firstTimeStamp = null;24 let lastTimeStamp = null;25 26 let asyncActions = {__proto__: null};27 28 /**29 * Time logging module, used to measure startup time of Adblock Plus (development builds only).30 * @class31 */32 let TimeLine = exports.TimeLine = {33 /**34 * Logs an event to console together with the time it took to get there.35 */36 log: function(/**String*/ message, /**Boolean*/ _forceDisplay)37 {38 if (!_forceDisplay && nestingCounter <= 0)39 return;40 41 let now = Date.now();42 let diff = lastTimeStamp ? Math.round(now - lastTimeStamp) : "first event";43 lastTimeStamp = now;44 45 // Indent message depending on current nesting level46 for (let i = 0; i < nestingCounter; i++)47 message = "* " + message;48 49 // Pad message with spaces50 let padding = [];51 for (let i = message.toString().length; i < 80; i++)52 padding.push(" ");53 dump("[" + now + "] ABP timeline: " + message + padding.join("") + "\t (" + diff + ")\n");54 },55 56 /**57 * Called to indicate that application entered a block that needs to be timed.58 */59 enter: function(/**String*/ message)60 {61 if (nestingCounter <= 0)62 firstTimeStamp = Date.now();63 64 this.log(message, true);65 nestingCounter = (nestingCounter <= 0 ? 1 : nestingCounter + 1);66 },67 68 /**69 * Called when application exited a block that TimeLine.enter() was called for.70 * @param {String} message message to be logged71 * @param {String} [asyncAction] identifier of a pending async action72 */73 leave: function(message, asyncAction)74 {75 if (typeof asyncAction != "undefined")76 message += " (async action pending)";77 78 nestingCounter--;79 this.log(message, true);80 81 if (nestingCounter <= 0)82 {83 if (firstTimeStamp !== null)84 dump("ABP timeline: Total time elapsed: " + Math.round(Date.now() - firstTimeStamp) + "\n");85 firstTimeStamp = null;86 lastTimeStamp = null;87 }88 89 if (typeof asyncAction != "undefined")90 {91 if (asyncAction in asyncActions)92 dump("ABP timeline: Warning: Async action " + asyncAction + " already executing\n");93 asyncActions[asyncAction] = {start: Date.now(), total: 0};94 }95 },96 97 /**98 * Called when the application starts processing of an async action.99 */100 asyncStart: function(/**String*/ asyncAction)101 {102 if (asyncAction in asyncActions)103 {104 let action = asyncActions[asyncAction];105 if ("currentStart" in action)106 dump("ABP timeline: Warning: Processing reentered for async action " + asyncAction + "\n");107 action.currentStart = Date.now();108 }109 else110 dump("ABP timeline: Warning: Async action " + asyncAction + " is unknown\n");111 },112 113 /**114 * Called when the application finishes processing of an async action.115 */116 asyncEnd: function(/**String*/ asyncAction)117 {118 if (asyncAction in asyncActions)119 {120 let action = asyncActions[asyncAction];121 if ("currentStart" in action)122 {123 action.total += Date.now() - action.currentStart;124 delete action.currentStart;125 }126 else127 dump("ABP timeline: Warning: Processing not entered for async action " + asyncAction + "\n");128 }129 else130 dump("ABP timeline: Warning: Async action " + asyncAction + " is unknown\n");131 },132 133 /**134 * Called when an async action is done and its time can be logged.135 */136 asyncDone: function(/**String*/ asyncAction)137 {138 if (asyncAction in asyncActions)139 {140 let action = asyncActions[asyncAction];141 let now = Date.now();142 let diff = now - action.start;143 if ("currentStart" in action)144 dump("ABP timeline: Warning: Still processing for async action " + asyncAction + "\n");145 146 let message = "Async action " + asyncAction + " done";147 let padding = [];148 for (let i = message.toString().length; i < 80; i++)149 padding.push(" ");150 dump("[" + now + "] ABP timeline: " + message + padding.join("") + "\t (" + action.total + "/" + diff + ")\n");151 }152 else153 dump("ABP timeline: Warning: Async action " + asyncAction + " is unknown\n");154 }155 };