| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 /** | 4 /** |
| 5 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 SDK.ServiceWorkerCacheModel = class extends SDK.SDKModel { | 7 SDK.ServiceWorkerCacheModel = class extends SDK.SDKModel { |
| 8 /** | 8 /** |
| 9 * Invariant: This model can only be constructed on a ServiceWorker target. | 9 * Invariant: This model can only be constructed on a ServiceWorker target. |
| 10 * @param {!SDK.Target} target | 10 * @param {!SDK.Target} target |
| 11 */ | 11 */ |
| 12 constructor(target) { | 12 constructor(target) { |
| 13 super(target); | 13 super(target); |
| 14 | 14 |
| 15 /** @type {!Map<string, !SDK.ServiceWorkerCacheModel.Cache>} */ | 15 /** @type {!Map<string, !SDK.ServiceWorkerCacheModel.Cache>} */ |
| 16 this._caches = new Map(); | 16 this._caches = new Map(); |
| 17 | 17 |
| 18 this._agent = target.cacheStorageAgent(); | 18 this._agent = target.cacheStorageAgent(); |
| 19 | 19 |
| 20 this._securityOriginManager = SDK.SecurityOriginManager.fromTarget(target); | 20 this._securityOriginManager = target.model(SDK.SecurityOriginManager); |
| 21 | 21 |
| 22 /** @type {boolean} */ | 22 /** @type {boolean} */ |
| 23 this._enabled = false; | 23 this._enabled = false; |
| 24 } | 24 } |
| 25 | 25 |
| 26 /** | |
| 27 * @param {!SDK.Target} target | |
| 28 * @return {?SDK.ServiceWorkerCacheModel} | |
| 29 */ | |
| 30 static fromTarget(target) { | |
| 31 return target.model(SDK.ServiceWorkerCacheModel); | |
| 32 } | |
| 33 | |
| 34 enable() { | 26 enable() { |
| 35 if (this._enabled) | 27 if (this._enabled) |
| 36 return; | 28 return; |
| 37 | 29 |
| 38 this._securityOriginManager.addEventListener( | 30 this._securityOriginManager.addEventListener( |
| 39 SDK.SecurityOriginManager.Events.SecurityOriginAdded, this._securityOrig
inAdded, this); | 31 SDK.SecurityOriginManager.Events.SecurityOriginAdded, this._securityOrig
inAdded, this); |
| 40 this._securityOriginManager.addEventListener( | 32 this._securityOriginManager.addEventListener( |
| 41 SDK.SecurityOriginManager.Events.SecurityOriginRemoved, this._securityOr
iginRemoved, this); | 33 SDK.SecurityOriginManager.Events.SecurityOriginRemoved, this._securityOr
iginRemoved, this); |
| 42 | 34 |
| 43 for (var securityOrigin of this._securityOriginManager.securityOrigins()) | 35 for (var securityOrigin of this._securityOriginManager.securityOrigins()) |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 303 } |
| 312 | 304 |
| 313 /** | 305 /** |
| 314 * @override | 306 * @override |
| 315 * @return {string} | 307 * @return {string} |
| 316 */ | 308 */ |
| 317 toString() { | 309 toString() { |
| 318 return this.securityOrigin + this.cacheName; | 310 return this.securityOrigin + this.cacheName; |
| 319 } | 311 } |
| 320 }; | 312 }; |
| OLD | NEW |