OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * MetadataCache is a map from url to an object containing properties. | 6 * MetadataCache is a map from url to an object containing properties. |
7 * Properties are divided by types, and all properties of one type are accessed | 7 * Properties are divided by types, and all properties of one type are accessed |
8 * at once. | 8 * at once. |
9 * Some of the properties: | 9 * Some of the properties: |
10 * { | 10 * { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 }; | 289 }; |
290 | 290 |
291 /** | 291 /** |
292 * Puts the metadata into cache | 292 * Puts the metadata into cache |
293 * @param {string|Entry|Array.<string|Entry>} items The list of entries or | 293 * @param {string|Entry|Array.<string|Entry>} items The list of entries or |
294 * file urls. May be just a single item. | 294 * file urls. May be just a single item. |
295 * @param {string} type The metadata type. | 295 * @param {string} type The metadata type. |
296 * @param {Array.<Object>} values List of corresponding metadata values. | 296 * @param {Array.<Object>} values List of corresponding metadata values. |
297 */ | 297 */ |
298 MetadataCache.prototype.set = function(items, type, values) { | 298 MetadataCache.prototype.set = function(items, type, values) { |
299 if (!(items instanceof Array)) | 299 if (!(items instanceof Array)) { |
300 items = [items]; | 300 items = [items]; |
| 301 values = [values]; |
| 302 } |
301 | 303 |
302 this.startBatchUpdates(); | 304 this.startBatchUpdates(); |
303 for (var index = 0; index < items.length; index++) { | 305 for (var index = 0; index < items.length; index++) { |
304 var url = this.itemToUrl_(items[index]); | 306 var url = this.itemToUrl_(items[index]); |
305 if (!(url in this.cache_)) { | 307 if (!(url in this.cache_)) { |
306 this.cache_[url] = this.createEmptyEntry_(); | 308 this.cache_[url] = this.createEmptyEntry_(); |
307 this.totalCount_++; | 309 this.totalCount_++; |
308 } | 310 } |
309 this.cache_[url].properties[type] = values[index]; | 311 this.cache_[url].properties[type] = values[index]; |
310 this.notifyObservers_(url, type); | 312 this.notifyObservers_(url, type); |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 | 941 |
940 /** | 942 /** |
941 * Handles the 'log' message from the worker. | 943 * Handles the 'log' message from the worker. |
942 * @param {Array.<*>} arglist Log arguments. | 944 * @param {Array.<*>} arglist Log arguments. |
943 * @private | 945 * @private |
944 */ | 946 */ |
945 ContentProvider.prototype.onLog_ = function(arglist) { | 947 ContentProvider.prototype.onLog_ = function(arglist) { |
946 if (localStorage.logMetadata) // Avoid log spam by default. | 948 if (localStorage.logMetadata) // Avoid log spam by default. |
947 console.log.apply(console, ['metadata:'].concat(arglist)); | 949 console.log.apply(console, ['metadata:'].concat(arglist)); |
948 }; | 950 }; |
OLD | NEW |