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

Unified Diff: webkit/browser/fileapi/file_system_operation.h

Issue 24030002: Adds callbacks to notify progress into Copy's API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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: webkit/browser/fileapi/file_system_operation.h
diff --git a/webkit/browser/fileapi/file_system_operation.h b/webkit/browser/fileapi/file_system_operation.h
index a039dd45a8041a4080eaca3cb0880534dbf83f6a..4671880e4f8e439bebe1be59ff07c30e857e1975 100644
--- a/webkit/browser/fileapi/file_system_operation.h
+++ b/webkit/browser/fileapi/file_system_operation.h
@@ -115,6 +115,72 @@ class FileSystemOperation {
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref)>
SnapshotFileCallback;
+ // Used for progress update callback for Copy().
+ //
+ // BEGIN_COPY_ENTRY is fired for each copy creation beginning (for both
+ // file and directory).
+ // The |source_url| is the URL of the source entry. |size| should not be
+ // used.
+ //
+ // END_COPY_ENTRY is fired for each copy creation finishing (for both
+ // file and directory).
+ // The |source_url| is the URL of the source entry. |size| should not be
+ // used.
+ //
+ // PROGRESS is fired periodically during file copying (not fired for
+ // directory copy).
+ // The |source_url| is the URL of the source file. |size| is the number
+ // of cumulative copied bytes for the currently copied file.
+ // Both at beginning and ending of file copying, PROGRESS event should be
+ // called. At beginning, |size| should be 0. At ending, |size| should be
+ // the size of the file.
+ //
+ // Here is an example callback sequence of recursive copy. Suppose
+ // there are a/b/c.txt (100 bytes) and a/b/d.txt (200 bytes), and trying to
+ // copy a to x recursively, then the progress update sequence will be:
+ //
+ // BEGIN_COPY_ENTRY a (starting create "a" directory in x/).
+ // END_COPY_ENTRY a (creating "a" directory in x/ is finished).
+ //
+ // BEGIN_COPY_ENTRY a/b (starting create "b" directory in x/a).
+ // END_COPY_ENTRY a/b (creating "b" directory in x/a/ is finished).
+ //
+ // BEGIN_COPY_ENTRY a/b/c.txt (starting to copy "c.txt" in x/a/b/).
+ // PROGRESS a/b/c.txt 0 (The first PROGRESS's |size| should be 0).
+ // PROGRESS a/b/c.txt 10
+ // :
+ // PROGRESS a/b/c.txt 90
+ // PROGRESS a/b/c.txt 100 (The last PROGRESS's |size| should be the size of
+ // the file).
+ // END_COPY_ENTRY a/b/c.txt (copying "c.txt" is finished).
+ //
+ // BEGIN_COPY_ENTRY a/b/d.txt (starting to copy "d.txt" in x/a/b).
+ // PROGRESS a/b/d.txt 0 (The first PROGRESS's |size| should be 0).
+ // PROGRESS a/b/d.txt 10
+ // :
+ // PROGRESS a/b/d.txt 190
+ // PROGRESS a/b/d.txt 200 (The last PROGRESS's |size| should be the size of
+ // the file).
+ // END_COPY_ENTRY a/b/d.txt (copy "d.txt" is finished).
+ //
+ // Note that event sequence of a/b/c.txt and a/b/d.txt can be interlaced,
+ // because they can be done in parallel.
+ enum CopyProgressType {
+ BEGIN_COPY_ENTRY,
+ END_COPY_ENTRY,
+ PROGRESS,
+ };
+ typedef base::Callback<void(
+ CopyProgressType type, const FileSystemURL& source_url, int64 size)>
+ CopyProgressCallback;
+
+ // Used for CopyFileLocal() to report progress update.
+ // |size| is the cumulative copied bytes for the copy.
+ // At the beginning the progress callback should be called with |size| = 0,
+ // and also at the ending the progress callback should be called with |size|
+ // set to the copied file size.
+ typedef base::Callback<void(int64 size)> CopyFileProgressCallback;
kinuko 2013/09/06 09:55:25 Question: how difficult would it be (in terms of c
hidehiko 2013/09/06 10:06:16 IMHO, it's a bit complicated especially for direct
kinuko 2013/09/09 03:46:31 Would it need more effort than adding one more pro
hidehiko 2013/09/09 04:48:15 Added comments about future extension and on error
+
// Used for Write().
typedef base::Callback<void(base::PlatformFileError result,
int64 bytes,
@@ -139,6 +205,9 @@ class FileSystemOperation {
// |src_path| is a directory, the contents of |src_path| are copied to
// |dest_path| recursively. A new file or directory is created at
// |dest_path| as needed.
+ // |progress_callback| is periodically called to report the progress
+ // update. See also the comment of CopyProgressCallback. This callback is
+ // optional.
//
// For recursive case this internally creates new FileSystemOperations and
// calls:
@@ -150,6 +219,7 @@ class FileSystemOperation {
//
virtual void Copy(const FileSystemURL& src_path,
const FileSystemURL& dest_path,
+ const CopyProgressCallback& progress_callback,
const StatusCallback& callback) = 0;
// Moves a file or directory from |src_path| to |dest_path|. A new file
@@ -295,6 +365,9 @@ class FileSystemOperation {
// Copies a file from |src_url| to |dest_url|.
// This must be called for files that belong to the same filesystem
// (i.e. type() and origin() of the |src_url| and |dest_url| must match).
+ // |progress_callback| is periodically called to report the progress
+ // update. See also the comment of CopyFileProgressCallback. This callback is
+ // optional.
//
// This returns:
// - PLATFORM_FILE_ERROR_NOT_FOUND if |src_url|
@@ -307,6 +380,7 @@ class FileSystemOperation {
//
virtual void CopyFileLocal(const FileSystemURL& src_url,
const FileSystemURL& dest_url,
+ const CopyFileProgressCallback& progress_callback,
const StatusCallback& callback) = 0;
// Moves a local file from |src_url| to |dest_url|.
« no previous file with comments | « webkit/browser/fileapi/copy_or_move_operation_delegate.cc ('k') | webkit/browser/fileapi/file_system_operation_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698