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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js

Issue 2795193003: DevTools: carefully cleanup script UISourceCodes (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js
index 657d96b6bdd6a58aa2b452f7f7bababdbb69889b..de8325dce00f3b77a455d466fe60c09674335d3c 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/DebuggerModel.js
@@ -49,8 +49,8 @@ SDK.DebuggerModel = class extends SDK.SDKModel {
/** @type {?SDK.DebuggerPausedDetails} */
this._debuggerPausedDetails = null;
- /** @type {!Object.<string, !SDK.Script>} */
- this._scripts = {};
+ /** @type {!Map<string, !SDK.Script>} */
+ this._scripts = new Map();
dgozman 2017/04/05 18:22:55 Is it as performant? We have a lot of scripts!
lushnikov 2017/04/06 03:32:35 According to https://docs.google.com/spreadsheets
/** @type {!Map.<string, !Array.<!SDK.Script>>} */
this._scriptsBySourceURL = new Map();
/** @type {!Array.<!SDK.Script>} */
@@ -345,17 +345,17 @@ SDK.DebuggerModel = class extends SDK.SDKModel {
this._sourceMapManager.detachSourceMap(scriptWithSourceMap);
this._sourceMapIdToScript.clear();
- this._scripts = {};
+ this._scripts.clear();
this._scriptsBySourceURL.clear();
this._stringMap.clear();
this._discardableScripts = [];
}
/**
- * @return {!Object.<string, !SDK.Script>}
+ * @return {!Array<!SDK.Script>}
*/
- get scripts() {
- return this._scripts;
+ scripts() {
+ return Array.from(this._scripts.values());
dgozman 2017/04/05 18:22:55 Is this method performance-critical? Does it make
lushnikov 2017/04/06 03:32:35 No, it's used by blackbox model only
}
/**
@@ -363,7 +363,7 @@ SDK.DebuggerModel = class extends SDK.SDKModel {
* @return {?SDK.Script}
*/
scriptForId(scriptId) {
- return this._scripts[scriptId] || null;
+ return this._scripts.get(scriptId) || null;
}
/**
@@ -381,7 +381,8 @@ SDK.DebuggerModel = class extends SDK.SDKModel {
* @param {function(?Protocol.Error, !Protocol.Runtime.ExceptionDetails=)} callback
*/
setScriptSource(scriptId, newSource, callback) {
- this._scripts[scriptId].editSource(newSource, this._didEditScriptSource.bind(this, scriptId, newSource, callback));
+ this._scripts.get(scriptId).editSource(
+ newSource, this._didEditScriptSource.bind(this, scriptId, newSource, callback));
}
/**
@@ -567,13 +568,19 @@ SDK.DebuggerModel = class extends SDK.SDKModel {
this._sourceMapManager.detachSourceMap(script);
}
}
+ var affectedScripts = [];
+ for (var script of this._scripts.values()) {
+ if (script.executionContextId === executionContext.id)
+ affectedScripts.push(script);
+ }
+ this.dispatchEventToListeners(SDK.DebuggerModel.Events.ExecutionContextDestroyed, affectedScripts);
}
/**
* @param {!SDK.Script} script
*/
_registerScript(script) {
- this._scripts[script.scriptId] = script;
+ this._scripts.set(script.scriptId, script);
if (script.isAnonymousScript())
return;
@@ -590,7 +597,7 @@ SDK.DebuggerModel = class extends SDK.SDKModel {
*/
_unregisterScript(script) {
console.assert(script.isAnonymousScript());
- delete this._scripts[script.scriptId];
+ this._scripts.delete(script.scriptId);
}
_collectDiscardedScripts() {
@@ -918,6 +925,7 @@ SDK.DebuggerModel.Events = {
DebuggerWasDisabled: Symbol('DebuggerWasDisabled'),
DebuggerPaused: Symbol('DebuggerPaused'),
DebuggerResumed: Symbol('DebuggerResumed'),
+ ExecutionContextDestroyed: Symbol('ExecutionContextDestroyed'),
dgozman 2017/04/05 18:22:55 DiscardedScriptSources, and merge with DiscardedAn
lushnikov 2017/04/06 03:32:35 As discussed offline, i'm started to listen to Run
ParsedScriptSource: Symbol('ParsedScriptSource'),
FailedToParseScriptSource: Symbol('FailedToParseScriptSource'),
DiscardedAnonymousScriptSource: Symbol('DiscardedAnonymousScriptSource'),

Powered by Google App Engine
This is Rietveld 408576698