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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 369 |
370 this._manager._workers.set(workerId, this); | 370 this._manager._workers.set(workerId, this); |
371 WebInspector.targetManager.createTarget(title, WebInspector.Target.Type.Serv
iceWorker, this._connection, manager.target(), targetCreated.bind(this)); | 371 WebInspector.targetManager.createTarget(title, WebInspector.Target.Type.Serv
iceWorker, this._connection, manager.target(), targetCreated.bind(this)); |
372 | 372 |
373 /** | 373 /** |
374 * @param {?WebInspector.Target} target | 374 * @param {?WebInspector.Target} target |
375 * @this {WebInspector.ServiceWorker} | 375 * @this {WebInspector.ServiceWorker} |
376 */ | 376 */ |
377 function targetCreated(target) | 377 function targetCreated(target) |
378 { | 378 { |
379 if (!target) { | 379 if (!this._connection || !target) { |
380 this._manager._workers.delete(workerId); | 380 this._manager._workers.delete(workerId); |
381 return; | 381 return; |
382 } | 382 } |
| 383 this._target = target; |
383 this._manager.dispatchEventToListeners(WebInspector.ServiceWorkerManager
.Events.WorkersUpdated); | 384 this._manager.dispatchEventToListeners(WebInspector.ServiceWorkerManager
.Events.WorkersUpdated); |
384 target.runtimeAgent().run(); | 385 target.runtimeAgent().run(); |
385 } | 386 } |
386 } | 387 } |
387 | 388 |
388 WebInspector.ServiceWorker._lastAnonymousTargetId = 0; | 389 WebInspector.ServiceWorker._lastAnonymousTargetId = 0; |
389 | 390 |
390 WebInspector.ServiceWorker.prototype = { | 391 WebInspector.ServiceWorker.prototype = { |
391 /** | 392 /** |
392 * @return {string} | 393 * @return {string} |
(...skipping 19 matching lines...) Expand all Loading... |
412 return this._scope; | 413 return this._scope; |
413 }, | 414 }, |
414 | 415 |
415 stop: function() | 416 stop: function() |
416 { | 417 { |
417 this._agent.stop(this._workerId); | 418 this._agent.stop(this._workerId); |
418 }, | 419 }, |
419 | 420 |
420 _closeConnection: function() | 421 _closeConnection: function() |
421 { | 422 { |
| 423 if (!this._target) |
| 424 return; |
422 this._connection._close(); | 425 this._connection._close(); |
| 426 delete this._connection; |
423 } | 427 } |
424 } | 428 } |
425 | 429 |
426 /** | 430 /** |
427 * @constructor | 431 * @constructor |
428 * @implements {ServiceWorkerAgent.Dispatcher} | 432 * @implements {ServiceWorkerAgent.Dispatcher} |
429 * @param {!WebInspector.ServiceWorkerManager} manager | 433 * @param {!WebInspector.ServiceWorkerManager} manager |
430 */ | 434 */ |
431 WebInspector.ServiceWorkerDispatcher = function(manager) | 435 WebInspector.ServiceWorkerDispatcher = function(manager) |
432 { | 436 { |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 }, | 812 }, |
809 | 813 |
810 /** | 814 /** |
811 * @return {boolean} | 815 * @return {boolean} |
812 */ | 816 */ |
813 _shouldBeRemoved: function() | 817 _shouldBeRemoved: function() |
814 { | 818 { |
815 return this._isRedundant() && (!this._hasErrorLog() || this._deleting); | 819 return this._isRedundant() && (!this._hasErrorLog() || this._deleting); |
816 } | 820 } |
817 } | 821 } |
OLD | NEW |