| 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 26 matching lines...) Expand all Loading... |
| 37 { | 37 { |
| 38 WebInspector.SDKObject.call(this, target); | 38 WebInspector.SDKObject.call(this, target); |
| 39 target.registerServiceWorkerDispatcher(new WebInspector.ServiceWorkerDispatc
her(this)); | 39 target.registerServiceWorkerDispatcher(new WebInspector.ServiceWorkerDispatc
her(this)); |
| 40 this._lastAnonymousTargetId = 0; | 40 this._lastAnonymousTargetId = 0; |
| 41 this._agent = target.serviceWorkerAgent(); | 41 this._agent = target.serviceWorkerAgent(); |
| 42 /** @type {!Map.<string, !WebInspector.ServiceWorker>} */ | 42 /** @type {!Map.<string, !WebInspector.ServiceWorker>} */ |
| 43 this._workers = new Map(); | 43 this._workers = new Map(); |
| 44 /** @type {!Map.<string, !WebInspector.ServiceWorkerRegistration>} */ | 44 /** @type {!Map.<string, !WebInspector.ServiceWorkerRegistration>} */ |
| 45 this._registrations = new Map(); | 45 this._registrations = new Map(); |
| 46 this.enable(); | 46 this.enable(); |
| 47 this._forceUpdateSetting = WebInspector.settings.createSetting("serviceWorke
rUpdateOnReload", false); |
| 48 if (this._forceUpdateSetting.get()) |
| 49 this._forceUpdateSettingChanged(); |
| 50 this._forceUpdateSetting.addChangeListener(this._forceUpdateSettingChanged,
this); |
| 47 } | 51 } |
| 48 | 52 |
| 49 WebInspector.ServiceWorkerManager.Events = { | 53 WebInspector.ServiceWorkerManager.Events = { |
| 50 WorkersUpdated: "WorkersUpdated", | 54 WorkersUpdated: "WorkersUpdated", |
| 51 RegistrationUpdated: "RegistrationUpdated", | 55 RegistrationUpdated: "RegistrationUpdated", |
| 52 RegistrationDeleted: "RegistrationDeleted", | 56 RegistrationDeleted: "RegistrationDeleted" |
| 53 DebugOnStartUpdated: "DebugOnStartUpdated" | |
| 54 } | 57 } |
| 55 | 58 |
| 56 WebInspector.ServiceWorkerManager.prototype = { | 59 WebInspector.ServiceWorkerManager.prototype = { |
| 57 enable: function() | 60 enable: function() |
| 58 { | 61 { |
| 59 if (this._enabled) | 62 if (this._enabled) |
| 60 return; | 63 return; |
| 61 this._enabled = true; | 64 this._enabled = true; |
| 62 | 65 |
| 63 this._agent.enable(); | 66 this._agent.enable(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 | 91 |
| 89 /** | 92 /** |
| 90 * @return {boolean} | 93 * @return {boolean} |
| 91 */ | 94 */ |
| 92 hasWorkers: function() | 95 hasWorkers: function() |
| 93 { | 96 { |
| 94 return !!this._workers.size; | 97 return !!this._workers.size; |
| 95 }, | 98 }, |
| 96 | 99 |
| 97 /** | 100 /** |
| 98 * @return {boolean} | |
| 99 */ | |
| 100 debugOnStart: function() | |
| 101 { | |
| 102 return !!this._debugOnStart; | |
| 103 }, | |
| 104 | |
| 105 /** | |
| 106 * @param {boolean} flag | |
| 107 */ | |
| 108 setDebugOnStart: function(flag) | |
| 109 { | |
| 110 this._agent.setDebugOnStart(flag); | |
| 111 }, | |
| 112 | |
| 113 /** | |
| 114 * @param {string} registrationId | |
| 115 * @param {boolean} flag | |
| 116 */ | |
| 117 setForceUpdateOnPageLoad: function(registrationId, flag) | |
| 118 { | |
| 119 this._agent.setForceUpdateOnPageLoad(registrationId, flag); | |
| 120 }, | |
| 121 | |
| 122 /** | |
| 123 * @return {!Map.<string, !WebInspector.ServiceWorkerRegistration>} | 101 * @return {!Map.<string, !WebInspector.ServiceWorkerRegistration>} |
| 124 */ | 102 */ |
| 125 registrations: function() | 103 registrations: function() |
| 126 { | 104 { |
| 127 return this._registrations; | 105 return this._registrations; |
| 128 }, | 106 }, |
| 129 | 107 |
| 130 /** | 108 /** |
| 131 * @param {string} versionId | 109 * @param {string} versionId |
| 132 * @return {?WebInspector.ServiceWorkerVersion} | 110 * @return {?WebInspector.ServiceWorkerVersion} |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 _workerErrorReported: function(payload) | 317 _workerErrorReported: function(payload) |
| 340 { | 318 { |
| 341 var registration = this._registrations.get(payload.registrationId); | 319 var registration = this._registrations.get(payload.registrationId); |
| 342 if (!registration) | 320 if (!registration) |
| 343 return; | 321 return; |
| 344 registration._addError(payload); | 322 registration._addError(payload); |
| 345 this.dispatchEventToListeners(WebInspector.ServiceWorkerManager.Events.R
egistrationUpdated, registration); | 323 this.dispatchEventToListeners(WebInspector.ServiceWorkerManager.Events.R
egistrationUpdated, registration); |
| 346 }, | 324 }, |
| 347 | 325 |
| 348 /** | 326 /** |
| 349 * @param {boolean} flag | |
| 350 */ | |
| 351 _debugOnStartUpdated: function(flag) | |
| 352 { | |
| 353 this._debugOnStart = flag; | |
| 354 this.dispatchEventToListeners(WebInspector.ServiceWorkerManager.Events.D
ebugOnStartUpdated, flag); | |
| 355 }, | |
| 356 | |
| 357 /** | |
| 358 * @param {!WebInspector.Event} event | 327 * @param {!WebInspector.Event} event |
| 359 */ | 328 */ |
| 360 _mainFrameNavigated: function(event) | 329 _mainFrameNavigated: function(event) |
| 361 { | 330 { |
| 362 // Attach to the new worker set. | 331 // Attach to the new worker set. |
| 363 }, | 332 }, |
| 364 | 333 |
| 334 /** |
| 335 * @return {!WebInspector.Setting} |
| 336 */ |
| 337 forceUpdateOnReloadSetting: function() |
| 338 { |
| 339 return this._forceUpdateSetting; |
| 340 }, |
| 341 |
| 342 _forceUpdateSettingChanged: function() |
| 343 { |
| 344 this._agent.setForceUpdateOnPageLoad(this._forceUpdateSetting.get()); |
| 345 }, |
| 346 |
| 365 __proto__: WebInspector.SDKObject.prototype | 347 __proto__: WebInspector.SDKObject.prototype |
| 366 } | 348 } |
| 367 | 349 |
| 368 /** | 350 /** |
| 369 * @constructor | 351 * @constructor |
| 370 * @param {!WebInspector.ServiceWorkerManager} manager | 352 * @param {!WebInspector.ServiceWorkerManager} manager |
| 371 * @param {string} workerId | 353 * @param {string} workerId |
| 372 * @param {string} url | 354 * @param {string} url |
| 373 * @param {string} versionId | 355 * @param {string} versionId |
| 374 */ | 356 */ |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 this._manager._workerVersionUpdated(versions); | 478 this._manager._workerVersionUpdated(versions); |
| 497 }, | 479 }, |
| 498 | 480 |
| 499 /** | 481 /** |
| 500 * @override | 482 * @override |
| 501 * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} errorMessage | 483 * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} errorMessage |
| 502 */ | 484 */ |
| 503 workerErrorReported: function(errorMessage) | 485 workerErrorReported: function(errorMessage) |
| 504 { | 486 { |
| 505 this._manager._workerErrorReported(errorMessage); | 487 this._manager._workerErrorReported(errorMessage); |
| 506 }, | |
| 507 | |
| 508 /** | |
| 509 * @override | |
| 510 * @param {boolean} flag | |
| 511 */ | |
| 512 debugOnStartUpdated: function(flag) | |
| 513 { | |
| 514 this._manager._debugOnStartUpdated(flag); | |
| 515 } | 488 } |
| 516 } | 489 } |
| 517 | 490 |
| 518 /** | 491 /** |
| 519 * @constructor | 492 * @constructor |
| 520 * @extends {InspectorBackendClass.Connection} | 493 * @extends {InspectorBackendClass.Connection} |
| 521 * @param {!Protocol.ServiceWorkerAgent} agent | 494 * @param {!Protocol.ServiceWorkerAgent} agent |
| 522 * @param {string} workerId | 495 * @param {string} workerId |
| 523 */ | 496 */ |
| 524 WebInspector.ServiceWorkerConnection = function(agent, workerId) | 497 WebInspector.ServiceWorkerConnection = function(agent, workerId) |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 }, | 797 }, |
| 825 | 798 |
| 826 /** | 799 /** |
| 827 * @return {boolean} | 800 * @return {boolean} |
| 828 */ | 801 */ |
| 829 _shouldBeRemoved: function() | 802 _shouldBeRemoved: function() |
| 830 { | 803 { |
| 831 return this._isRedundant() && (!this._hasErrorLog() || this._deleting); | 804 return this._isRedundant() && (!this._hasErrorLog() || this._deleting); |
| 832 } | 805 } |
| 833 } | 806 } |
| OLD | NEW |