| 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 /** | 5 /** |
| 6 * Invariant: This model can only be constructed on a ServiceWorker target. | 6 * Invariant: This model can only be constructed on a ServiceWorker target. |
| 7 * @constructor | 7 * @constructor |
| 8 * @extends {WebInspector.SDKModel} | 8 * @extends {WebInspector.SDKModel} |
| 9 */ | 9 */ |
| 10 WebInspector.ServiceWorkerCacheModel = function(target) | 10 WebInspector.ServiceWorkerCacheModel = function(target) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 this._caches.delete(cache.cacheId); | 64 this._caches.delete(cache.cacheId); |
| 65 this._cacheRemoved(cache); | 65 this._cacheRemoved(cache); |
| 66 } | 66 } |
| 67 this._agent.deleteCache(cache.cacheId, callback.bind(this)); | 67 this._agent.deleteCache(cache.cacheId, callback.bind(this)); |
| 68 }, | 68 }, |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache | 71 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache |
| 72 * @param {string} request |
| 73 * @param {function()} callback |
| 74 */ |
| 75 deleteCacheEntry: function(cache, request, callback) |
| 76 { |
| 77 |
| 78 /** |
| 79 * @param {?Protocol.Error} error |
| 80 */ |
| 81 function myCallback(error) |
| 82 { |
| 83 if (error) { |
| 84 WebInspector.console.error(WebInspector.UIString("ServiceWorkerC
acheAgent error deleting cache entry %s in cache: %s", cache.toString(), error))
; |
| 85 return; |
| 86 } |
| 87 callback(); |
| 88 } |
| 89 this._agent.deleteEntry(cache.cacheId, request, myCallback); |
| 90 }, |
| 91 |
| 92 /** |
| 93 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache |
| 72 * @param {number} skipCount | 94 * @param {number} skipCount |
| 73 * @param {number} pageSize | 95 * @param {number} pageSize |
| 74 * @param {function(!Array.<!WebInspector.ServiceWorkerCacheModel.Entry>, bo
olean)} callback | 96 * @param {function(!Array.<!WebInspector.ServiceWorkerCacheModel.Entry>, bo
olean)} callback |
| 75 */ | 97 */ |
| 76 loadCacheData: function(cache, skipCount, pageSize, callback) | 98 loadCacheData: function(cache, skipCount, pageSize, callback) |
| 77 { | 99 { |
| 78 this._requestEntries(cache, skipCount, pageSize, callback); | 100 this._requestEntries(cache, skipCount, pageSize, callback); |
| 79 }, | 101 }, |
| 80 | 102 |
| 81 /** | 103 /** |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 * @param {boolean} hasMore | 248 * @param {boolean} hasMore |
| 227 */ | 249 */ |
| 228 function innerCallback(error, dataEntries, hasMore) | 250 function innerCallback(error, dataEntries, hasMore) |
| 229 { | 251 { |
| 230 if (error) { | 252 if (error) { |
| 231 console.error("ServiceWorkerCacheAgent error while requesting en
tries: ", error); | 253 console.error("ServiceWorkerCacheAgent error while requesting en
tries: ", error); |
| 232 return; | 254 return; |
| 233 } | 255 } |
| 234 var entries = []; | 256 var entries = []; |
| 235 for (var i = 0; i < dataEntries.length; ++i) { | 257 for (var i = 0; i < dataEntries.length; ++i) { |
| 236 var request = WebInspector.RemoteObject.fromLocalObject(JSON.par
se(dataEntries[i].request)); | 258 entries.push(new WebInspector.ServiceWorkerCacheModel.Entry(data
Entries[i].request, dataEntries[i].response)); |
| 237 var response = WebInspector.RemoteObject.fromLocalObject(JSON.pa
rse(dataEntries[i].response)); | |
| 238 entries.push(new WebInspector.ServiceWorkerCacheModel.Entry(requ
est, response)); | |
| 239 } | 259 } |
| 240 callback(entries, hasMore); | 260 callback(entries, hasMore); |
| 241 } | 261 } |
| 242 this._agent.requestEntries(cache.cacheId, skipCount, pageSize, innerCall
back); | 262 this._agent.requestEntries(cache.cacheId, skipCount, pageSize, innerCall
back); |
| 243 }, | 263 }, |
| 244 | 264 |
| 245 __proto__: WebInspector.SDKModel.prototype | 265 __proto__: WebInspector.SDKModel.prototype |
| 246 } | 266 } |
| 247 | 267 |
| 248 /** | 268 /** |
| 249 * @constructor | 269 * @constructor |
| 250 * @param {!WebInspector.RemoteObject} request | 270 * @param {string} request |
| 251 * @param {!WebInspector.RemoteObject} response | 271 * @param {string} response |
| 252 */ | 272 */ |
| 253 WebInspector.ServiceWorkerCacheModel.Entry = function(request, response) | 273 WebInspector.ServiceWorkerCacheModel.Entry = function(request, response) |
| 254 { | 274 { |
| 255 this.request = request; | 275 this.request = request; |
| 256 this.response = response; | 276 this.response = response; |
| 257 } | 277 } |
| 258 | 278 |
| 259 /** | 279 /** |
| 260 * @constructor | 280 * @constructor |
| 261 * @param {string} securityOrigin | 281 * @param {string} securityOrigin |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 * @param {!WebInspector.Target} target | 315 * @param {!WebInspector.Target} target |
| 296 * @return {!WebInspector.ServiceWorkerCacheModel} | 316 * @return {!WebInspector.ServiceWorkerCacheModel} |
| 297 */ | 317 */ |
| 298 WebInspector.ServiceWorkerCacheModel.fromTarget = function(target) | 318 WebInspector.ServiceWorkerCacheModel.fromTarget = function(target) |
| 299 { | 319 { |
| 300 if (!target[WebInspector.ServiceWorkerCacheModel._symbol]) | 320 if (!target[WebInspector.ServiceWorkerCacheModel._symbol]) |
| 301 target[WebInspector.ServiceWorkerCacheModel._symbol] = new WebInspector.
ServiceWorkerCacheModel(target); | 321 target[WebInspector.ServiceWorkerCacheModel._symbol] = new WebInspector.
ServiceWorkerCacheModel(target); |
| 302 | 322 |
| 303 return target[WebInspector.ServiceWorkerCacheModel._symbol]; | 323 return target[WebInspector.ServiceWorkerCacheModel._symbol]; |
| 304 } | 324 } |
| OLD | NEW |