Chromium Code Reviews| 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 function _callback(error) | |
|
pfeldman
2015/04/29 09:53:02
myCallback, annotate
dmurph
2015/04/29 20:57:47
Done.
| |
| 78 { | |
| 79 if (error) { | |
| 80 console.error("ServiceWorkerCacheAgent error deleting cache entr y ", request, " in cache ", cache.toString(), ": ", error); | |
|
pfeldman
2015/04/29 09:53:02
WebInspector.console.error(WebInspector.UIString("
dmurph
2015/04/29 20:57:47
Done.
| |
| 81 return; | |
| 82 } | |
| 83 callback(); | |
| 84 } | |
| 85 this._agent.deleteEntry(cache.cacheId, request, _callback); | |
| 86 }, | |
| 87 | |
| 88 /** | |
| 89 * @param {!WebInspector.ServiceWorkerCacheModel.Cache} cache | |
| 72 * @param {number} skipCount | 90 * @param {number} skipCount |
| 73 * @param {number} pageSize | 91 * @param {number} pageSize |
| 74 * @param {function(!Array.<!WebInspector.ServiceWorkerCacheModel.Entry>, bo olean)} callback | 92 * @param {function(!Array.<!WebInspector.ServiceWorkerCacheModel.Entry>, bo olean)} callback |
| 75 */ | 93 */ |
| 76 loadCacheData: function(cache, skipCount, pageSize, callback) | 94 loadCacheData: function(cache, skipCount, pageSize, callback) |
| 77 { | 95 { |
| 78 this._requestEntries(cache, skipCount, pageSize, callback); | 96 this._requestEntries(cache, skipCount, pageSize, callback); |
| 79 }, | 97 }, |
| 80 | 98 |
| 81 /** | 99 /** |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 * @param {boolean} hasMore | 244 * @param {boolean} hasMore |
| 227 */ | 245 */ |
| 228 function innerCallback(error, dataEntries, hasMore) | 246 function innerCallback(error, dataEntries, hasMore) |
| 229 { | 247 { |
| 230 if (error) { | 248 if (error) { |
| 231 console.error("ServiceWorkerCacheAgent error while requesting en tries: ", error); | 249 console.error("ServiceWorkerCacheAgent error while requesting en tries: ", error); |
| 232 return; | 250 return; |
| 233 } | 251 } |
| 234 var entries = []; | 252 var entries = []; |
| 235 for (var i = 0; i < dataEntries.length; ++i) { | 253 for (var i = 0; i < dataEntries.length; ++i) { |
| 236 var request = WebInspector.RemoteObject.fromLocalObject(JSON.par se(dataEntries[i].request)); | 254 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 } | 255 } |
| 240 callback(entries, hasMore); | 256 callback(entries, hasMore); |
| 241 } | 257 } |
| 242 this._agent.requestEntries(cache.cacheId, skipCount, pageSize, innerCall back); | 258 this._agent.requestEntries(cache.cacheId, skipCount, pageSize, innerCall back); |
| 243 }, | 259 }, |
| 244 | 260 |
| 245 __proto__: WebInspector.SDKModel.prototype | 261 __proto__: WebInspector.SDKModel.prototype |
| 246 } | 262 } |
| 247 | 263 |
| 248 /** | 264 /** |
| 249 * @constructor | 265 * @constructor |
| 250 * @param {!WebInspector.RemoteObject} request | 266 * @param {string} request |
| 251 * @param {!WebInspector.RemoteObject} response | 267 * @param {string} response |
| 252 */ | 268 */ |
| 253 WebInspector.ServiceWorkerCacheModel.Entry = function(request, response) | 269 WebInspector.ServiceWorkerCacheModel.Entry = function(request, response) |
| 254 { | 270 { |
| 255 this.request = request; | 271 this.request = request; |
| 256 this.response = response; | 272 this.response = response; |
| 257 } | 273 } |
| 258 | 274 |
| 259 /** | 275 /** |
| 260 * @constructor | 276 * @constructor |
| 261 * @param {string} securityOrigin | 277 * @param {string} securityOrigin |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 * @param {!WebInspector.Target} target | 311 * @param {!WebInspector.Target} target |
| 296 * @return {!WebInspector.ServiceWorkerCacheModel} | 312 * @return {!WebInspector.ServiceWorkerCacheModel} |
| 297 */ | 313 */ |
| 298 WebInspector.ServiceWorkerCacheModel.fromTarget = function(target) | 314 WebInspector.ServiceWorkerCacheModel.fromTarget = function(target) |
| 299 { | 315 { |
| 300 if (!target[WebInspector.ServiceWorkerCacheModel._symbol]) | 316 if (!target[WebInspector.ServiceWorkerCacheModel._symbol]) |
| 301 target[WebInspector.ServiceWorkerCacheModel._symbol] = new WebInspector. ServiceWorkerCacheModel(target); | 317 target[WebInspector.ServiceWorkerCacheModel._symbol] = new WebInspector. ServiceWorkerCacheModel(target); |
| 302 | 318 |
| 303 return target[WebInspector.ServiceWorkerCacheModel._symbol]; | 319 return target[WebInspector.ServiceWorkerCacheModel._symbol]; |
| 304 } | 320 } |
| OLD | NEW |