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 30 matching lines...) Expand all Loading... |
41 this._lastAnonymousTargetId = 0; | 41 this._lastAnonymousTargetId = 0; |
42 this._agent = target.serviceWorkerAgent(); | 42 this._agent = target.serviceWorkerAgent(); |
43 /** @type {!Map.<string, !WebInspector.ServiceWorkerRegistration>} */ | 43 /** @type {!Map.<string, !WebInspector.ServiceWorkerRegistration>} */ |
44 this._registrations = new Map(); | 44 this._registrations = new Map(); |
45 this.enable(); | 45 this.enable(); |
46 this._forceUpdateSetting = WebInspector.settings.createSetting("serviceWorke
rUpdateOnReload", false); | 46 this._forceUpdateSetting = WebInspector.settings.createSetting("serviceWorke
rUpdateOnReload", false); |
47 if (this._forceUpdateSetting.get()) | 47 if (this._forceUpdateSetting.get()) |
48 this._forceUpdateSettingChanged(); | 48 this._forceUpdateSettingChanged(); |
49 this._forceUpdateSetting.addChangeListener(this._forceUpdateSettingChanged,
this); | 49 this._forceUpdateSetting.addChangeListener(this._forceUpdateSettingChanged,
this); |
50 new WebInspector.ServiceWorkerContextNamer(target, this, subTargetsManager); | 50 new WebInspector.ServiceWorkerContextNamer(target, this, subTargetsManager); |
51 } | 51 }; |
52 | 52 |
53 /** @enum {symbol} */ | 53 /** @enum {symbol} */ |
54 WebInspector.ServiceWorkerManager.Events = { | 54 WebInspector.ServiceWorkerManager.Events = { |
55 RegistrationUpdated: Symbol("RegistrationUpdated"), | 55 RegistrationUpdated: Symbol("RegistrationUpdated"), |
56 RegistrationErrorAdded: Symbol("RegistrationErrorAdded"), | 56 RegistrationErrorAdded: Symbol("RegistrationErrorAdded"), |
57 RegistrationDeleted: Symbol("RegistrationDeleted") | 57 RegistrationDeleted: Symbol("RegistrationDeleted") |
58 } | 58 }; |
59 | 59 |
60 WebInspector.ServiceWorkerManager.prototype = { | 60 WebInspector.ServiceWorkerManager.prototype = { |
61 enable: function() | 61 enable: function() |
62 { | 62 { |
63 if (this._enabled) | 63 if (this._enabled) |
64 return; | 64 return; |
65 this._enabled = true; | 65 this._enabled = true; |
66 this._agent.enable(); | 66 this._agent.enable(); |
67 }, | 67 }, |
68 | 68 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 { | 261 { |
262 return this._forceUpdateSetting; | 262 return this._forceUpdateSetting; |
263 }, | 263 }, |
264 | 264 |
265 _forceUpdateSettingChanged: function() | 265 _forceUpdateSettingChanged: function() |
266 { | 266 { |
267 this._agent.setForceUpdateOnPageLoad(this._forceUpdateSetting.get()); | 267 this._agent.setForceUpdateOnPageLoad(this._forceUpdateSetting.get()); |
268 }, | 268 }, |
269 | 269 |
270 __proto__: WebInspector.SDKObject.prototype | 270 __proto__: WebInspector.SDKObject.prototype |
271 } | 271 }; |
272 | 272 |
273 /** | 273 /** |
274 * @constructor | 274 * @constructor |
275 * @implements {ServiceWorkerAgent.Dispatcher} | 275 * @implements {ServiceWorkerAgent.Dispatcher} |
276 * @param {!WebInspector.ServiceWorkerManager} manager | 276 * @param {!WebInspector.ServiceWorkerManager} manager |
277 */ | 277 */ |
278 WebInspector.ServiceWorkerDispatcher = function(manager) | 278 WebInspector.ServiceWorkerDispatcher = function(manager) |
279 { | 279 { |
280 this._manager = manager; | 280 this._manager = manager; |
281 } | 281 }; |
282 | 282 |
283 WebInspector.ServiceWorkerDispatcher.prototype = { | 283 WebInspector.ServiceWorkerDispatcher.prototype = { |
284 /** | 284 /** |
285 * @override | 285 * @override |
286 * @param {!Array.<!ServiceWorkerAgent.ServiceWorkerRegistration>} registrat
ions | 286 * @param {!Array.<!ServiceWorkerAgent.ServiceWorkerRegistration>} registrat
ions |
287 */ | 287 */ |
288 workerRegistrationUpdated: function(registrations) | 288 workerRegistrationUpdated: function(registrations) |
289 { | 289 { |
290 this._manager._workerRegistrationUpdated(registrations); | 290 this._manager._workerRegistrationUpdated(registrations); |
291 }, | 291 }, |
292 | 292 |
293 /** | 293 /** |
294 * @override | 294 * @override |
295 * @param {!Array.<!ServiceWorkerAgent.ServiceWorkerVersion>} versions | 295 * @param {!Array.<!ServiceWorkerAgent.ServiceWorkerVersion>} versions |
296 */ | 296 */ |
297 workerVersionUpdated: function(versions) | 297 workerVersionUpdated: function(versions) |
298 { | 298 { |
299 this._manager._workerVersionUpdated(versions); | 299 this._manager._workerVersionUpdated(versions); |
300 }, | 300 }, |
301 | 301 |
302 /** | 302 /** |
303 * @override | 303 * @override |
304 * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} errorMessage | 304 * @param {!ServiceWorkerAgent.ServiceWorkerErrorMessage} errorMessage |
305 */ | 305 */ |
306 workerErrorReported: function(errorMessage) | 306 workerErrorReported: function(errorMessage) |
307 { | 307 { |
308 this._manager._workerErrorReported(errorMessage); | 308 this._manager._workerErrorReported(errorMessage); |
309 } | 309 } |
310 } | 310 }; |
311 | 311 |
312 /** | 312 /** |
313 * @constructor | 313 * @constructor |
314 * @param {!WebInspector.ServiceWorkerRegistration} registration | 314 * @param {!WebInspector.ServiceWorkerRegistration} registration |
315 * @param {!ServiceWorkerAgent.ServiceWorkerVersion} payload | 315 * @param {!ServiceWorkerAgent.ServiceWorkerVersion} payload |
316 */ | 316 */ |
317 WebInspector.ServiceWorkerVersion = function(registration, payload) | 317 WebInspector.ServiceWorkerVersion = function(registration, payload) |
318 { | 318 { |
319 this.registration = registration; | 319 this.registration = registration; |
320 this._update(payload); | 320 this._update(payload); |
321 } | 321 }; |
322 | 322 |
323 /** | 323 /** |
324 * @enum {string} | 324 * @enum {string} |
325 */ | 325 */ |
326 WebInspector.ServiceWorkerVersion.Modes = { | 326 WebInspector.ServiceWorkerVersion.Modes = { |
327 Installing: "installing", | 327 Installing: "installing", |
328 Waiting: "waiting", | 328 Waiting: "waiting", |
329 Active: "active", | 329 Active: "active", |
330 Redundant: "redundant" | 330 Redundant: "redundant" |
331 } | 331 }; |
332 | 332 |
333 WebInspector.ServiceWorkerVersion.prototype = { | 333 WebInspector.ServiceWorkerVersion.prototype = { |
334 /** | 334 /** |
335 * @param {!ServiceWorkerAgent.ServiceWorkerVersion} payload | 335 * @param {!ServiceWorkerAgent.ServiceWorkerVersion} payload |
336 */ | 336 */ |
337 _update: function(payload) | 337 _update: function(payload) |
338 { | 338 { |
339 this.id = payload.versionId; | 339 this.id = payload.versionId; |
340 this.scriptURL = payload.scriptURL; | 340 this.scriptURL = payload.scriptURL; |
341 var parsedURL = new WebInspector.ParsedURL(payload.scriptURL); | 341 var parsedURL = new WebInspector.ParsedURL(payload.scriptURL); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 mode: function() | 452 mode: function() |
453 { | 453 { |
454 if (this.isNew() || this.isInstalling()) | 454 if (this.isNew() || this.isInstalling()) |
455 return WebInspector.ServiceWorkerVersion.Modes.Installing; | 455 return WebInspector.ServiceWorkerVersion.Modes.Installing; |
456 else if (this.isInstalled()) | 456 else if (this.isInstalled()) |
457 return WebInspector.ServiceWorkerVersion.Modes.Waiting; | 457 return WebInspector.ServiceWorkerVersion.Modes.Waiting; |
458 else if (this.isActivating() || this.isActivated()) | 458 else if (this.isActivating() || this.isActivated()) |
459 return WebInspector.ServiceWorkerVersion.Modes.Active; | 459 return WebInspector.ServiceWorkerVersion.Modes.Active; |
460 return WebInspector.ServiceWorkerVersion.Modes.Redundant; | 460 return WebInspector.ServiceWorkerVersion.Modes.Redundant; |
461 } | 461 } |
462 } | 462 }; |
463 | 463 |
464 /** | 464 /** |
465 * @constructor | 465 * @constructor |
466 * @param {!ServiceWorkerAgent.ServiceWorkerRegistration} payload | 466 * @param {!ServiceWorkerAgent.ServiceWorkerRegistration} payload |
467 */ | 467 */ |
468 WebInspector.ServiceWorkerRegistration = function(payload) | 468 WebInspector.ServiceWorkerRegistration = function(payload) |
469 { | 469 { |
470 this._update(payload); | 470 this._update(payload); |
471 /** @type {!Map.<string, !WebInspector.ServiceWorkerVersion>} */ | 471 /** @type {!Map.<string, !WebInspector.ServiceWorkerVersion>} */ |
472 this.versions = new Map(); | 472 this.versions = new Map(); |
473 this._deleting = false; | 473 this._deleting = false; |
474 /** @type {!Array<!ServiceWorkerAgent.ServiceWorkerErrorMessage>} */ | 474 /** @type {!Array<!ServiceWorkerAgent.ServiceWorkerErrorMessage>} */ |
475 this.errors = []; | 475 this.errors = []; |
476 } | 476 }; |
477 | 477 |
478 WebInspector.ServiceWorkerRegistration.prototype = { | 478 WebInspector.ServiceWorkerRegistration.prototype = { |
479 /** | 479 /** |
480 * @param {!ServiceWorkerAgent.ServiceWorkerRegistration} payload | 480 * @param {!ServiceWorkerAgent.ServiceWorkerRegistration} payload |
481 */ | 481 */ |
482 _update: function(payload) | 482 _update: function(payload) |
483 { | 483 { |
484 this._fingerprint = Symbol("fingerprint"); | 484 this._fingerprint = Symbol("fingerprint"); |
485 this.id = payload.registrationId; | 485 this.id = payload.registrationId; |
486 this.scopeURL = payload.scopeURL; | 486 this.scopeURL = payload.scopeURL; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 _shouldBeRemoved: function() | 545 _shouldBeRemoved: function() |
546 { | 546 { |
547 return this._isRedundant() && (!this.errors.length || this._deleting); | 547 return this._isRedundant() && (!this.errors.length || this._deleting); |
548 }, | 548 }, |
549 | 549 |
550 clearErrors: function() | 550 clearErrors: function() |
551 { | 551 { |
552 this._fingerprint = Symbol("fingerprint"); | 552 this._fingerprint = Symbol("fingerprint"); |
553 this.errors = []; | 553 this.errors = []; |
554 } | 554 } |
555 } | 555 }; |
556 | 556 |
557 /** | 557 /** |
558 * @constructor | 558 * @constructor |
559 * @param {!WebInspector.Target} target | 559 * @param {!WebInspector.Target} target |
560 * @param {!WebInspector.ServiceWorkerManager} serviceWorkerManager | 560 * @param {!WebInspector.ServiceWorkerManager} serviceWorkerManager |
561 * @param {!WebInspector.SubTargetsManager} subTargetsManager | 561 * @param {!WebInspector.SubTargetsManager} subTargetsManager |
562 */ | 562 */ |
563 WebInspector.ServiceWorkerContextNamer = function(target, serviceWorkerManager,
subTargetsManager) | 563 WebInspector.ServiceWorkerContextNamer = function(target, serviceWorkerManager,
subTargetsManager) |
564 { | 564 { |
565 this._target = target; | 565 this._target = target; |
566 this._serviceWorkerManager = serviceWorkerManager; | 566 this._serviceWorkerManager = serviceWorkerManager; |
567 this._subTargetsManager = subTargetsManager; | 567 this._subTargetsManager = subTargetsManager; |
568 /** @type {!Map<string, !WebInspector.ServiceWorkerVersion>} */ | 568 /** @type {!Map<string, !WebInspector.ServiceWorkerVersion>} */ |
569 this._versionByTargetId = new Map(); | 569 this._versionByTargetId = new Map(); |
570 serviceWorkerManager.addEventListener(WebInspector.ServiceWorkerManager.Even
ts.RegistrationUpdated, this._registrationsUpdated, this); | 570 serviceWorkerManager.addEventListener(WebInspector.ServiceWorkerManager.Even
ts.RegistrationUpdated, this._registrationsUpdated, this); |
571 serviceWorkerManager.addEventListener(WebInspector.ServiceWorkerManager.Even
ts.RegistrationDeleted, this._registrationsUpdated, this); | 571 serviceWorkerManager.addEventListener(WebInspector.ServiceWorkerManager.Even
ts.RegistrationDeleted, this._registrationsUpdated, this); |
572 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn
spector.RuntimeModel.Events.ExecutionContextCreated, this._executionContextCreat
ed, this); | 572 WebInspector.targetManager.addModelListener(WebInspector.RuntimeModel, WebIn
spector.RuntimeModel.Events.ExecutionContextCreated, this._executionContextCreat
ed, this); |
573 } | 573 }; |
574 | 574 |
575 WebInspector.ServiceWorkerContextNamer.prototype = { | 575 WebInspector.ServiceWorkerContextNamer.prototype = { |
576 /** | 576 /** |
577 * @param {!WebInspector.Event} event | 577 * @param {!WebInspector.Event} event |
578 */ | 578 */ |
579 _registrationsUpdated: function(event) | 579 _registrationsUpdated: function(event) |
580 { | 580 { |
581 this._versionByTargetId.clear(); | 581 this._versionByTargetId.clear(); |
582 var registrations = this._serviceWorkerManager.registrations().valuesArr
ay(); | 582 var registrations = this._serviceWorkerManager.registrations().valuesArr
ay(); |
583 for (var registration of registrations) { | 583 for (var registration of registrations) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 */ | 635 */ |
636 _updateContextLabel: function(context, version) | 636 _updateContextLabel: function(context, version) |
637 { | 637 { |
638 var parsedUrl = context.origin.asParsedURL(); | 638 var parsedUrl = context.origin.asParsedURL(); |
639 var label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : cont
ext.name; | 639 var label = parsedUrl ? parsedUrl.lastPathComponentWithFragment() : cont
ext.name; |
640 if (version) | 640 if (version) |
641 context.setLabel(label + " #" + version.id + " (" + version.status +
")"); | 641 context.setLabel(label + " #" + version.id + " (" + version.status +
")"); |
642 else | 642 else |
643 context.setLabel(label); | 643 context.setLabel(label); |
644 }, | 644 }, |
645 } | 645 }; |
OLD | NEW |