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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotProxy.js

Issue 1763193002: [DevTools] Fix more frontend compiler errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@caseq-patch
Patch Set: Created 4 years, 9 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyrightdd 8 * * Redistributions of source code must retain the above copyrightdd
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 20 matching lines...) Expand all
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @param {function(string, *)} eventHandler 33 * @param {function(string, *)} eventHandler
34 * @extends {WebInspector.Object} 34 * @extends {WebInspector.Object}
35 */ 35 */
36 WebInspector.HeapSnapshotWorkerProxy = function(eventHandler) 36 WebInspector.HeapSnapshotWorkerProxy = function(eventHandler)
37 { 37 {
38 this._eventHandler = eventHandler; 38 this._eventHandler = eventHandler;
39 this._nextObjectId = 1; 39 this._nextObjectId = 1;
40 this._nextCallId = 1; 40 this._nextCallId = 1;
41 this._callbacks = []; 41 /** @type {!Map<number, function(*)>} */
42 this._previousCallbacks = []; 42 this._callbacks = new Map();
43 /** @type {!Map<number, boolean>} */
lushnikov 2016/03/04 22:49:18 Set?!
kozy 2016/03/04 23:18:50 Done.
44 this._previousCallbacks = new Map();
43 this._worker = new WorkerRuntime.Worker("heap_snapshot_worker"); 45 this._worker = new WorkerRuntime.Worker("heap_snapshot_worker");
44 this._worker.onmessage = this._messageReceived.bind(this); 46 this._worker.onmessage = this._messageReceived.bind(this);
45 } 47 }
46 48
47 WebInspector.HeapSnapshotWorkerProxy.prototype = { 49 WebInspector.HeapSnapshotWorkerProxy.prototype = {
48 /** 50 /**
49 * @param {number} profileUid 51 * @param {number} profileUid
50 * @param {function(!WebInspector.HeapSnapshotProxy)} snapshotReceivedCallba ck 52 * @param {function(!WebInspector.HeapSnapshotProxy)} snapshotReceivedCallba ck
51 * @return {!WebInspector.HeapSnapshotLoaderProxy} 53 * @return {!WebInspector.HeapSnapshotLoaderProxy}
52 */ 54 */
(...skipping 13 matching lines...) Expand all
66 }, 68 },
67 69
68 disposeObject: function(objectId) 70 disposeObject: function(objectId)
69 { 71 {
70 this._postMessage({callId: this._nextCallId++, disposition: "dispose", o bjectId: objectId}); 72 this._postMessage({callId: this._nextCallId++, disposition: "dispose", o bjectId: objectId});
71 }, 73 },
72 74
73 evaluateForTest: function(script, callback) 75 evaluateForTest: function(script, callback)
74 { 76 {
75 var callId = this._nextCallId++; 77 var callId = this._nextCallId++;
76 this._callbacks[callId] = callback; 78 this._callbacks.set(callId, callback);
77 this._postMessage({callId: callId, disposition: "evaluateForTest", sourc e: script}); 79 this._postMessage({callId: callId, disposition: "evaluateForTest", sourc e: script});
78 }, 80 },
79 81
80 /** 82 /**
81 * @param {?function(...?)} callback 83 * @param {?function(...?)} callback
82 * @param {string} objectId 84 * @param {string} objectId
83 * @param {string} methodName 85 * @param {string} methodName
84 * @param {function(new:T, ...?)} proxyConstructor 86 * @param {function(new:T, ...?)} proxyConstructor
85 * @return {?Object} 87 * @return {?Object}
86 * @template T 88 * @template T
87 */ 89 */
88 callFactoryMethod: function(callback, objectId, methodName, proxyConstructor ) 90 callFactoryMethod: function(callback, objectId, methodName, proxyConstructor )
89 { 91 {
90 var callId = this._nextCallId++; 92 var callId = this._nextCallId++;
91 var methodArguments = Array.prototype.slice.call(arguments, 4); 93 var methodArguments = Array.prototype.slice.call(arguments, 4);
92 var newObjectId = this._nextObjectId++; 94 var newObjectId = this._nextObjectId++;
93 95
94 /** 96 /**
95 * @this {WebInspector.HeapSnapshotWorkerProxy} 97 * @this {WebInspector.HeapSnapshotWorkerProxy}
96 */ 98 */
97 function wrapCallback(remoteResult) 99 function wrapCallback(remoteResult)
98 { 100 {
99 callback(remoteResult ? new proxyConstructor(this, newObjectId) : nu ll); 101 callback(remoteResult ? new proxyConstructor(this, newObjectId) : nu ll);
100 } 102 }
101 103
102 if (callback) { 104 if (callback) {
103 this._callbacks[callId] = wrapCallback.bind(this); 105 this._callbacks.set(callId, wrapCallback.bind(this));
104 this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId : newObjectId}); 106 this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId : newObjectId});
105 return null; 107 return null;
106 } else { 108 } else {
107 this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId : newObjectId}); 109 this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId : newObjectId});
108 return new proxyConstructor(this, newObjectId); 110 return new proxyConstructor(this, newObjectId);
109 } 111 }
110 }, 112 },
111 113
112 /** 114 /**
113 * @param {function(*)} callback 115 * @param {function(*)} callback
114 * @param {string} objectId 116 * @param {string} objectId
115 * @param {string} methodName 117 * @param {string} methodName
116 */ 118 */
117 callMethod: function(callback, objectId, methodName) 119 callMethod: function(callback, objectId, methodName)
118 { 120 {
119 var callId = this._nextCallId++; 121 var callId = this._nextCallId++;
120 var methodArguments = Array.prototype.slice.call(arguments, 3); 122 var methodArguments = Array.prototype.slice.call(arguments, 3);
121 if (callback) 123 if (callback)
122 this._callbacks[callId] = callback; 124 this._callbacks.set(callId, callback);
123 this._postMessage({callId: callId, disposition: "method", objectId: obje ctId, methodName: methodName, methodArguments: methodArguments}); 125 this._postMessage({callId: callId, disposition: "method", objectId: obje ctId, methodName: methodName, methodArguments: methodArguments});
124 }, 126 },
125 127
126 startCheckingForLongRunningCalls: function() 128 startCheckingForLongRunningCalls: function()
127 { 129 {
128 if (this._interval) 130 if (this._interval)
129 return; 131 return;
130 this._checkLongRunningCalls(); 132 this._checkLongRunningCalls();
131 this._interval = setInterval(this._checkLongRunningCalls.bind(this), 300 ); 133 this._interval = setInterval(this._checkLongRunningCalls.bind(this), 300 );
132 }, 134 },
133 135
134 _checkLongRunningCalls: function() 136 _checkLongRunningCalls: function()
135 { 137 {
136 for (var callId in this._previousCallbacks) 138 for (var callId of this._previousCallbacks.keysArray())
137 if (!(callId in this._callbacks)) 139 if (!this._callbacks.has(callId))
138 delete this._previousCallbacks[callId]; 140 this._previousCallbacks.delete(callId);
139 var hasLongRunningCalls = false; 141 var hasLongRunningCalls = this._previousCallbacks.size;
lushnikov 2016/03/04 22:49:18 !!
kozy 2016/03/04 23:18:50 Done.
140 for (callId in this._previousCallbacks) {
141 hasLongRunningCalls = true;
142 break;
143 }
144 this.dispatchEventToListeners("wait", hasLongRunningCalls); 142 this.dispatchEventToListeners("wait", hasLongRunningCalls);
145 for (callId in this._callbacks) 143 for (var callId of this._callbacks.keysArray())
146 this._previousCallbacks[callId] = true; 144 this._previousCallbacks.set(callId, true);
147 }, 145 },
148 146
149 /** 147 /**
150 * @param {!MessageEvent} event 148 * @param {!MessageEvent} event
151 */ 149 */
152 _messageReceived: function(event) 150 _messageReceived: function(event)
153 { 151 {
154 var data = event.data; 152 var data = event.data;
155 if (data.eventName) { 153 if (data.eventName) {
156 if (this._eventHandler) 154 if (this._eventHandler)
157 this._eventHandler(data.eventName, data.data); 155 this._eventHandler(data.eventName, data.data);
158 return; 156 return;
159 } 157 }
160 if (data.error) { 158 if (data.error) {
161 if (data.errorMethodName) 159 if (data.errorMethodName)
162 WebInspector.console.error(WebInspector.UIString("An error occur red when a call to method '%s' was requested", data.errorMethodName)); 160 WebInspector.console.error(WebInspector.UIString("An error occur red when a call to method '%s' was requested", data.errorMethodName));
163 WebInspector.console.error(data["errorCallStack"]); 161 WebInspector.console.error(data["errorCallStack"]);
164 delete this._callbacks[data.callId]; 162 this._callbacks.delete(data.callId);
165 return; 163 return;
166 } 164 }
167 if (!this._callbacks[data.callId]) 165 if (!this._callbacks.has(data.callId))
168 return; 166 return;
169 var callback = this._callbacks[data.callId]; 167 var callback = this._callbacks.get(data.callId);
170 delete this._callbacks[data.callId]; 168 this._callbacks.delete(data.callId);
171 callback(data.result); 169 callback(data.result);
172 }, 170 },
173 171
174 _postMessage: function(message) 172 _postMessage: function(message)
175 { 173 {
176 this._worker.postMessage(message); 174 this._worker.postMessage(message);
177 }, 175 },
178 176
179 __proto__: WebInspector.Object.prototype 177 __proto__: WebInspector.Object.prototype
180 } 178 }
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 * @param {!WebInspector.HeapSnapshotCommon.ComparatorConfig} comparator 570 * @param {!WebInspector.HeapSnapshotCommon.ComparatorConfig} comparator
573 * @return {!Promise<?>} 571 * @return {!Promise<?>}
574 */ 572 */
575 sortAndRewind: function(comparator) 573 sortAndRewind: function(comparator)
576 { 574 {
577 return this._callMethodPromise("sortAndRewind", comparator); 575 return this._callMethodPromise("sortAndRewind", comparator);
578 }, 576 },
579 577
580 __proto__: WebInspector.HeapSnapshotProxyObject.prototype 578 __proto__: WebInspector.HeapSnapshotProxyObject.prototype
581 } 579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698