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

Side by Side Diff: ext/common.js

Issue 6751260996796416: Issue 1724 - Fixed memory leak in messaging code, when no response is sent, on Safari (Closed)
Patch Set: Created Jan. 8, 2015, 2:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 18
19 (function() 19 (function()
20 { 20 {
21 window.ext = {}; 21 window.ext = {};
22 22
23 var EventTarget = ext._EventTarget = function(cancelable) 23 var EventTarget = ext._EventTarget = function()
24 { 24 {
25 this._listeners = []; 25 this._listeners = [];
26 this._cancelable = cancelable;
27 }; 26 };
28 EventTarget.prototype = { 27 EventTarget.prototype = {
29 addListener: function(listener) 28 addListener: function(listener)
30 { 29 {
31 if (this._listeners.indexOf(listener) == -1) 30 if (this._listeners.indexOf(listener) == -1)
32 this._listeners.push(listener); 31 this._listeners.push(listener);
33 }, 32 },
34 removeListener: function(listener) 33 removeListener: function(listener)
35 { 34 {
36 var idx = this._listeners.indexOf(listener); 35 var idx = this._listeners.indexOf(listener);
37 if (idx != -1) 36 if (idx != -1)
38 this._listeners.splice(idx, 1); 37 this._listeners.splice(idx, 1);
39 }, 38 },
40 _dispatch: function() 39 _dispatch: function()
41 { 40 {
42 var result = null; 41 var results = [];
43 42
44 for (var i = 0; i < this._listeners.length; i++) 43 for (var i = 0; i < this._listeners.length; i++)
45 { 44 results.push(this._listeners[i].apply(null, arguments));
46 result = this._listeners[i].apply(null, arguments);
47 45
48 if (this._cancelable && result === false) 46 return results;
49 break;
50 }
51
52 return result;
53 } 47 }
54 }; 48 };
55 })(); 49 })();
OLDNEW
« no previous file with comments | « chrome/ext/background.js ('k') | safari/ext/background.js » ('j') | safari/ext/common.js » ('J')

Powered by Google App Engine
This is Rietveld