| 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 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.ServiceWorkerManager = class extends SDK.SDKModel { | 34 SDK.ServiceWorkerManager = 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 target.registerServiceWorkerDispatcher(new SDK.ServiceWorkerDispatcher(this)
); | 41 dispatcher.registerServiceWorkerDispatcher(new SDK.ServiceWorkerDispatcher(t
his)); |
| 41 this._lastAnonymousTargetId = 0; | 42 this._lastAnonymousTargetId = 0; |
| 42 this._agent = target.serviceWorkerAgent(); | 43 this._agent = dispatcher.serviceWorkerAgent(); |
| 44 this._targetAgent = dispatcher.targetAgent(); |
| 43 /** @type {!Map.<string, !SDK.ServiceWorkerRegistration>} */ | 45 /** @type {!Map.<string, !SDK.ServiceWorkerRegistration>} */ |
| 44 this._registrations = new Map(); | 46 this._registrations = new Map(); |
| 45 this.enable(); | 47 this.enable(); |
| 46 this._forceUpdateSetting = Common.settings.createSetting('serviceWorkerUpdat
eOnReload', false); | 48 this._forceUpdateSetting = Common.settings.createSetting('serviceWorkerUpdat
eOnReload', false); |
| 47 if (this._forceUpdateSetting.get()) | 49 if (this._forceUpdateSetting.get()) |
| 48 this._forceUpdateSettingChanged(); | 50 this._forceUpdateSettingChanged(); |
| 49 this._forceUpdateSetting.addChangeListener(this._forceUpdateSettingChanged,
this); | 51 this._forceUpdateSetting.addChangeListener(this._forceUpdateSettingChanged,
this); |
| 50 new SDK.ServiceWorkerContextNamer(target, this); | 52 new SDK.ServiceWorkerContextNamer(target, this); |
| 51 } | 53 } |
| 52 | 54 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 169 } |
| 168 | 170 |
| 169 /** | 171 /** |
| 170 * @param {string} versionId | 172 * @param {string} versionId |
| 171 */ | 173 */ |
| 172 inspectWorker(versionId) { | 174 inspectWorker(versionId) { |
| 173 this._agent.inspectWorker(versionId); | 175 this._agent.inspectWorker(versionId); |
| 174 } | 176 } |
| 175 | 177 |
| 176 /** | 178 /** |
| 179 * @param {string} controlledClient |
| 180 * @return {!Promise<?Protocol.Target.TargetInfo>} |
| 181 */ |
| 182 controlledClientInfo(controlledClient) { |
| 183 return this._targetAgent.getTargetInfo(controlledClient, (error, targetInfo)
=> error ? null : targetInfo); |
| 184 } |
| 185 |
| 186 /** |
| 187 * @param {string} controlledClient |
| 188 */ |
| 189 activateControlledClient(controlledClient) { |
| 190 this._targetAgent.activateTarget(controlledClient); |
| 191 } |
| 192 |
| 193 /** |
| 177 * @param {!Array.<!Protocol.ServiceWorker.ServiceWorkerRegistration>} registr
ations | 194 * @param {!Array.<!Protocol.ServiceWorker.ServiceWorkerRegistration>} registr
ations |
| 178 */ | 195 */ |
| 179 _workerRegistrationUpdated(registrations) { | 196 _workerRegistrationUpdated(registrations) { |
| 180 for (var payload of registrations) { | 197 for (var payload of registrations) { |
| 181 var registration = this._registrations.get(payload.registrationId); | 198 var registration = this._registrations.get(payload.registrationId); |
| 182 if (!registration) { | 199 if (!registration) { |
| 183 registration = new SDK.ServiceWorkerRegistration(payload); | 200 registration = new SDK.ServiceWorkerRegistration(payload); |
| 184 this._registrations.set(payload.registrationId, registration); | 201 this._registrations.set(payload.registrationId, registration); |
| 185 this.dispatchEventToListeners(SDK.ServiceWorkerManager.Events.Registrati
onUpdated, registration); | 202 this.dispatchEventToListeners(SDK.ServiceWorkerManager.Events.Registrati
onUpdated, registration); |
| 186 continue; | 203 continue; |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 _updateContextLabel(context, version) { | 620 _updateContextLabel(context, version) { |
| 604 if (!version) { | 621 if (!version) { |
| 605 context.setLabel(''); | 622 context.setLabel(''); |
| 606 return; | 623 return; |
| 607 } | 624 } |
| 608 var parsedUrl = context.origin.asParsedURL(); | 625 var parsedUrl = context.origin.asParsedURL(); |
| 609 var label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : context.
name; | 626 var label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : context.
name; |
| 610 context.setLabel(label + ' #' + version.id + ' (' + version.status + ')'); | 627 context.setLabel(label + ' #' + version.id + ' (' + version.status + ')'); |
| 611 } | 628 } |
| 612 }; | 629 }; |
| OLD | NEW |