| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 this.target().resourceTreeModel.addEventListener(WebInspector.TargetMana
ger.Events.MainFrameNavigated, this._mainFrameNavigated, this); | 60 WebInspector.targetManager.addEventListener(WebInspector.TargetManager.E
vents.MainFrameNavigated, this._mainFrameNavigated, this); |
| 61 }, | 61 }, |
| 62 | 62 |
| 63 disable: function() | 63 disable: function() |
| 64 { | 64 { |
| 65 if (!this._enabled) | 65 if (!this._enabled) |
| 66 return; | 66 return; |
| 67 this._enabled = false; | 67 this._enabled = false; |
| 68 this._reset(); | 68 this._reset(); |
| 69 this.target().workerAgent().disable(); | 69 this.target().workerAgent().disable(); |
| 70 this.target().resourceTreeModel.removeEventListener(WebInspector.TargetM
anager.Events.MainFrameNavigated, this._mainFrameNavigated, this); | 70 WebInspector.targetManager.removeEventListener(WebInspector.TargetManage
r.Events.MainFrameNavigated, this._mainFrameNavigated, this); |
| 71 }, | 71 }, |
| 72 | 72 |
| 73 dispose: function() | 73 dispose: function() |
| 74 { | 74 { |
| 75 this._reset(); | 75 this._reset(); |
| 76 }, | 76 }, |
| 77 | 77 |
| 78 _reset: function() | 78 _reset: function() |
| 79 { | 79 { |
| 80 for (var connection of this._connections.values()) | 80 for (var connection of this._connections.values()) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 var connection = this._connections.get(workerId); | 133 var connection = this._connections.get(workerId); |
| 134 if (connection) | 134 if (connection) |
| 135 connection.dispatch(message); | 135 connection.dispatch(message); |
| 136 }, | 136 }, |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * @param {!WebInspector.Event} event | 139 * @param {!WebInspector.Event} event |
| 140 */ | 140 */ |
| 141 _mainFrameNavigated: function(event) | 141 _mainFrameNavigated: function(event) |
| 142 { | 142 { |
| 143 this._reset(); | 143 if (event.data.target() !== this.target()) |
| 144 return; |
| 145 this._reset(); // TODO (dgozman): Probably, unnecessary. Consider remova
l. |
| 144 }, | 146 }, |
| 145 | 147 |
| 146 /** | 148 /** |
| 147 * @param {string} workerId | 149 * @param {string} workerId |
| 148 * @return {?WebInspector.Target} | 150 * @return {?WebInspector.Target} |
| 149 */ | 151 */ |
| 150 targetByWorkerId: function(workerId) | 152 targetByWorkerId: function(workerId) |
| 151 { | 153 { |
| 152 return this._targetsByWorkerId.get(workerId) || null; | 154 return this._targetsByWorkerId.get(workerId) || null; |
| 153 }, | 155 }, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 this._agent.sendMessageToWorker(this._workerId, JSON.stringify(messageOb
ject)); | 223 this._agent.sendMessageToWorker(this._workerId, JSON.stringify(messageOb
ject)); |
| 222 }, | 224 }, |
| 223 | 225 |
| 224 _close: function() | 226 _close: function() |
| 225 { | 227 { |
| 226 this.connectionClosed("worker_terminated"); | 228 this.connectionClosed("worker_terminated"); |
| 227 }, | 229 }, |
| 228 | 230 |
| 229 __proto__: InspectorBackendClass.Connection.prototype | 231 __proto__: InspectorBackendClass.Connection.prototype |
| 230 } | 232 } |
| OLD | NEW |