Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Unified Diff: ui/file_manager/file_manager/foreground/js/metadata/metadata_model.js

Issue 971723002: Files.app: Rename FileSystemMetadata with MetadataModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/file_manager/foreground/js/metadata/metadata_model.js
diff --git a/ui/file_manager/file_manager/foreground/js/metadata/new_metadata_provider.js b/ui/file_manager/file_manager/foreground/js/metadata/metadata_model.js
similarity index 76%
copy from ui/file_manager/file_manager/foreground/js/metadata/new_metadata_provider.js
copy to ui/file_manager/file_manager/foreground/js/metadata/metadata_model.js
index 6f63f02622e3fcc6df4b0f36ffbadfb32b17fbe1..bd46fa81fc6642f242da40bea8d4b47050db747c 100644
--- a/ui/file_manager/file_manager/foreground/js/metadata/new_metadata_provider.js
+++ b/ui/file_manager/file_manager/foreground/js/metadata/metadata_model.js
@@ -3,47 +3,11 @@
// found in the LICENSE file.
/**
- * TODO(hirono): Remove 'New' from the name after removing old MetadataProvider.
- * @param {!Array<string>} validPropertyNames
- * @constructor
- * @struct
- */
-function NewMetadataProvider(validPropertyNames) {
- /**
- * Set of valid property names. Key is the name of property and value is
- * always true.
- * @private {!Object<string, boolean>}
- * @const
- */
- this.validPropertyNames_ = {};
- for (var i = 0; i < validPropertyNames.length; i++) {
- this.validPropertyNames_[validPropertyNames[i]] = true;
- }
-}
-
-NewMetadataProvider.prototype.checkPropertyNames = function(names) {
- // Check if the property name is correct or not.
- for (var i = 0; i < names.length; i++) {
- assert(this.validPropertyNames_[names[i]]);
- }
-};
-
-/**
- * Obtains the metadata for the request.
- * @param {!Array<!MetadataRequest>} requests
- * @return {!Promise<!Array<!MetadataItem>>} Promise with obtained metadata. It
- * should not return rejected promise. Instead it should return undefined
- * property for property error, and should return empty MetadataItem for
- * entry error.
- */
-NewMetadataProvider.prototype.get;
-
-/**
* @param {!NewMetadataProvider} rawProvider
* @constructor
* @struct
*/
-function CachedMetadataProvider(rawProvider) {
+function MetadataModel(rawProvider) {
/**
* @private {!NewMetadataProvider}
* @const
@@ -64,9 +28,22 @@ function CachedMetadataProvider(rawProvider) {
}
/**
+ * @param {!VolumeManagerCommon.VolumeInfoProvider} volumeManager
+ * @return {!MetadataModel}
+ */
+MetadataModel.create = function(volumeManager) {
+ return new MetadataModel(
+ new MultiMetadataProvider(
+ new FileSystemMetadataProvider(),
+ new ExternalMetadataProvider(),
+ new ContentMetadataProvider(),
+ volumeManager));
+};
+
+/**
* @return {!NewMetadataProvider}
*/
-CachedMetadataProvider.prototype.getRawProvider = function() {
+MetadataModel.prototype.getProvider = function() {
return this.rawProvider_;
};
@@ -76,7 +53,7 @@ CachedMetadataProvider.prototype.getRawProvider = function() {
* @param {!Array<string>} names Metadata property names to be obtained.
* @return {!Promise<!Array<!MetadataItem>>}
*/
-CachedMetadataProvider.prototype.get = function(entries, names) {
+MetadataModel.prototype.get = function(entries, names) {
this.rawProvider_.checkPropertyNames(names);
// Check if the results are cached or not.
@@ -138,7 +115,7 @@ CachedMetadataProvider.prototype.get = function(entries, names) {
* @param {!Array<string>} names Metadata property names to be obtained.
* @return {!Array<!MetadataItem>}
*/
-CachedMetadataProvider.prototype.getCache = function(entries, names) {
+MetadataModel.prototype.getCache = function(entries, names) {
// Check if the property name is correct or not.
this.rawProvider_.checkPropertyNames(names);
return this.cache_.get(entries, names);
@@ -148,7 +125,7 @@ CachedMetadataProvider.prototype.getCache = function(entries, names) {
* Clears old metadata for newly created entries.
* @param {!Array<!Entry>} entries
*/
-CachedMetadataProvider.prototype.notifyEntriesCreated = function(entries) {
+MetadataModel.prototype.notifyEntriesCreated = function(entries) {
this.cache_.clear(util.entriesToURLs(entries));
};
@@ -157,7 +134,7 @@ CachedMetadataProvider.prototype.notifyEntriesCreated = function(entries) {
* @param {!Array<string>} urls Note it is not an entry list because we cannot
* obtain entries after removing them from the file system.
*/
-CachedMetadataProvider.prototype.notifyEntriesRemoved = function(urls) {
+MetadataModel.prototype.notifyEntriesRemoved = function(urls) {
this.cache_.clear(urls);
};
@@ -165,14 +142,14 @@ CachedMetadataProvider.prototype.notifyEntriesRemoved = function(urls) {
* Invalidates metadata for updated entries.
* @param {!Array<!Entry>} entries
*/
-CachedMetadataProvider.prototype.notifyEntriesChanged = function(entries) {
+MetadataModel.prototype.notifyEntriesChanged = function(entries) {
this.cache_.invalidate(this.cache_.generateRequestId(), entries);
};
/**
* Clears all cache.
*/
-CachedMetadataProvider.prototype.clearAllCache = function() {
+MetadataModel.prototype.clearAllCache = function() {
this.cache_.clearAll();
};
@@ -181,7 +158,7 @@ CachedMetadataProvider.prototype.clearAllCache = function() {
* @param {string} type
* @param {function(Event):undefined} callback
*/
-CachedMetadataProvider.prototype.addEventListener = function(type, callback) {
+MetadataModel.prototype.addEventListener = function(type, callback) {
this.cache_.addEventListener(type, callback);
};

Powered by Google App Engine
This is Rietveld 408576698