OLD | NEW |
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 16 matching lines...) Expand all Loading... |
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 * @unrestricted | 32 * @unrestricted |
33 */ | 33 */ |
34 SDK.RuntimeModel = class extends SDK.SDKModel { | 34 SDK.RuntimeModel = class extends SDK.SDKModel { |
35 /** | 35 /** |
36 * @param {!SDK.Target} target | 36 * @param {!SDK.Target} target |
| 37 * @param {!Protocol.Dispatcher} dispatcher |
37 */ | 38 */ |
38 constructor(target) { | 39 constructor(target, dispatcher) { |
39 super(target); | 40 super(target, dispatcher); |
40 | 41 |
41 this._agent = target.runtimeAgent(); | 42 this._agent = dispatcher.runtimeAgent(); |
42 this.target().registerRuntimeDispatcher(new SDK.RuntimeDispatcher(this)); | 43 dispatcher.registerRuntimeDispatcher(new SDK.RuntimeDispatcher(this)); |
43 this._agent.enable(); | 44 this._agent.enable(); |
44 /** @type {!Map<number, !SDK.ExecutionContext>} */ | 45 /** @type {!Map<number, !SDK.ExecutionContext>} */ |
45 this._executionContextById = new Map(); | 46 this._executionContextById = new Map(); |
46 this._executionContextComparator = SDK.ExecutionContext.comparator; | 47 this._executionContextComparator = SDK.ExecutionContext.comparator; |
47 | 48 |
48 if (Common.moduleSetting('customFormatters').get()) | 49 if (Common.moduleSetting('customFormatters').get()) |
49 this._agent.setCustomObjectFormatterEnabled(true); | 50 this._agent.setCustomObjectFormatterEnabled(true); |
50 | 51 |
51 Common.moduleSetting('customFormatters').addChangeListener(this._customForma
ttersStateChanged.bind(this)); | 52 Common.moduleSetting('customFormatters').addChangeListener(this._customForma
ttersStateChanged.bind(this)); |
52 } | 53 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextDest
royed, contexts[i]); | 164 this.dispatchEventToListeners(SDK.RuntimeModel.Events.ExecutionContextDest
royed, contexts[i]); |
164 } | 165 } |
165 | 166 |
166 /** | 167 /** |
167 * @param {!Protocol.Runtime.RemoteObject} payload | 168 * @param {!Protocol.Runtime.RemoteObject} payload |
168 * @return {!SDK.RemoteObject} | 169 * @return {!SDK.RemoteObject} |
169 */ | 170 */ |
170 createRemoteObject(payload) { | 171 createRemoteObject(payload) { |
171 console.assert(typeof payload === 'object', 'Remote object payload should on
ly be an object'); | 172 console.assert(typeof payload === 'object', 'Remote object payload should on
ly be an object'); |
172 return new SDK.RemoteObjectImpl( | 173 return new SDK.RemoteObjectImpl( |
173 this, payload.objectId, payload.type, payload.subtype, payload.value, pa
yload.unserializableValue, | 174 this, this._agent, payload.objectId, payload.type, payload.subtype, payl
oad.value, payload.unserializableValue, |
174 payload.description, payload.preview, payload.customPreview); | 175 payload.description, payload.preview, payload.customPreview); |
175 } | 176 } |
176 | 177 |
177 /** | 178 /** |
178 * @param {!Protocol.Runtime.RemoteObject} payload | 179 * @param {!Protocol.Runtime.RemoteObject} payload |
179 * @param {!SDK.ScopeRef} scopeRef | 180 * @param {!SDK.ScopeRef} scopeRef |
180 * @return {!SDK.RemoteObject} | 181 * @return {!SDK.RemoteObject} |
181 */ | 182 */ |
182 createScopeRemoteObject(payload, scopeRef) { | 183 createScopeRemoteObject(payload, scopeRef) { |
183 return new SDK.ScopeRemoteObject( | 184 return new SDK.ScopeRemoteObject( |
184 this, payload.objectId, scopeRef, payload.type, payload.subtype, payload
.value, payload.unserializableValue, | 185 this, this._agent, payload.objectId, scopeRef, payload.type, payload.sub
type, payload.value, |
185 payload.description, payload.preview); | 186 payload.unserializableValue, payload.description, payload.preview); |
186 } | 187 } |
187 | 188 |
188 /** | 189 /** |
189 * @param {number|string|boolean|undefined} value | 190 * @param {number|string|boolean|undefined} value |
190 * @return {!SDK.RemoteObject} | 191 * @return {!SDK.RemoteObject} |
191 */ | 192 */ |
192 createRemoteObjectFromPrimitiveValue(value) { | 193 createRemoteObjectFromPrimitiveValue(value) { |
193 var type = typeof value; | 194 var type = typeof value; |
194 var unserializableValue = undefined; | 195 var unserializableValue = undefined; |
195 if (typeof value === 'number') { | 196 if (typeof value === 'number') { |
196 var description = String(value); | 197 var description = String(value); |
197 if (value === 0 && 1 / value < 0) | 198 if (value === 0 && 1 / value < 0) |
198 unserializableValue = Protocol.Runtime.UnserializableValue.Negative0; | 199 unserializableValue = Protocol.Runtime.UnserializableValue.Negative0; |
199 if (description === 'NaN') | 200 if (description === 'NaN') |
200 unserializableValue = Protocol.Runtime.UnserializableValue.NaN; | 201 unserializableValue = Protocol.Runtime.UnserializableValue.NaN; |
201 if (description === 'Infinity') | 202 if (description === 'Infinity') |
202 unserializableValue = Protocol.Runtime.UnserializableValue.Infinity; | 203 unserializableValue = Protocol.Runtime.UnserializableValue.Infinity; |
203 if (description === '-Infinity') | 204 if (description === '-Infinity') |
204 unserializableValue = Protocol.Runtime.UnserializableValue.NegativeInfin
ity; | 205 unserializableValue = Protocol.Runtime.UnserializableValue.NegativeInfin
ity; |
205 if (typeof unserializableValue !== 'undefined') | 206 if (typeof unserializableValue !== 'undefined') |
206 value = undefined; | 207 value = undefined; |
207 } | 208 } |
208 return new SDK.RemoteObjectImpl(this, undefined, type, undefined, value, uns
erializableValue); | 209 return new SDK.RemoteObjectImpl(this, this._agent, undefined, type, undefine
d, value, unserializableValue); |
209 } | 210 } |
210 | 211 |
211 /** | 212 /** |
212 * @param {string} name | 213 * @param {string} name |
213 * @param {number|string|boolean} value | 214 * @param {number|string|boolean} value |
214 * @return {!SDK.RemoteObjectProperty} | 215 * @return {!SDK.RemoteObjectProperty} |
215 */ | 216 */ |
216 createRemotePropertyFromPrimitiveValue(name, value) { | 217 createRemotePropertyFromPrimitiveValue(name, value) { |
217 return new SDK.RemoteObjectProperty(name, this.createRemoteObjectFromPrimiti
veValue(value)); | 218 return new SDK.RemoteObjectProperty(name, this.createRemoteObjectFromPrimiti
veValue(value)); |
218 } | 219 } |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 return; | 683 return; |
683 } | 684 } |
684 if (this.name) { | 685 if (this.name) { |
685 this._label = this.name; | 686 this._label = this.name; |
686 return; | 687 return; |
687 } | 688 } |
688 var parsedUrl = this.origin.asParsedURL(); | 689 var parsedUrl = this.origin.asParsedURL(); |
689 this._label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : ''; | 690 this._label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : ''; |
690 } | 691 } |
691 }; | 692 }; |
OLD | NEW |