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

Delta Between Two Patch Sets: webrequest.js

Issue 8756093: Fixed small memory leak (Closed)
Left Patch Set: Created Nov. 8, 2012, 1:18 p.m.
Right Patch Set: Created Nov. 8, 2012, 4:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of the Adblock Plus extension, 2 * This file is part of the Adblock Plus extension,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["http://* /*", "https://*/*"]}, ["blocking"]); 18 chrome.webRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: ["http://* /*", "https://*/*"]}, ["blocking"]);
19 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["http ://*/*", "https://*/*"]}, ["responseHeaders"]); 19 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["http ://*/*", "https://*/*"]}, ["responseHeaders"]);
20 chrome.tabs.onUpdated.addListener(forgetTab); 20 chrome.tabs.onUpdated.addListener(onUpdated);
Wladimir Palant 2012/11/08 13:28:06 I don't think that this will work like that. This
21 chrome.tabs.onRemoved.addListener(forgetTab); 21 chrome.tabs.onRemoved.addListener(forgetTab);
22 22
23 var onFilterChangeTimeout = null; 23 var onFilterChangeTimeout = null;
24 function onFilterChange() 24 function onFilterChange()
25 { 25 {
26 onFilterChangeTimeout = null; 26 onFilterChangeTimeout = null;
27 chrome.webRequest.handlerBehaviorChanged(); 27 chrome.webRequest.handlerBehaviorChanged();
28 } 28 }
29 29
30 var importantNotifications = { 30 var importantNotifications = {
(...skipping 12 matching lines...) Expand all
43 if (action in importantNotifications) 43 if (action in importantNotifications)
44 { 44 {
45 // Execute delayed to prevent multiple executions in a quick succession 45 // Execute delayed to prevent multiple executions in a quick succession
46 if (onFilterChangeTimeout != null) 46 if (onFilterChangeTimeout != null)
47 window.clearTimeout(onFilterChangeTimeout); 47 window.clearTimeout(onFilterChangeTimeout);
48 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000); 48 onFilterChangeTimeout = window.setTimeout(onFilterChange, 2000);
49 } 49 }
50 }); 50 });
51 51
52 var frames = {}; 52 var frames = {};
53
54 function onUpdated(tabId, changeInfo, tab)
55 {
56 var url = changeInfo.url;
57 if (url)
58 {
59 if (url.indexOf("#") > -1)
60 url = url.match(/^(.*?)#/) && RegExp.$1;
61 var lastURL = tabId in frames && frames[tabId].lastURL;
62 if (lastURL != url)
Wladimir Palant 2012/11/08 16:58:27 And now try window.history.pushState() to change U
63 {
64 if (lastURL)
65 forgetTab(tabId);
66
67 if (!(tabId in frames))
68 frames[tabId] = {};
69
70 frames[tabId].lastURL = url;
71 }
72 }
73 }
53 74
54 function onBeforeRequest(details) 75 function onBeforeRequest(details)
55 { 76 {
56 if (details.tabId == -1) 77 if (details.tabId == -1)
57 return {}; 78 return {};
58 79
59 var type = details.type; 80 var type = details.type;
60 if (type == "main_frame" || type == "sub_frame") 81 if (type == "main_frame" || type == "sub_frame")
61 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl); 82 recordFrame(details.tabId, details.frameId, details.parentFrameId, details.u rl);
62 83
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 parent = frameData.parent; 212 parent = frameData.parent;
192 parentData = getFrameData(tabId, parent); 213 parentData = getFrameData(tabId, parent);
193 214
194 var frameUrl = frameData.url; 215 var frameUrl = frameData.url;
195 var parentUrl = (parentData ? parentData.url : frameUrl); 216 var parentUrl = (parentData ? parentData.url : frameUrl);
196 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type)) 217 if ("keyException" in frameData || isWhitelisted(frameUrl, parentUrl, type))
197 return true; 218 return true;
198 } 219 }
199 return false; 220 return false;
200 } 221 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld