Chromium Code Reviews| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * MetadataCache is a map from Entry to an object containing properties. | 8 * MetadataCache is a map from Entry to an object containing properties. |
| 9 * Properties are divided by types, and all properties of one type are accessed | 9 * Properties are divided by types, and all properties of one type are accessed |
| 10 * at once. | 10 * at once. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 * Margin of the cache size. This amount of caches may be kept in addition. | 108 * Margin of the cache size. This amount of caches may be kept in addition. |
| 109 */ | 109 */ |
| 110 MetadataCache.EVICTION_THRESHOLD_MARGIN = 500; | 110 MetadataCache.EVICTION_THRESHOLD_MARGIN = 500; |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * @param {VolumeManagerWrapper} volumeManager Volume manager instance. | 113 * @param {VolumeManagerWrapper} volumeManager Volume manager instance. |
| 114 * @return {MetadataCache!} The cache with all providers. | 114 * @return {MetadataCache!} The cache with all providers. |
| 115 */ | 115 */ |
| 116 MetadataCache.createFull = function(volumeManager) { | 116 MetadataCache.createFull = function(volumeManager) { |
| 117 var cache = new MetadataCache(); | 117 var cache = new MetadataCache(); |
| 118 // DriveProvider should be prior to FileSystemProvider, because it covers | |
| 119 // FileSystemProvider for files in Drive. | |
| 120 cache.providers_.push(new DriveProvider(volumeManager)); | |
| 118 cache.providers_.push(new FilesystemProvider()); | 121 cache.providers_.push(new FilesystemProvider()); |
| 119 cache.providers_.push(new DriveProvider(volumeManager)); | |
| 120 cache.providers_.push(new ContentProvider()); | 122 cache.providers_.push(new ContentProvider()); |
| 121 return cache; | 123 return cache; |
| 122 }; | 124 }; |
| 123 | 125 |
| 124 /** | 126 /** |
| 125 * Clones metadata entry. Metadata entries may contain scalars, arrays, | 127 * Clones metadata entry. Metadata entries may contain scalars, arrays, |
| 126 * hash arrays and Date object. Other objects are not supported. | 128 * hash arrays and Date object. Other objects are not supported. |
| 127 * @param {Object} metadata Metadata object. | 129 * @param {Object} metadata Metadata object. |
| 128 * @return {Object} Cloned entry. | 130 * @return {Object} Cloned entry. |
| 129 */ | 131 */ |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 var locationInfo = this.volumeManager_.getLocationInfo(entry); | 730 var locationInfo = this.volumeManager_.getLocationInfo(entry); |
| 729 return locationInfo && locationInfo.isDriveBased; | 731 return locationInfo && locationInfo.isDriveBased; |
| 730 }; | 732 }; |
| 731 | 733 |
| 732 /** | 734 /** |
| 733 * @param {string} type The metadata type. | 735 * @param {string} type The metadata type. |
| 734 * @return {boolean} Whether this provider provides this metadata. | 736 * @return {boolean} Whether this provider provides this metadata. |
| 735 */ | 737 */ |
| 736 DriveProvider.prototype.providesType = function(type) { | 738 DriveProvider.prototype.providesType = function(type) { |
| 737 return type === 'drive' || type === 'thumbnail' || | 739 return type === 'drive' || type === 'thumbnail' || |
| 738 type === 'streaming' || type === 'media'; | 740 type === 'streaming' || type === 'media' || type === 'filesystem'; |
| 739 }; | 741 }; |
| 740 | 742 |
| 741 /** | 743 /** |
| 742 * @return {string} Unique provider id. | 744 * @return {string} Unique provider id. |
| 743 */ | 745 */ |
| 744 DriveProvider.prototype.getId = function() { return 'drive'; }; | 746 DriveProvider.prototype.getId = function() { return 'drive'; }; |
| 745 | 747 |
| 746 /** | 748 /** |
| 747 * Fetches the metadata. | 749 * Fetches the metadata. |
| 748 * @param {Entry} entry File entry. | 750 * @param {Entry} entry File entry. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 imageHeight: data.imageHeight, | 834 imageHeight: data.imageHeight, |
| 833 imageRotation: data.imageRotation, | 835 imageRotation: data.imageRotation, |
| 834 availableOffline: DriveProvider.isAvailableOffline(data, entry), | 836 availableOffline: DriveProvider.isAvailableOffline(data, entry), |
| 835 availableWhenMetered: DriveProvider.isAvailableWhenMetered(data), | 837 availableWhenMetered: DriveProvider.isAvailableWhenMetered(data), |
| 836 customIconUrl: data.customIconUrl || '', | 838 customIconUrl: data.customIconUrl || '', |
| 837 contentMimeType: data.contentMimeType || '', | 839 contentMimeType: data.contentMimeType || '', |
| 838 sharedWithMe: data.sharedWithMe, | 840 sharedWithMe: data.sharedWithMe, |
| 839 shared: data.shared | 841 shared: data.shared |
| 840 }; | 842 }; |
| 841 | 843 |
| 844 result.filesystem = { | |
| 845 size: (entry.isFile ? (data.fileSize || 0) : -1), | |
|
hirono
2014/03/14 08:47:29
Currently the size of directories on the drive are
yoshiki
2014/03/14 10:03:11
Yes, I completely agree with you. Done.
| |
| 846 modificationTime: new Date(data.lastModifiedTime) | |
| 847 }; | |
| 848 | |
| 842 if (!data.isPresent) { | 849 if (!data.isPresent) { |
| 843 // Block the local fetch for drive files, which require downloading. | 850 // Block the local fetch for drive files, which require downloading. |
| 844 result.thumbnail = {url: '', transform: null}; | 851 result.thumbnail = {url: '', transform: null}; |
| 845 result.media = {}; | 852 result.media = {}; |
| 846 } | 853 } |
| 847 | 854 |
| 848 if ('thumbnailUrl' in data) { | 855 if ('thumbnailUrl' in data) { |
| 849 result.thumbnail = { | 856 result.thumbnail = { |
| 850 url: data.thumbnailUrl, | 857 url: data.thumbnailUrl, |
| 851 transform: null | 858 transform: null |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 | 1051 |
| 1045 /** | 1052 /** |
| 1046 * Handles the 'log' message from the worker. | 1053 * Handles the 'log' message from the worker. |
| 1047 * @param {Array.<*>} arglist Log arguments. | 1054 * @param {Array.<*>} arglist Log arguments. |
| 1048 * @private | 1055 * @private |
| 1049 */ | 1056 */ |
| 1050 ContentProvider.prototype.onLog_ = function(arglist) { | 1057 ContentProvider.prototype.onLog_ = function(arglist) { |
| 1051 if (MetadataCache.log) // Avoid log spam by default. | 1058 if (MetadataCache.log) // Avoid log spam by default. |
| 1052 console.log.apply(console, ['metadata:'].concat(arglist)); | 1059 console.log.apply(console, ['metadata:'].concat(arglist)); |
| 1053 }; | 1060 }; |
| OLD | NEW |