| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Resources.ServiceWorkersView = class extends UI.VBox { | 8 Resources.ServiceWorkersView = class extends UI.VBox { |
| 9 constructor() { | 9 constructor() { |
| 10 super(true); | 10 super(true); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 section._section.element.classList.toggle('hidden', !visible); | 88 section._section.element.classList.toggle('hidden', !visible); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 /** | 92 /** |
| 93 * @param {!Common.Event} event | 93 * @param {!Common.Event} event |
| 94 */ | 94 */ |
| 95 _registrationUpdated(event) { | 95 _registrationUpdated(event) { |
| 96 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data
); | 96 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data
); |
| 97 this._updateRegistration(registration); | 97 this._updateRegistration(registration); |
| 98 this._gcRegistrations(); |
| 99 } |
| 100 |
| 101 _gcRegistrations() { |
| 102 var hasNonDeletedRegistrations = false; |
| 103 var securityOrigins = new Set(this._securityOriginManager.securityOrigins())
; |
| 104 for (var registration of this._manager.registrations().values()) { |
| 105 var visible = this._showAllCheckbox.checked() || securityOrigins.has(regis
tration.securityOrigin); |
| 106 if (!visible) |
| 107 continue; |
| 108 if (!registration.canBeRemoved()) { |
| 109 hasNonDeletedRegistrations = true; |
| 110 break; |
| 111 } |
| 112 } |
| 113 |
| 114 if (!hasNonDeletedRegistrations) |
| 115 return; |
| 116 |
| 117 for (var registration of this._manager.registrations().values()) { |
| 118 var visible = this._showAllCheckbox.checked() || securityOrigins.has(regis
tration.securityOrigin); |
| 119 if (visible && registration.canBeRemoved()) |
| 120 this._removeRegistrationFromList(registration); |
| 121 } |
| 98 } | 122 } |
| 99 | 123 |
| 100 /** | 124 /** |
| 101 * @param {!Common.Event} event | 125 * @param {!Common.Event} event |
| 102 */ | 126 */ |
| 103 _registrationErrorAdded(event) { | 127 _registrationErrorAdded(event) { |
| 104 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data
['registration']); | 128 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data
['registration']); |
| 105 var error = /** @type {!Protocol.ServiceWorker.ServiceWorkerErrorMessage} */
(event.data['error']); | 129 var error = /** @type {!Protocol.ServiceWorker.ServiceWorkerErrorMessage} */
(event.data['error']); |
| 106 var section = this._sections.get(registration); | 130 var section = this._sections.get(registration); |
| 107 if (!section) | 131 if (!section) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 121 } | 145 } |
| 122 this._updateSectionVisibility(); | 146 this._updateSectionVisibility(); |
| 123 section._scheduleUpdate(); | 147 section._scheduleUpdate(); |
| 124 } | 148 } |
| 125 | 149 |
| 126 /** | 150 /** |
| 127 * @param {!Common.Event} event | 151 * @param {!Common.Event} event |
| 128 */ | 152 */ |
| 129 _registrationDeleted(event) { | 153 _registrationDeleted(event) { |
| 130 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data
); | 154 var registration = /** @type {!SDK.ServiceWorkerRegistration} */ (event.data
); |
| 155 this._removeRegistrationFromList(registration); |
| 156 } |
| 157 |
| 158 /** |
| 159 * @param {!SDK.ServiceWorkerRegistration} registration |
| 160 */ |
| 161 _removeRegistrationFromList(registration) { |
| 131 var section = this._sections.get(registration); | 162 var section = this._sections.get(registration); |
| 132 if (section) | 163 if (section) |
| 133 section._section.remove(); | 164 section._section.remove(); |
| 134 this._sections.delete(registration); | 165 this._sections.delete(registration); |
| 135 } | 166 } |
| 136 }; | 167 }; |
| 137 | 168 |
| 138 /** | 169 /** |
| 139 * @unrestricted | 170 * @unrestricted |
| 140 */ | 171 */ |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 * @param {!Element} container | 442 * @param {!Element} container |
| 412 * @return {!Element} | 443 * @return {!Element} |
| 413 */ | 444 */ |
| 414 _wrapWidget(container) { | 445 _wrapWidget(container) { |
| 415 var shadowRoot = UI.createShadowRootWithCoreStyles(container); | 446 var shadowRoot = UI.createShadowRootWithCoreStyles(container); |
| 416 UI.appendStyle(shadowRoot, 'resources/serviceWorkersView.css'); | 447 UI.appendStyle(shadowRoot, 'resources/serviceWorkersView.css'); |
| 417 var contentElement = createElement('div'); | 448 var contentElement = createElement('div'); |
| 418 shadowRoot.appendChild(contentElement); | 449 shadowRoot.appendChild(contentElement); |
| 419 return contentElement; | 450 return contentElement; |
| 420 } | 451 } |
| 421 | |
| 422 _dispose() { | |
| 423 this._linkifier.dispose(); | |
| 424 if (this._pendingUpdate) | |
| 425 clearTimeout(this._pendingUpdate); | |
| 426 } | |
| 427 }; | 452 }; |
| OLD | NEW |