OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 29 matching lines...) Expand all Loading... |
40 this._lastAnonymousTargetId = 0; | 40 this._lastAnonymousTargetId = 0; |
41 /** @type {!Map.<string, !WebInspector.WorkerConnection>} */ | 41 /** @type {!Map.<string, !WebInspector.WorkerConnection>} */ |
42 this._connections = new Map(); | 42 this._connections = new Map(); |
43 | 43 |
44 /** @type {!Map.<string, !WebInspector.Target>} */ | 44 /** @type {!Map.<string, !WebInspector.Target>} */ |
45 this._targetsByWorkerId = new Map(); | 45 this._targetsByWorkerId = new Map(); |
46 | 46 |
47 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.SuspendStateChanged, this._onSuspendStateChanged, this); | 47 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Event
s.SuspendStateChanged, this._onSuspendStateChanged, this); |
48 this._onSuspendStateChanged(); | 48 this._onSuspendStateChanged(); |
49 this.enable(); | 49 this.enable(); |
50 } | 50 }; |
51 | 51 |
52 WebInspector.WorkerManager.prototype = { | 52 WebInspector.WorkerManager.prototype = { |
53 enable: function() | 53 enable: function() |
54 { | 54 { |
55 if (this._enabled) | 55 if (this._enabled) |
56 return; | 56 return; |
57 this._enabled = true; | 57 this._enabled = true; |
58 | 58 |
59 this.target().workerAgent().enable(); | 59 this.target().workerAgent().enable(); |
60 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.E
vents.MainFrameNavigated, this._mainFrameNavigated, this); | 60 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.E
vents.MainFrameNavigated, this._mainFrameNavigated, this); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 /** | 148 /** |
149 * @param {string} workerId | 149 * @param {string} workerId |
150 * @return {?WebInspector.Target} | 150 * @return {?WebInspector.Target} |
151 */ | 151 */ |
152 targetByWorkerId: function(workerId) | 152 targetByWorkerId: function(workerId) |
153 { | 153 { |
154 return this._targetsByWorkerId.get(workerId) || null; | 154 return this._targetsByWorkerId.get(workerId) || null; |
155 }, | 155 }, |
156 | 156 |
157 __proto__: WebInspector.SDKObject.prototype | 157 __proto__: WebInspector.SDKObject.prototype |
158 } | 158 }; |
159 | 159 |
160 /** | 160 /** |
161 * @constructor | 161 * @constructor |
162 * @implements {WorkerAgent.Dispatcher} | 162 * @implements {WorkerAgent.Dispatcher} |
163 */ | 163 */ |
164 WebInspector.WorkerDispatcher = function(workerManager) | 164 WebInspector.WorkerDispatcher = function(workerManager) |
165 { | 165 { |
166 this._workerManager = workerManager; | 166 this._workerManager = workerManager; |
167 } | 167 }; |
168 | 168 |
169 WebInspector.WorkerDispatcher.prototype = { | 169 WebInspector.WorkerDispatcher.prototype = { |
170 /** | 170 /** |
171 * @override | 171 * @override |
172 * @param {string} workerId | 172 * @param {string} workerId |
173 * @param {string} url | 173 * @param {string} url |
174 * @param {boolean} waitingForDebugger | 174 * @param {boolean} waitingForDebugger |
175 */ | 175 */ |
176 workerCreated: function(workerId, url, waitingForDebugger) | 176 workerCreated: function(workerId, url, waitingForDebugger) |
177 { | 177 { |
(...skipping 11 matching lines...) Expand all Loading... |
189 | 189 |
190 /** | 190 /** |
191 * @override | 191 * @override |
192 * @param {string} workerId | 192 * @param {string} workerId |
193 * @param {string} message | 193 * @param {string} message |
194 */ | 194 */ |
195 dispatchMessageFromWorker: function(workerId, message) | 195 dispatchMessageFromWorker: function(workerId, message) |
196 { | 196 { |
197 this._workerManager._dispatchMessageFromWorker(workerId, message); | 197 this._workerManager._dispatchMessageFromWorker(workerId, message); |
198 } | 198 } |
199 } | 199 }; |
200 | 200 |
201 /** | 201 /** |
202 * @constructor | 202 * @constructor |
203 * @extends {InspectorBackendClass.Connection} | 203 * @extends {InspectorBackendClass.Connection} |
204 * @param {!WebInspector.WorkerManager} workerManager | 204 * @param {!WebInspector.WorkerManager} workerManager |
205 * @param {string} workerId | 205 * @param {string} workerId |
206 */ | 206 */ |
207 WebInspector.WorkerConnection = function(workerManager, workerId) | 207 WebInspector.WorkerConnection = function(workerManager, workerId) |
208 { | 208 { |
209 InspectorBackendClass.Connection.call(this); | 209 InspectorBackendClass.Connection.call(this); |
210 // FIXME: remove resourceTreeModel and others from worker targets | 210 // FIXME: remove resourceTreeModel and others from worker targets |
211 this.suppressErrorsForDomains(["Worker", "Page", "CSS", "DOM", "DOMStorage",
"Database", "Network", "IndexedDB"]); | 211 this.suppressErrorsForDomains(["Worker", "Page", "CSS", "DOM", "DOMStorage",
"Database", "Network", "IndexedDB"]); |
212 this._agent = workerManager.target().workerAgent(); | 212 this._agent = workerManager.target().workerAgent(); |
213 this._workerId = workerId; | 213 this._workerId = workerId; |
214 } | 214 }; |
215 | 215 |
216 WebInspector.WorkerConnection.prototype = { | 216 WebInspector.WorkerConnection.prototype = { |
217 /** | 217 /** |
218 * @override | 218 * @override |
219 * @param {!Object} messageObject | 219 * @param {!Object} messageObject |
220 */ | 220 */ |
221 sendMessage: function(messageObject) | 221 sendMessage: function(messageObject) |
222 { | 222 { |
223 this._agent.sendMessageToWorker(this._workerId, JSON.stringify(messageOb
ject)); | 223 this._agent.sendMessageToWorker(this._workerId, JSON.stringify(messageOb
ject)); |
224 }, | 224 }, |
225 | 225 |
226 _reportClosed: function() | 226 _reportClosed: function() |
227 { | 227 { |
228 this.connectionClosed("worker_terminated"); | 228 this.connectionClosed("worker_terminated"); |
229 }, | 229 }, |
230 | 230 |
231 __proto__: InspectorBackendClass.Connection.prototype | 231 __proto__: InspectorBackendClass.Connection.prototype |
232 } | 232 }; |
OLD | NEW |