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

Side by Side Diff: Source/devtools/front_end/RuntimeModel.js

Issue 185463010: DevTools: Introduce Target class which holds connection & models (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@gr-RuntimeAgent
Patch Set: Created 6 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) 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.Object} 33 * @extends {WebInspector.Object}
34 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel 34 * @param {!WebInspector.Target} target
35 */ 35 */
36 WebInspector.RuntimeModel = function(resourceTreeModel) 36 WebInspector.RuntimeModel = function(target)
37 { 37 {
38 this._agent = RuntimeAgent; 38 this._agent = target.connection.agent("Runtime");
39 this._debuggerModel = WebInspector.debuggerModel; 39 this._debuggerModel = target.debuggerModel;
40 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes .FrameAdded, this._frameAdded, this); 40 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.FrameAdded, this._frameAdded, this);
41 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes .FrameNavigated, this._frameNavigated, this); 41 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.FrameNavigated, this._frameNavigated, this);
42 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes .FrameDetached, this._frameDetached, this); 42 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.FrameDetached, this._frameDetached, this);
43 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes .CachedResourcesLoaded, this._didLoadCachedResources, this); 43 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.CachedResourcesLoaded, this._didLoadCachedResources, this);
44 this._frameIdToContextList = {}; 44 this._frameIdToContextList = {};
45 target.connection.registerDispatcher("Runtime", new WebInspector.RuntimeDisp atcher(this));
45 } 46 }
46 47
47 WebInspector.RuntimeModel.Events = { 48 WebInspector.RuntimeModel.Events = {
48 FrameExecutionContextListAdded: "FrameExecutionContextListAdded", 49 FrameExecutionContextListAdded: "FrameExecutionContextListAdded",
49 FrameExecutionContextListRemoved: "FrameExecutionContextListRemoved", 50 FrameExecutionContextListRemoved: "FrameExecutionContextListRemoved",
50 } 51 }
51 52
52 WebInspector.RuntimeModel.prototype = { 53 WebInspector.RuntimeModel.prototype = {
53 /** 54 /**
54 * @param {?WebInspector.ExecutionContext} executionContext 55 * @param {?WebInspector.ExecutionContext} executionContext
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); 114 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data);
114 var context = this._frameIdToContextList[frame.id]; 115 var context = this._frameIdToContextList[frame.id];
115 if (!context) 116 if (!context)
116 return; 117 return;
117 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.FrameExec utionContextListRemoved, context); 118 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.FrameExec utionContextListRemoved, context);
118 delete this._frameIdToContextList[frame.id]; 119 delete this._frameIdToContextList[frame.id];
119 }, 120 },
120 121
121 _didLoadCachedResources: function() 122 _didLoadCachedResources: function()
122 { 123 {
123 InspectorBackend.registerRuntimeDispatcher(new WebInspector.RuntimeDispa tcher(this));
124 this._agent.enable(); 124 this._agent.enable();
125 }, 125 },
126 126
127 _executionContextCreated: function(context) 127 _executionContextCreated: function(context)
128 { 128 {
129 var contextList = this._frameIdToContextList[context.frameId]; 129 var contextList = this._frameIdToContextList[context.frameId];
130 console.assert(contextList); 130 console.assert(contextList);
131 contextList._addExecutionContext(new WebInspector.ExecutionContext(conte xt.id, context.name, context.isPageContext)); 131 contextList._addExecutionContext(new WebInspector.ExecutionContext(conte xt.id, context.name, context.isPageContext));
132 }, 132 },
133 133
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 /** 484 /**
485 * @return {string} 485 * @return {string}
486 */ 486 */
487 get displayName() 487 get displayName()
488 { 488 {
489 return this._frame.displayName(); 489 return this._frame.displayName();
490 }, 490 },
491 491
492 __proto__: WebInspector.Object.prototype 492 __proto__: WebInspector.Object.prototype
493 } 493 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698