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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/Target.js

Issue 2109813003: [DevTools] No NetworkManager and NetworkLog for v8only mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass NetworkManager as a ctor parameter, to ensure proper initialization order. Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * @constructor 8 * @constructor
9 * @extends {Protocol.Agents} 9 * @extends {Protocol.Agents}
10 * @param {!WebInspector.TargetManager} targetManager 10 * @param {!WebInspector.TargetManager} targetManager
11 * @param {string} name 11 * @param {string} name
12 * @param {number} type 12 * @param {number} type
13 * @param {!InspectorBackendClass.Connection} connection 13 * @param {!InspectorBackendClass.Connection} connection
14 * @param {?WebInspector.Target} parentTarget 14 * @param {?WebInspector.Target} parentTarget
15 */ 15 */
16 WebInspector.Target = function(targetManager, name, type, connection, parentTarg et) 16 WebInspector.Target = function(targetManager, name, type, connection, parentTarg et)
17 { 17 {
18 Protocol.Agents.call(this, connection.agentsMap()); 18 Protocol.Agents.call(this, connection.agentsMap());
19 this._targetManager = targetManager; 19 this._targetManager = targetManager;
20 this._name = name; 20 this._name = name;
21 this._type = type; 21 this._type = type;
22 this._connection = connection; 22 this._connection = connection;
23 this._parentTarget = parentTarget; 23 this._parentTarget = parentTarget;
24 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne cted, this._onDisconnect, this); 24 connection.addEventListener(InspectorBackendClass.Connection.Events.Disconne cted, this._onDisconnect, this);
25 this._id = WebInspector.Target._nextId++; 25 this._id = WebInspector.Target._nextId++;
26 26
27 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */ 27 /** @type {!Map.<!Function, !WebInspector.SDKModel>} */
28 this._modelByConstructor = new Map(); 28 this._modelByConstructor = new Map();
29 /** @type {!Array<!{dispose: !Function}>} */
dgozman 2016/06/29 18:37:58 If we go for this, Disposable should be an interfa
eostroukhov-old 2016/06/29 22:54:20 Removed the array, listening to an event instead.
30 this.disposables = [];
29 } 31 }
30 32
31 /** 33 /**
32 * @enum {number} 34 * @enum {number}
33 */ 35 */
34 WebInspector.Target.Type = { 36 WebInspector.Target.Type = {
35 Page: 1, 37 Page: 1,
36 DedicatedWorker: 2, 38 DedicatedWorker: 2,
37 ServiceWorker: 4 39 ServiceWorker: 4,
40 V8Inspector: 8
dgozman 2016/06/29 18:37:58 I think it's better to use JS term instead of V8.
eostroukhov-old 2016/06/29 22:54:20 Done.
38 } 41 }
39 42
40 WebInspector.Target._nextId = 1; 43 WebInspector.Target._nextId = 1;
41 44
42 WebInspector.Target.prototype = { 45 WebInspector.Target.prototype = {
43 /** 46 /**
44 * @return {number} 47 * @return {number}
45 */ 48 */
46 id: function() 49 id: function()
47 { 50 {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 isPage: function() 102 isPage: function()
100 { 103 {
101 return this._type === WebInspector.Target.Type.Page; 104 return this._type === WebInspector.Target.Type.Page;
102 }, 105 },
103 106
104 /** 107 /**
105 * @return {boolean} 108 * @return {boolean}
106 */ 109 */
107 isWorker: function() 110 isWorker: function()
108 { 111 {
109 return this.isDedicatedWorker() || this.isServiceWorker(); 112 return this.isDedicatedWorker() || this.isServiceWorker() || this.isV8In spector();
110 }, 113 },
111 114
112 /** 115 /**
113 * @return {boolean} 116 * @return {boolean}
114 */ 117 */
115 isDedicatedWorker: function() 118 isDedicatedWorker: function()
116 { 119 {
117 return this._type === WebInspector.Target.Type.DedicatedWorker; 120 return this._type === WebInspector.Target.Type.DedicatedWorker;
118 }, 121 },
119 122
120 /** 123 /**
121 * @return {boolean} 124 * @return {boolean}
122 */ 125 */
123 isServiceWorker: function() 126 isServiceWorker: function()
124 { 127 {
125 return this._type === WebInspector.Target.Type.ServiceWorker; 128 return this._type === WebInspector.Target.Type.ServiceWorker;
126 }, 129 },
127 130
128 /** 131 /**
129 * @return {boolean} 132 * @return {boolean}
130 */ 133 */
134 isV8Inspector: function()
135 {
136 return this._type === WebInspector.Target.Type.V8Inspector;
137 },
138
139 /**
140 * @return {boolean}
141 */
131 hasJSContext: function() 142 hasJSContext: function()
132 { 143 {
133 return !this.isServiceWorker(); 144 return !this.isServiceWorker();
134 }, 145 },
135 146
136 /** 147 /**
137 * @return {?WebInspector.Target} 148 * @return {?WebInspector.Target}
138 */ 149 */
139 parentTarget: function() 150 parentTarget: function()
140 { 151 {
141 return this._parentTarget; 152 return this._parentTarget;
142 }, 153 },
143 154
144 _onDisconnect: function() 155 _onDisconnect: function()
145 { 156 {
146 this._targetManager.removeTarget(this); 157 this._targetManager.removeTarget(this);
147 this._dispose(); 158 this._dispose();
148 }, 159 },
149 160
150 _dispose: function() 161 _dispose: function()
151 { 162 {
152 this._targetManager.dispatchEventToListeners(WebInspector.TargetManager. Events.TargetDisposed, this); 163 this._targetManager.dispatchEventToListeners(WebInspector.TargetManager. Events.TargetDisposed, this);
153 this.networkManager.dispose();
154 this.cpuProfilerModel.dispose(); 164 this.cpuProfilerModel.dispose();
155 WebInspector.ServiceWorkerCacheModel.fromTarget(this).dispose(); 165 WebInspector.ServiceWorkerCacheModel.fromTarget(this).dispose();
156 if (this.workerManager) 166 if (this.workerManager)
157 this.workerManager.dispose(); 167 this.workerManager.dispose();
168 for (var disposable of this.disposables)
dgozman 2016/06/29 18:37:58 I think we can just listen for TargetDisposed even
eostroukhov-old 2016/06/29 22:54:20 Done.
169 disposable.dispose();
158 }, 170 },
159 171
160 /** 172 /**
161 * @return {boolean} 173 * @return {boolean}
162 */ 174 */
163 isDetached: function() 175 isDetached: function()
164 { 176 {
165 return this._connection.isClosed(); 177 return this._connection.isClosed();
166 }, 178 },
167 179
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 /** 244 /**
233 * @return {!Promise} 245 * @return {!Promise}
234 */ 246 */
235 resumeModel: function() 247 resumeModel: function()
236 { 248 {
237 return Promise.resolve(); 249 return Promise.resolve();
238 }, 250 },
239 251
240 __proto__: WebInspector.SDKObject.prototype 252 __proto__: WebInspector.SDKObject.prototype
241 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698