OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** | 7 /** |
8 * Persistent cache storing images in an indexed database on the hard disk. | 8 * Persistent cache storing images in an indexed database on the hard disk. |
9 * @constructor | 9 * @constructor |
10 */ | 10 */ |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 var dataEntry = null; | 277 var dataEntry = null; |
278 var dataReceived = false; | 278 var dataReceived = false; |
279 | 279 |
280 var onPartialSuccess = function() { | 280 var onPartialSuccess = function() { |
281 // Check if all sub-requests have finished. | 281 // Check if all sub-requests have finished. |
282 if (!metadataReceived || !dataReceived) | 282 if (!metadataReceived || !dataReceived) |
283 return; | 283 return; |
284 | 284 |
285 // Check if both entries are available or both unavailable. | 285 // Check if both entries are available or both unavailable. |
286 if (!!metadataEntry != !!dataEntry) { | 286 if (!!metadataEntry != !!dataEntry) { |
287 console.warn('Incosistent cache database.'); | 287 console.warn('Inconsistent cache database.'); |
288 onFailure(); | 288 onFailure(); |
289 return; | 289 return; |
290 } | 290 } |
291 | 291 |
292 // Process the responses. | 292 // Process the responses. |
293 if (!metadataEntry) { | 293 if (!metadataEntry) { |
294 // The image not found. | 294 // The image not found. |
295 onFailure(); | 295 onFailure(); |
296 } else if (metadataEntry.timestamp != timestamp) { | 296 } else if (metadataEntry.timestamp != timestamp) { |
297 // The image is not up to date, so remove it. | 297 // The image is not up to date, so remove it. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 metadataReceived = true; | 401 metadataReceived = true; |
402 onPartialSuccess(); | 402 onPartialSuccess(); |
403 }; | 403 }; |
404 | 404 |
405 metadataRequest.onerror = function() { | 405 metadataRequest.onerror = function() { |
406 console.error('Failed to remove an image.'); | 406 console.error('Failed to remove an image.'); |
407 metadataReceived = true; | 407 metadataReceived = true; |
408 onPartialSuccess(); | 408 onPartialSuccess(); |
409 }; | 409 }; |
410 }; | 410 }; |
OLD | NEW |