Commit 7db804e2 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Add FileOperationManager.restoreDeleted function interface

Add FileOperationManager.restoreDeleted interface. Implementation to
follow in crrev.com/c/2469340.

Add trashedItems property to background FileOperationProgressEvent
which is populated with a list of items moved to trash in a delete
operation.

Bug: 953310
Change-Id: If5067bdbcb605f63434c8efab2f8f81f57c76198
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487744
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Auto-Submit: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819289}
parent 2054aecd
......@@ -56,6 +56,14 @@ class FileOperationManager extends EventTarget {
*/
deleteEntries(entries) {}
/**
* Restores files from trash.
*
* @param {Array<!{name: string, filesEntry: !Entry, infoEntry: !FileEntry}>}
* trashItems The trash items.
*/
restoreDeleted(trashItems) {}
/**
* Creates a zip file for the selection of files.
*
......
......@@ -24,5 +24,8 @@ class FileOperationProgressEvent extends Event {
/** @public {number} */
this.processedBytes;
/** @public {?Array<!fileOperationUtil.TrashItem>} */
this.trashedItems;
}
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const fileOperationUtil = {};
/** @constructor */
fileOperationUtil.Error = function() {};
/** @constructor */
fileOperationUtil.EventRouter = function() {};
/** @enum {string} */
fileOperationUtil.EventRouter.EventType = {};
/**
* @typedef {{
* name: string,
* filesEntry: !Entry,
* infoEntry: !FileEntry
* }}
*/
fileOperationUtil.TrashItem;
......@@ -400,7 +400,8 @@ class FileOperationManagerImpl {
entrySize: {},
totalBytes: 0,
processedBytes: 0,
cancelRequested: false
cancelRequested: false,
trashedItems: [],
}));
// Obtains entry size and sum them up.
......@@ -481,7 +482,10 @@ class FileOperationManagerImpl {
.removeFileOrDirectory(
assert(this.volumeManager_), task.entries[0],
/*permanentlyDelete=*/ false)
.then(() => {
.then(trashItem => {
if (trashItem) {
task.trashedItems.push(trashItem);
}
this.eventRouter_.sendEntryChangedEvent(
util.EntryChangedKind.DELETED, task.entries[0]);
task.processedBytes += task.entrySize[task.entries[0].toURL()];
......@@ -512,6 +516,15 @@ class FileOperationManagerImpl {
});
}
/**
* Restores files from trash.
*
* @param {Array<!fileOperationUtil.TrashItem>} trashItems The trash items.
*/
restoreDeleted(trashItems) {
// TODO(crbug.com/953310): to be implemented in crrev.com/c/2469340.
}
/**
* TODO(crbug.com/912236) Remove dead code.
* Creates a zip file for the selection of files.
......
......@@ -1245,6 +1245,15 @@ fileOperationUtil.ZipTask = class extends fileOperationUtil.Task {
}
};
/**
* @typedef {{
* name: string,
* filesEntry: !Entry,
* infoEntry: !FileEntry
* }}
*/
fileOperationUtil.TrashItem;
/**
* @typedef {{
* entries: Array<Entry>,
......@@ -1252,7 +1261,8 @@ fileOperationUtil.ZipTask = class extends fileOperationUtil.Task {
* entrySize: Object,
* totalBytes: number,
* processedBytes: number,
* cancelRequested: boolean
* cancelRequested: boolean,
* trashedItems: Array<!fileOperationUtil.TrashItem>,
* }}
*/
fileOperationUtil.DeleteTask;
......@@ -1379,6 +1389,7 @@ fileOperationUtil.EventRouter = class extends cr.EventTarget {
event.entries = task.entries;
event.totalBytes = task.totalBytes;
event.processedBytes = task.processedBytes;
event.trashedItems = task.trashedItems;
this.dispatchEvent(event);
}
};
......
......@@ -94,5 +94,6 @@ class MockFileOperationManager extends cr.EventTarget {
hasQueuedTasks() {}
filterSameDirectoryEntry() {}
deleteEntries() {}
restoreDeleted() {}
zipSelection() {}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment