Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/ServiceWorkerCacheModel.js

Issue 2782773002: [DevTools] Remove SDKModels' fromTarget methods (Closed)
Patch Set: addressed review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698