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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 }; | 64 }; |
65 | 65 |
66 /** | 66 /** |
67 * Initializes the cache database. | 67 * Initializes the cache database. |
68 * @param {function()} callback Completion callback. | 68 * @param {function()} callback Completion callback. |
69 */ | 69 */ |
70 Cache.prototype.initialize = function(callback) { | 70 Cache.prototype.initialize = function(callback) { |
71 // Establish a connection to the database or (re)create it if not available | 71 // Establish a connection to the database or (re)create it if not available |
72 // or not up to date. After changing the database's schema, increment | 72 // or not up to date. After changing the database's schema, increment |
73 // Cache.DB_VERSION to force database recreating. | 73 // Cache.DB_VERSION to force database recreating. |
74 var openRequest = window.webkitIndexedDB.open(Cache.DB_NAME, | 74 var openRequest = window.indexedDB.open(Cache.DB_NAME, Cache.DB_VERSION); |
75 Cache.DB_VERSION); | |
76 | 75 |
77 openRequest.onsuccess = function(e) { | 76 openRequest.onsuccess = function(e) { |
78 this.db_ = e.target.result; | 77 this.db_ = e.target.result; |
79 callback(); | 78 callback(); |
80 }.bind(this); | 79 }.bind(this); |
81 | 80 |
82 openRequest.onerror = callback; | 81 openRequest.onerror = callback; |
83 | 82 |
84 openRequest.onupgradeneeded = function(e) { | 83 openRequest.onupgradeneeded = function(e) { |
85 console.info('Cache database creating or upgrading.'); | 84 console.info('Cache database creating or upgrading.'); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 metadataReceived = true; | 400 metadataReceived = true; |
402 onPartialSuccess(); | 401 onPartialSuccess(); |
403 }; | 402 }; |
404 | 403 |
405 metadataRequest.onerror = function() { | 404 metadataRequest.onerror = function() { |
406 console.error('Failed to remove an image.'); | 405 console.error('Failed to remove an image.'); |
407 metadataReceived = true; | 406 metadataReceived = true; |
408 onPartialSuccess(); | 407 onPartialSuccess(); |
409 }; | 408 }; |
410 }; | 409 }; |
OLD | NEW |