| 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * | 10 * |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * @unrestricted | 30 * @unrestricted |
| 31 */ | 31 */ |
| 32 WebInspector.ApplicationCacheModel = class extends WebInspector.SDKModel { | 32 SDK.ApplicationCacheModel = class extends SDK.SDKModel { |
| 33 /** | 33 /** |
| 34 * @param {!WebInspector.Target} target | 34 * @param {!SDK.Target} target |
| 35 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel | 35 * @param {!SDK.ResourceTreeModel} resourceTreeModel |
| 36 */ | 36 */ |
| 37 constructor(target, resourceTreeModel) { | 37 constructor(target, resourceTreeModel) { |
| 38 super(WebInspector.ApplicationCacheModel, target); | 38 super(SDK.ApplicationCacheModel, target); |
| 39 | 39 |
| 40 target.registerApplicationCacheDispatcher(new WebInspector.ApplicationCacheD
ispatcher(this)); | 40 target.registerApplicationCacheDispatcher(new SDK.ApplicationCacheDispatcher
(this)); |
| 41 this._agent = target.applicationCacheAgent(); | 41 this._agent = target.applicationCacheAgent(); |
| 42 this._agent.enable(); | 42 this._agent.enable(); |
| 43 | 43 |
| 44 resourceTreeModel.addEventListener( | 44 resourceTreeModel.addEventListener( |
| 45 WebInspector.ResourceTreeModel.Events.FrameNavigated, this._frameNavigat
ed, this); | 45 SDK.ResourceTreeModel.Events.FrameNavigated, this._frameNavigated, this)
; |
| 46 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Events.Fra
meDetached, this._frameDetached, this); | 46 resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.FrameDetache
d, this._frameDetached, this); |
| 47 | 47 |
| 48 this._statuses = {}; | 48 this._statuses = {}; |
| 49 this._manifestURLsByFrame = {}; | 49 this._manifestURLsByFrame = {}; |
| 50 | 50 |
| 51 this._mainFrameNavigated(); | 51 this._mainFrameNavigated(); |
| 52 this._onLine = true; | 52 this._onLine = true; |
| 53 } | 53 } |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * @param {!WebInspector.Target} target | 56 * @param {!SDK.Target} target |
| 57 * @return {?WebInspector.ApplicationCacheModel} | 57 * @return {?SDK.ApplicationCacheModel} |
| 58 */ | 58 */ |
| 59 static fromTarget(target) { | 59 static fromTarget(target) { |
| 60 return /** @type {?WebInspector.ApplicationCacheModel} */ (target.model(WebI
nspector.ApplicationCacheModel)); | 60 return /** @type {?SDK.ApplicationCacheModel} */ (target.model(SDK.Applicati
onCacheModel)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 _frameNavigated(event) { | 63 _frameNavigated(event) { |
| 64 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); | 64 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); |
| 65 if (frame.isMainFrame()) { | 65 if (frame.isMainFrame()) { |
| 66 this._mainFrameNavigated(); | 66 this._mainFrameNavigated(); |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 | 69 |
| 70 this._agent.getManifestForFrame(frame.id, this._manifestForFrameLoaded.bind(
this, frame.id)); | 70 this._agent.getManifestForFrame(frame.id, this._manifestForFrameLoaded.bind(
this, frame.id)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * @param {!WebInspector.Event} event | 74 * @param {!Common.Event} event |
| 75 */ | 75 */ |
| 76 _frameDetached(event) { | 76 _frameDetached(event) { |
| 77 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); | 77 var frame = /** @type {!SDK.ResourceTreeFrame} */ (event.data); |
| 78 this._frameManifestRemoved(frame.id); | 78 this._frameManifestRemoved(frame.id); |
| 79 } | 79 } |
| 80 | 80 |
| 81 reset() { | 81 reset() { |
| 82 this._statuses = {}; | 82 this._statuses = {}; |
| 83 this._manifestURLsByFrame = {}; | 83 this._manifestURLsByFrame = {}; |
| 84 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.Fram
eManifestsReset); | 84 this.dispatchEventToListeners(SDK.ApplicationCacheModel.Events.FrameManifest
sReset); |
| 85 } | 85 } |
| 86 | 86 |
| 87 _mainFrameNavigated() { | 87 _mainFrameNavigated() { |
| 88 this._agent.getFramesWithManifests(this._framesWithManifestsLoaded.bind(this
)); | 88 this._agent.getFramesWithManifests(this._framesWithManifestsLoaded.bind(this
)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * @param {string} frameId | 92 * @param {string} frameId |
| 93 * @param {?Protocol.Error} error | 93 * @param {?Protocol.Error} error |
| 94 * @param {string} manifestURL | 94 * @param {string} manifestURL |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 if (this._manifestURLsByFrame[frameId] && manifestURL !== this._manifestURLs
ByFrame[frameId]) | 135 if (this._manifestURLsByFrame[frameId] && manifestURL !== this._manifestURLs
ByFrame[frameId]) |
| 136 this._frameManifestRemoved(frameId); | 136 this._frameManifestRemoved(frameId); |
| 137 | 137 |
| 138 var statusChanged = this._statuses[frameId] !== status; | 138 var statusChanged = this._statuses[frameId] !== status; |
| 139 this._statuses[frameId] = status; | 139 this._statuses[frameId] = status; |
| 140 | 140 |
| 141 if (!this._manifestURLsByFrame[frameId]) { | 141 if (!this._manifestURLsByFrame[frameId]) { |
| 142 this._manifestURLsByFrame[frameId] = manifestURL; | 142 this._manifestURLsByFrame[frameId] = manifestURL; |
| 143 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.Fr
ameManifestAdded, frameId); | 143 this.dispatchEventToListeners(SDK.ApplicationCacheModel.Events.FrameManife
stAdded, frameId); |
| 144 } | 144 } |
| 145 | 145 |
| 146 if (statusChanged) | 146 if (statusChanged) |
| 147 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.Fr
ameManifestStatusUpdated, frameId); | 147 this.dispatchEventToListeners(SDK.ApplicationCacheModel.Events.FrameManife
stStatusUpdated, frameId); |
| 148 } | 148 } |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * @param {string} frameId | 151 * @param {string} frameId |
| 152 */ | 152 */ |
| 153 _frameManifestRemoved(frameId) { | 153 _frameManifestRemoved(frameId) { |
| 154 if (!this._manifestURLsByFrame[frameId]) | 154 if (!this._manifestURLsByFrame[frameId]) |
| 155 return; | 155 return; |
| 156 | 156 |
| 157 delete this._manifestURLsByFrame[frameId]; | 157 delete this._manifestURLsByFrame[frameId]; |
| 158 delete this._statuses[frameId]; | 158 delete this._statuses[frameId]; |
| 159 | 159 |
| 160 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.Fram
eManifestRemoved, frameId); | 160 this.dispatchEventToListeners(SDK.ApplicationCacheModel.Events.FrameManifest
Removed, frameId); |
| 161 } | 161 } |
| 162 | 162 |
| 163 /** | 163 /** |
| 164 * @param {string} frameId | 164 * @param {string} frameId |
| 165 * @return {string} | 165 * @return {string} |
| 166 */ | 166 */ |
| 167 frameManifestURL(frameId) { | 167 frameManifestURL(frameId) { |
| 168 return this._manifestURLsByFrame[frameId] || ''; | 168 return this._manifestURLsByFrame[frameId] || ''; |
| 169 } | 169 } |
| 170 | 170 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 this._agent.getApplicationCacheForFrame(frameId, callbackWrapper); | 214 this._agent.getApplicationCacheForFrame(frameId, callbackWrapper); |
| 215 } | 215 } |
| 216 | 216 |
| 217 /** | 217 /** |
| 218 * @param {boolean} isNowOnline | 218 * @param {boolean} isNowOnline |
| 219 */ | 219 */ |
| 220 _networkStateUpdated(isNowOnline) { | 220 _networkStateUpdated(isNowOnline) { |
| 221 this._onLine = isNowOnline; | 221 this._onLine = isNowOnline; |
| 222 this.dispatchEventToListeners(WebInspector.ApplicationCacheModel.Events.Netw
orkStateChanged, isNowOnline); | 222 this.dispatchEventToListeners(SDK.ApplicationCacheModel.Events.NetworkStateC
hanged, isNowOnline); |
| 223 } | 223 } |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 /** @enum {symbol} */ | 226 /** @enum {symbol} */ |
| 227 WebInspector.ApplicationCacheModel.Events = { | 227 SDK.ApplicationCacheModel.Events = { |
| 228 FrameManifestStatusUpdated: Symbol('FrameManifestStatusUpdated'), | 228 FrameManifestStatusUpdated: Symbol('FrameManifestStatusUpdated'), |
| 229 FrameManifestAdded: Symbol('FrameManifestAdded'), | 229 FrameManifestAdded: Symbol('FrameManifestAdded'), |
| 230 FrameManifestRemoved: Symbol('FrameManifestRemoved'), | 230 FrameManifestRemoved: Symbol('FrameManifestRemoved'), |
| 231 FrameManifestsReset: Symbol('FrameManifestsReset'), | 231 FrameManifestsReset: Symbol('FrameManifestsReset'), |
| 232 NetworkStateChanged: Symbol('NetworkStateChanged') | 232 NetworkStateChanged: Symbol('NetworkStateChanged') |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 /** | 235 /** |
| 236 * @implements {Protocol.ApplicationCacheDispatcher} | 236 * @implements {Protocol.ApplicationCacheDispatcher} |
| 237 * @unrestricted | 237 * @unrestricted |
| 238 */ | 238 */ |
| 239 WebInspector.ApplicationCacheDispatcher = class { | 239 SDK.ApplicationCacheDispatcher = class { |
| 240 constructor(applicationCacheModel) { | 240 constructor(applicationCacheModel) { |
| 241 this._applicationCacheModel = applicationCacheModel; | 241 this._applicationCacheModel = applicationCacheModel; |
| 242 } | 242 } |
| 243 | 243 |
| 244 /** | 244 /** |
| 245 * @override | 245 * @override |
| 246 * @param {string} frameId | 246 * @param {string} frameId |
| 247 * @param {string} manifestURL | 247 * @param {string} manifestURL |
| 248 * @param {number} status | 248 * @param {number} status |
| 249 */ | 249 */ |
| 250 applicationCacheStatusUpdated(frameId, manifestURL, status) { | 250 applicationCacheStatusUpdated(frameId, manifestURL, status) { |
| 251 this._applicationCacheModel._statusUpdated(frameId, manifestURL, status); | 251 this._applicationCacheModel._statusUpdated(frameId, manifestURL, status); |
| 252 } | 252 } |
| 253 | 253 |
| 254 /** | 254 /** |
| 255 * @override | 255 * @override |
| 256 * @param {boolean} isNowOnline | 256 * @param {boolean} isNowOnline |
| 257 */ | 257 */ |
| 258 networkStateUpdated(isNowOnline) { | 258 networkStateUpdated(isNowOnline) { |
| 259 this._applicationCacheModel._networkStateUpdated(isNowOnline); | 259 this._applicationCacheModel._networkStateUpdated(isNowOnline); |
| 260 } | 260 } |
| 261 }; | 261 }; |
| OLD | NEW |