Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotProxy.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotProxy.js b/third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotProxy.js |
| index f52f23b190cc2b6fadf78ddf80d29bfbbe7d786b..3d6a709f4c31e130a7769e494193469e1485e3aa 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotProxy.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotProxy.js |
| @@ -38,8 +38,10 @@ WebInspector.HeapSnapshotWorkerProxy = function(eventHandler) |
| this._eventHandler = eventHandler; |
| this._nextObjectId = 1; |
| this._nextCallId = 1; |
| - this._callbacks = []; |
| - this._previousCallbacks = []; |
| + /** @type {!Map<number, function(*)>} */ |
| + this._callbacks = new Map(); |
| + /** @type {!Map<number, boolean>} */ |
|
lushnikov
2016/03/04 22:49:18
Set?!
kozy
2016/03/04 23:18:50
Done.
|
| + this._previousCallbacks = new Map(); |
| this._worker = new WorkerRuntime.Worker("heap_snapshot_worker"); |
| this._worker.onmessage = this._messageReceived.bind(this); |
| } |
| @@ -73,7 +75,7 @@ WebInspector.HeapSnapshotWorkerProxy.prototype = { |
| evaluateForTest: function(script, callback) |
| { |
| var callId = this._nextCallId++; |
| - this._callbacks[callId] = callback; |
| + this._callbacks.set(callId, callback); |
| this._postMessage({callId: callId, disposition: "evaluateForTest", source: script}); |
| }, |
| @@ -100,7 +102,7 @@ WebInspector.HeapSnapshotWorkerProxy.prototype = { |
| } |
| if (callback) { |
| - this._callbacks[callId] = wrapCallback.bind(this); |
| + this._callbacks.set(callId, wrapCallback.bind(this)); |
| this._postMessage({callId: callId, disposition: "factory", objectId: objectId, methodName: methodName, methodArguments: methodArguments, newObjectId: newObjectId}); |
| return null; |
| } else { |
| @@ -119,7 +121,7 @@ WebInspector.HeapSnapshotWorkerProxy.prototype = { |
| var callId = this._nextCallId++; |
| var methodArguments = Array.prototype.slice.call(arguments, 3); |
| if (callback) |
| - this._callbacks[callId] = callback; |
| + this._callbacks.set(callId, callback); |
| this._postMessage({callId: callId, disposition: "method", objectId: objectId, methodName: methodName, methodArguments: methodArguments}); |
| }, |
| @@ -133,17 +135,13 @@ WebInspector.HeapSnapshotWorkerProxy.prototype = { |
| _checkLongRunningCalls: function() |
| { |
| - for (var callId in this._previousCallbacks) |
| - if (!(callId in this._callbacks)) |
| - delete this._previousCallbacks[callId]; |
| - var hasLongRunningCalls = false; |
| - for (callId in this._previousCallbacks) { |
| - hasLongRunningCalls = true; |
| - break; |
| - } |
| + for (var callId of this._previousCallbacks.keysArray()) |
| + if (!this._callbacks.has(callId)) |
| + this._previousCallbacks.delete(callId); |
| + var hasLongRunningCalls = this._previousCallbacks.size; |
|
lushnikov
2016/03/04 22:49:18
!!
kozy
2016/03/04 23:18:50
Done.
|
| this.dispatchEventToListeners("wait", hasLongRunningCalls); |
| - for (callId in this._callbacks) |
| - this._previousCallbacks[callId] = true; |
| + for (var callId of this._callbacks.keysArray()) |
| + this._previousCallbacks.set(callId, true); |
| }, |
| /** |
| @@ -161,13 +159,13 @@ WebInspector.HeapSnapshotWorkerProxy.prototype = { |
| if (data.errorMethodName) |
| WebInspector.console.error(WebInspector.UIString("An error occurred when a call to method '%s' was requested", data.errorMethodName)); |
| WebInspector.console.error(data["errorCallStack"]); |
| - delete this._callbacks[data.callId]; |
| + this._callbacks.delete(data.callId); |
| return; |
| } |
| - if (!this._callbacks[data.callId]) |
| + if (!this._callbacks.has(data.callId)) |
| return; |
| - var callback = this._callbacks[data.callId]; |
| - delete this._callbacks[data.callId]; |
| + var callback = this._callbacks.get(data.callId); |
| + this._callbacks.delete(data.callId); |
| callback(data.result); |
| }, |