* remove unused field distinctRequestCount

* remove mostly unused RequestStats

* write to pageStore.pageUrl, not pageStore.normalURL

* remove unused cookie code

* remove unused field off
pull/2/head
Ryan Hendrickson 6 years ago committed by Raymond Hill
parent 130db1f351
commit 4d7109bf99

@ -32,53 +32,6 @@ var oneMinute = 60 * oneSecond;
var oneHour = 60 * oneMinute;
var oneDay = 24 * oneHour;
/******************************************************************************/
/******************************************************************************/
var _RequestStats = function() {
this.reset();
};
_RequestStats.prototype.reset = function() {
this.all =
this.doc =
this.frame =
this.script =
this.css =
this.image =
this.media =
this.xhr =
this.other =
this.cookie = 0;
};
/******************************************************************************/
var RequestStats = function() {
this.allowed = new _RequestStats();
this.blocked = new _RequestStats();
};
RequestStats.prototype.reset = function() {
this.blocked.reset();
this.allowed.reset();
};
RequestStats.prototype.record = function(type, blocked) {
// Remember: always test against **false**
if ( blocked !== false ) {
this.blocked[type] += 1;
this.blocked.all += 1;
} else {
this.allowed[type] += 1;
this.allowed.all += 1;
}
};
var requestStatsFactory = function() {
return new RequestStats();
};
/*******************************************************************************
SVG-based icons below were extracted from
@ -231,8 +184,6 @@ return {
ubiquitousBlacklist: null,
// various stats
requestStatsFactory: requestStatsFactory,
requestStats: requestStatsFactory(),
cookieRemovedCounter: 0,
localStorageRemovedCounter: 0,
cookieHeaderFoiledCounter: 0,

@ -40,14 +40,12 @@
var µm = µMatrix;
var recordPageCookiesQueue = new Map();
var removePageCookiesQueue = new Map();
var removeCookieQueue = new Set();
var cookieDict = new Map();
var cookieEntryJunkyard = [];
var processRemoveQueuePeriod = 2 * 60 * 1000;
var processCleanPeriod = 10 * 60 * 1000;
var processPageRecordQueueTimer = null;
var processPageRemoveQueueTimer = null;
/******************************************************************************/
@ -260,24 +258,6 @@ var recordPageCookie = (function() {
/******************************************************************************/
// Look for cookies to potentially remove for a specific web page
var removePageCookiesAsync = function(pageStats) {
// Hold onto pageStats objects so that it doesn't go away
// before we handle the job.
// rhill 2013-10-19: pageStats could be nil, for example, this can
// happens if a file:// ... makes an xmlHttpRequest
if ( !pageStats ) {
return;
}
removePageCookiesQueue.set(pageStats.pageUrl, pageStats);
if ( processPageRemoveQueueTimer === null ) {
processPageRemoveQueueTimer = vAPI.setTimeout(processPageRemoveQueue, 15 * 1000);
}
};
/******************************************************************************/
// Candidate for removal
var removeCookieAsync = function(cookieKey) {
@ -332,17 +312,6 @@ var processPageRecordQueue = function() {
/******************************************************************************/
var processPageRemoveQueue = function() {
processPageRemoveQueueTimer = null;
for ( var pageStore of removePageCookiesQueue.values() ) {
findAndRemovePageCookies(pageStore);
}
removePageCookiesQueue.clear();
};
/******************************************************************************/
// Effectively remove cookies.
var processRemoveQueue = function() {
@ -442,16 +411,6 @@ var findAndRecordPageCookies = function(pageStore) {
/******************************************************************************/
var findAndRemovePageCookies = function(pageStore) {
for ( var cookieKey of cookieDict.keys() ) {
if ( cookieMatchDomains(cookieKey, pageStore.allHostnamesString) ) {
removeCookieAsync(cookieKey);
}
}
};
/******************************************************************************/
var canRemoveCookie = function(cookieKey, srcHostnames) {
var cookieEntry = cookieDict.get(cookieKey);
if ( cookieEntry === undefined ) { return false; }
@ -587,8 +546,7 @@ vAPI.setTimeout(processClean, processCleanPeriod);
// Expose only what is necessary
return {
recordPageCookies: recordPageCookiesAsync,
removePageCookies: removePageCookiesAsync
recordPageCookies: recordPageCookiesAsync
};
/******************************************************************************/

@ -226,7 +226,7 @@ var matrixSnapshot = function(pageStore, details) {
let r = {
appVersion: vAPI.app.version,
blockedCount: pageStore.requestStats.blocked.all,
blockedCount: pageStore.perLoadBlockedRequestCount,
collapseAllDomains: µmuser.popupCollapseAllDomains,
collapseBlacklistedDomains: µmuser.popupCollapseBlacklistedDomains,
diff: [],

@ -104,8 +104,6 @@ var PageStore = function(tabContext) {
this.hostnameTypeCells = new Map();
this.domains = new Set();
this.blockedCollapsibles = new BlockedCollapsibles();
this.requestStats = µm.requestStatsFactory();
this.off = false;
this.init(tabContext);
};
@ -125,8 +123,6 @@ PageStore.prototype = {
this.domains.clear();
this.allHostnamesString = ' ';
this.blockedCollapsibles.reset();
this.requestStats.reset();
this.distinctRequestCount = 0;
this.perLoadAllowedRequestCount = 0;
this.perLoadBlockedRequestCount = 0;
this.perLoadBlockedReferrerCount = 0;
@ -232,15 +228,8 @@ PageStore.prototype = {
if ( uids.has(uid) ) { return; }
uids.add(uid);
// Count blocked/allowed requests
this.requestStats.record(type, block);
// https://github.com/gorhill/httpswitchboard/issues/306
// If it is recorded locally, record globally
µm.requestStats.record(type, block);
µm.updateBadgeAsync(this.tabId);
this.distinctRequestCount++;
this.mtxCountModifiedTime = Date.now();
if ( this.domains.has(hostname) === false ) {

@ -472,7 +472,7 @@ vAPI.tabs.registerListeners();
pageStore.pageHostname === tabContext.rootHostname
) {
pageStore.rawURL = tabContext.rawURL;
pageStore.normalURL = normalURL;
pageStore.pageUrl = normalURL;
this.updateTitle(tabId);
this.pageStoresToken = Date.now();
return pageStore;

Loading…
Cancel
Save