1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-02 10:24:59 +12:00

remove unused cookie code

This commit is contained in:
Ryan Hendrickson 2018-05-31 13:03:16 -04:00
parent a1c205949e
commit 03ed236489

View file

@ -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;
/******************************************************************************/
@ -259,24 +257,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) {
@ -328,17 +308,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() {
@ -438,16 +407,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; }
@ -577,8 +536,7 @@ vAPI.setTimeout(processClean, processCleanPeriod);
// Expose only what is necessary
return {
recordPageCookies: recordPageCookiesAsync,
removePageCookies: removePageCookiesAsync
recordPageCookies: recordPageCookiesAsync
};
/******************************************************************************/