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

Unified Diff: ext/background.js

Issue 29445648: Issue 5264 - Return page objects instead of page IDs (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created May 22, 2017, 3:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/background.js
===================================================================
--- a/ext/background.js
+++ b/ext/background.js
@@ -21,55 +21,56 @@
{
let nonEmptyPageMaps = new Set();
let PageMap = ext.PageMap = function()
{
this._map = new Map();
};
PageMap.prototype = {
- _delete(id)
+ _deleteByPageId(id)
{
- this._map.delete(id);
-
- if (this._map.size == 0)
- nonEmptyPageMaps.delete(this);
+ for (let page of this.keys().filter(page => page.id == id))
+ this.delete(page);
},
keys()
{
- return this._map.keys();
+ return Array.from(this._map.keys());
},
get(page)
{
- return this._map.get(page.id);
+ return this._map.get(page);
},
set(page, value)
{
- this._map.set(page.id, value);
+ this._map.set(page, value);
nonEmptyPageMaps.add(this);
},
has(page)
{
- return this._map.has(page.id);
+ return this._map.has(page);
},
clear()
{
this._map.clear();
nonEmptyPageMaps.delete(this);
},
delete(page)
{
- this._delete(page.id);
+ this._map.delete(page);
+
+ if (this._map.size == 0)
+ nonEmptyPageMaps.delete(this);
}
};
ext._removeFromAllPageMaps = pageId =>
{
for (let pageMap of nonEmptyPageMaps)
- pageMap._delete(pageId);
+ pageMap._deleteByPageId(pageId);
};
/* Pages */
let Page = ext.Page = function(tab)
{
this.id = tab.id;
this._url = tab.url && new URL(tab.url);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld