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

Delta Between Two Patch Sets: safari/ext/common.js

Issue 6751260996796416: Issue 1724 - Fixed memory leak in messaging code, when no response is sent, on Safari (Closed)
Left Patch Set: Addressed comments Created Jan. 8, 2015, 2:35 p.m.
Right Patch Set: Prevent the request payload from being sent back with fallback responses Created Jan. 8, 2015, 3:57 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 | « safari/ext/background.js ('k') | 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 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
(...skipping 13 matching lines...) Expand all
24 this._messageDispatcher = messageDispatcher; 24 this._messageDispatcher = messageDispatcher;
25 this._responseCallbacks = {__proto__: null}; 25 this._responseCallbacks = {__proto__: null};
26 this._responseCallbackCounter = 0; 26 this._responseCallbackCounter = 0;
27 }; 27 };
28 MessageProxy.prototype = { 28 MessageProxy.prototype = {
29 _sendResponse: function(request, message) 29 _sendResponse: function(request, message)
30 { 30 {
31 var response = {}; 31 var response = {};
32 for (var prop in request) 32 for (var prop in request)
33 response[prop] = request[prop]; 33 response[prop] = request[prop];
34 if (typeof message != "undefined") 34 response.payload = message;
35 response.payload = message;
36 35
37 this._messageDispatcher.dispatchMessage("response", response); 36 this._messageDispatcher.dispatchMessage("response", response);
38 }, 37 },
39 handleRequest: function(request, sender) 38 handleRequest: function(request, sender)
40 { 39 {
41 if ("callbackId" in request) 40 if ("callbackId" in request)
42 { 41 {
43 var sent = false; 42 var sent = false;
44 var sendResponse = function(message) 43 var sendResponse = function(message)
45 { 44 {
(...skipping 16 matching lines...) Expand all
62 } 61 }
63 }, 62 },
64 handleResponse: function(response) 63 handleResponse: function(response)
65 { 64 {
66 var callbackId = response.callbackId; 65 var callbackId = response.callbackId;
67 var callback = this._responseCallbacks[callbackId]; 66 var callback = this._responseCallbacks[callbackId];
68 if (callback) 67 if (callback)
69 { 68 {
70 delete this._responseCallbacks[callbackId]; 69 delete this._responseCallbacks[callbackId];
71 70
72 if ("payload" in response) 71 if (typeof response.payload != "undefined")
73 callback(response.payload); 72 callback(response.payload);
74 } 73 }
75 }, 74 },
76 sendMessage: function(message, responseCallback, extra) 75 sendMessage: function(message, responseCallback, extra)
77 { 76 {
78 var request = {payload: message}; 77 var request = {payload: message};
79 78
80 if (responseCallback) 79 if (responseCallback)
81 { 80 {
82 request.callbackId = ++this._responseCallbackCounter; 81 request.callbackId = ++this._responseCallbackCounter;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 }; 211 };
213 212
214 213
215 /* Utils */ 214 /* Utils */
216 215
217 ext.getURL = function(path) 216 ext.getURL = function(path)
218 { 217 {
219 return safari.extension.baseURI + path; 218 return safari.extension.baseURI + path;
220 }; 219 };
221 })(); 220 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld