Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/Object.js

Issue 2298473003: DevTools: do not leak memory through event listeners (Closed)
Patch Set: cleanup - some clients have being cleaning event listeners Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 /** 161 /**
162 * @param {!Array<!WebInspector.EventTarget.EventDescriptor>} eventList 162 * @param {!Array<!WebInspector.EventTarget.EventDescriptor>} eventList
163 */ 163 */
164 WebInspector.EventTarget.removeEventListeners = function(eventList) 164 WebInspector.EventTarget.removeEventListeners = function(eventList)
165 { 165 {
166 for (var i = 0; i < eventList.length; ++i) { 166 for (var i = 0; i < eventList.length; ++i) {
167 var eventInfo = eventList[i]; 167 var eventInfo = eventList[i];
168 eventInfo.eventTarget.removeEventListener(eventInfo.eventType, eventInfo .method, eventInfo.receiver); 168 eventInfo.eventTarget.removeEventListener(eventInfo.eventType, eventInfo .method, eventInfo.receiver);
169 } 169 }
170 // Do not hold references on unused event descriptors.
171 eventList.splice(0, eventList.length);
170 } 172 }
171 173
172 WebInspector.EventTarget.prototype = { 174 WebInspector.EventTarget.prototype = {
173 /** 175 /**
174 * @param {string|symbol} eventType 176 * @param {string|symbol} eventType
175 * @param {function(!WebInspector.Event)} listener 177 * @param {function(!WebInspector.Event)} listener
176 * @param {!Object=} thisObject 178 * @param {!Object=} thisObject
177 * @return {!WebInspector.EventTarget.EventDescriptor} 179 * @return {!WebInspector.EventTarget.EventDescriptor}
178 */ 180 */
179 addEventListener: function(eventType, listener, thisObject) { }, 181 addEventListener: function(eventType, listener, thisObject) { },
(...skipping 28 matching lines...) Expand all
208 * @param {(!Object|undefined)} receiver 210 * @param {(!Object|undefined)} receiver
209 * @param {function(?):?} method 211 * @param {function(?):?} method
210 */ 212 */
211 WebInspector.EventTarget.EventDescriptor = function(eventTarget, eventType, rece iver, method) 213 WebInspector.EventTarget.EventDescriptor = function(eventTarget, eventType, rece iver, method)
212 { 214 {
213 this.eventTarget = eventTarget; 215 this.eventTarget = eventTarget;
214 this.eventType = eventType; 216 this.eventType = eventType;
215 this.receiver = receiver; 217 this.receiver = receiver;
216 this.method = method; 218 this.method = method;
217 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698