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

Unified Diff: ui/file_manager/file_manager/common/js/mock_entry.js

Issue 881463003: Files.app: Add a deduplication step to avoid importing duplicate media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to master; fix Banners test. Created 5 years, 11 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/common/js/mock_entry.js
diff --git a/ui/file_manager/file_manager/common/js/mock_entry.js b/ui/file_manager/file_manager/common/js/mock_entry.js
index 532b9206ae797ebc86320d8a8aa2b9ef7d7c50b9..26b9541daed4494141740ac56167db226b46da77 100644
--- a/ui/file_manager/file_manager/common/js/mock_entry.js
+++ b/ui/file_manager/file_manager/common/js/mock_entry.js
@@ -83,11 +83,12 @@ MockFileSystem.prototype.findChildren_ = function(directory) {
/**
* Base class of mock entries.
*
- * @param {TestFileSystem} filesystem File system where the entry is localed.
+ * @param {MockFileSystem} filesystem File system where the entry is localed.
* @param {string} fullPath Full path of the entry.
* @constructor
*/
function MockEntry(filesystem, fullPath) {
+ filesystem.entries[fullPath] = this;
this.filesystem = filesystem;
this.fullPath = fullPath;
}
@@ -139,11 +140,28 @@ MockEntry.prototype.getParent = function(
MockEntry.prototype.moveTo = function(parent, opt_newName, onSuccess, onError) {
Promise.resolve().then(function() {
this.filesystem.entries[this.fullPath] = null;
- return this.clone(joinPath(parent.fullPath, opt_newName || this.name));
+ return this.clone(
+ joinPath(parent.fullPath, opt_newName || this.name),
+ parent.filesystem);
}.bind(this)).then(onSuccess, onError);
};
/**
+ * @param {MockDirectoryEntry} parent
+ * @param {string=} opt_newName
+ * @param {function(!MockEntry)} successCallback
+ * @param {function} errorCallback
+ */
+MockEntry.prototype.copyTo =
+ function(parent, opt_newName, successCallback, errorCallback) {
+ Promise.resolve().then(function() {
+ return this.clone(
+ joinPath(parent.fullPath, opt_newName || this.name),
+ parent.filesystem);
+ }.bind(this)).then(successCallback, errorCallback);
+};
+
+/**
* Removes the entry.
*
* @param {function()} onSuccess Success callback.
@@ -159,9 +177,10 @@ MockEntry.prototype.remove = function(onSuccess, onError) {
* Clones the entry with the new fullpath.
*
* @param {string} fullpath New fullpath.
+ * @param {FileSystem} opt_filesystem New file system
* @return {MockEntry} Cloned entry.
*/
-MockEntry.prototype.clone = function(fullpath) {
+MockEntry.prototype.clone = function(fullpath, opt_filesystem) {
throw new Error('Not implemented.');
};
@@ -203,8 +222,9 @@ MockFileEntry.prototype.getMetadata = function(onSuccess, onError) {
/**
* @override
*/
-MockFileEntry.prototype.clone = function(path) {
- return new MockFileEntry(this.filesystem, path, this.metadata);
+MockFileEntry.prototype.clone = function(path, opt_filesystem) {
+ return new MockFileEntry(
+ opt_filesystem || this.filesystem, path, this.metadata);
};
/**
@@ -228,11 +248,19 @@ MockDirectoryEntry.prototype = {
/**
* @override
*/
-MockDirectoryEntry.prototype.clone = function(path) {
- return new MockDirectoryEntry(this.filesystem, path);
+MockDirectoryEntry.prototype.clone = function(path, opt_filesystem) {
+ return new MockDirectoryEntry(opt_filesystem || this.filesystem, path);
};
/**
+ * Returns all children of the supplied directoryEntry.
+ * @return {!Array.<!Entry>}
+ */
+MockDirectoryEntry.prototype.getAllChildren = function() {
+ return this.filesystem.findChildren_(this);
+};
+
+ /**
* Returns a file under the directory.
*
* @param {string} path Path.

Powered by Google App Engine
This is Rietveld 408576698