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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/NetworkProject.js

Issue 2832943002: DevTools: properly handle target suspension/resuming in NetworkProject (Closed)
Patch Set: address comments Created 3 years, 7 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 copyright 8 * * Redistributions of source code must retain the above copyright
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 this._eventListeners.push( 81 this._eventListeners.push(
82 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Resour ceAdded, this._resourceAdded, this), 82 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.Resour ceAdded, this._resourceAdded, this),
83 resourceTreeModel.addEventListener( 83 resourceTreeModel.addEventListener(
84 SDK.ResourceTreeModel.Events.FrameWillNavigate, this._frameWillNav igate, this), 84 SDK.ResourceTreeModel.Events.FrameWillNavigate, this._frameWillNav igate, this),
85 resourceTreeModel.addEventListener( 85 resourceTreeModel.addEventListener(
86 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa vigated, this), 86 SDK.ResourceTreeModel.Events.MainFrameNavigated, this._mainFrameNa vigated, this),
87 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameD etached, this._frameDetached, this)); 87 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameD etached, this._frameDetached, this));
88 } 88 }
89 89
90 this._debuggerModel = target.model(SDK.DebuggerModel); 90 this._debuggerModel = target.model(SDK.DebuggerModel);
91 /** @type {!Set<!SDK.Script>} */
92 this._acceptedScripts = new Set();
91 if (this._debuggerModel) { 93 if (this._debuggerModel) {
92 var runtimeModel = this._debuggerModel.runtimeModel(); 94 var runtimeModel = this._debuggerModel.runtimeModel();
93 this._eventListeners.push( 95 this._eventListeners.push(
94 runtimeModel.addEventListener( 96 runtimeModel.addEventListener(
95 SDK.RuntimeModel.Events.ExecutionContextDestroyed, this._execution ContextDestroyed, this), 97 SDK.RuntimeModel.Events.ExecutionContextDestroyed, this._execution ContextDestroyed, this),
96 this._debuggerModel.addEventListener( 98 this._debuggerModel.addEventListener(
99 SDK.DebuggerModel.Events.GlobalObjectCleared, this._globalObjectCl eared, this),
100 this._debuggerModel.addEventListener(
97 SDK.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSou rce, this), 101 SDK.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSou rce, this),
98 this._debuggerModel.addEventListener( 102 this._debuggerModel.addEventListener(
99 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc riptSource, this)); 103 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedSc riptSource, this));
100 } 104 }
101 var cssModel = target.model(SDK.CSSModel); 105 var cssModel = target.model(SDK.CSSModel);
102 if (cssModel) { 106 if (cssModel) {
103 this._eventListeners.push( 107 this._eventListeners.push(
104 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetAdded, this._s tyleSheetAdded, this), 108 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetAdded, this._s tyleSheetAdded, this),
105 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, this. _styleSheetRemoved, this)); 109 cssModel.addEventListener(SDK.CSSModel.Events.StyleSheetRemoved, this. _styleSheetRemoved, this));
106 } 110 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return true; 278 return true;
275 } 279 }
276 280
277 /** 281 /**
278 * @param {!Common.Event} event 282 * @param {!Common.Event} event
279 */ 283 */
280 _parsedScriptSource(event) { 284 _parsedScriptSource(event) {
281 var script = /** @type {!SDK.Script} */ (event.data); 285 var script = /** @type {!SDK.Script} */ (event.data);
282 if (!this._acceptsScript(script)) 286 if (!this._acceptsScript(script))
283 return; 287 return;
288 this._acceptedScripts.add(script);
284 var originalContentProvider = script.originalContentProvider(); 289 var originalContentProvider = script.originalContentProvider();
285 var frameId = Bindings.frameIdForScript(script); 290 var frameId = Bindings.frameIdForScript(script);
286 script[Bindings.NetworkProject._frameIdSymbol] = frameId; 291 script[Bindings.NetworkProject._frameIdSymbol] = frameId;
287 var uiSourceCode = this._createFile(originalContentProvider, frameId, script .isContentScript()); 292 var uiSourceCode = this._createFile(originalContentProvider, frameId, script .isContentScript());
288 uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script; 293 uiSourceCode[Bindings.NetworkProject._scriptSymbol] = script;
289 var metadata = this._fetchMetadata(frameId, uiSourceCode.url()); 294 var metadata = this._fetchMetadata(frameId, uiSourceCode.url());
290 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, met adata); 295 this._addUISourceCodeWithProvider(uiSourceCode, originalContentProvider, met adata);
291 } 296 }
292 297
293 /** 298 /**
294 * @param {!Common.Event} event 299 * @param {!Common.Event} event
295 */ 300 */
296 _executionContextDestroyed(event) { 301 _executionContextDestroyed(event) {
297 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data); 302 var executionContext = /** @type {!SDK.ExecutionContext} */ (event.data);
298 var scripts = this._debuggerModel.scriptsForExecutionContext(executionContex t); 303 var scripts = this._debuggerModel.scriptsForExecutionContext(executionContex t);
304 this._removeScripts(scripts);
305 }
306
307 /**
308 * @param {!Array<!SDK.Script>} scripts
309 */
310 _removeScripts(scripts) {
299 for (var script of scripts) { 311 for (var script of scripts) {
300 if (!this._acceptsScript(script)) 312 if (!this._acceptedScripts.has(script))
301 continue; 313 continue;
314 this._acceptedScripts.delete(script);
302 var frameId = script[Bindings.NetworkProject._frameIdSymbol]; 315 var frameId = script[Bindings.NetworkProject._frameIdSymbol];
303 this._removeFileForURL(script.contentURL(), frameId, script.isContentScrip t()); 316 this._removeFileForURL(script.contentURL(), frameId, script.isContentScrip t());
304 } 317 }
305 } 318 }
306 319
307 /** 320 /**
321 * @param {!Common.Event} event
322 */
323 _globalObjectCleared(event) {
324 this._removeScripts(Array.from(this._acceptedScripts));
325 }
326
327 /**
308 * @param {!SDK.CSSStyleSheetHeader} header 328 * @param {!SDK.CSSStyleSheetHeader} header
309 */ 329 */
310 _acceptsHeader(header) { 330 _acceptsHeader(header) {
311 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' ) 331 if (header.isInline && !header.hasSourceURL && header.origin !== 'inspector' )
312 return false; 332 return false;
313 if (!header.resourceURL()) 333 if (!header.resourceURL())
314 return false; 334 return false;
315 return true; 335 return true;
316 } 336 }
317 337
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 }; 515 };
496 516
497 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject'); 517 Bindings.NetworkProject._networkProjectSymbol = Symbol('networkProject');
498 Bindings.NetworkProject._resourceSymbol = Symbol('resource'); 518 Bindings.NetworkProject._resourceSymbol = Symbol('resource');
499 Bindings.NetworkProject._scriptSymbol = Symbol('script'); 519 Bindings.NetworkProject._scriptSymbol = Symbol('script');
500 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet'); 520 Bindings.NetworkProject._styleSheetSymbol = Symbol('styleSheet');
501 Bindings.NetworkProject._targetSymbol = Symbol('target'); 521 Bindings.NetworkProject._targetSymbol = Symbol('target');
502 Bindings.NetworkProject._frameIdSymbol = Symbol('frameid'); 522 Bindings.NetworkProject._frameIdSymbol = Symbol('frameid');
503 523
504 Bindings.NetworkProject._frameAttributionSymbol = Symbol('Bindings.NetworkProjec t._frameAttributionSymbol'); 524 Bindings.NetworkProject._frameAttributionSymbol = Symbol('Bindings.NetworkProjec t._frameAttributionSymbol');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698