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

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

Issue 23463048: Implement stream based cross file system copy. (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
« no previous file with comments | « no previous file | webkit/browser/fileapi/copy_or_move_operation_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/browser/fileapi/copy_or_move_operation_delegate.h
diff --git a/webkit/browser/fileapi/copy_or_move_operation_delegate.h b/webkit/browser/fileapi/copy_or_move_operation_delegate.h
index 1f82a34a08a14d372345385bd2b1c41b6f55dc22..597e05e229761ae86cc5713e20b93f0ae98c23c3 100644
--- a/webkit/browser/fileapi/copy_or_move_operation_delegate.h
+++ b/webkit/browser/fileapi/copy_or_move_operation_delegate.h
@@ -9,15 +9,23 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
#include "webkit/browser/fileapi/recursive_operation_delegate.h"
+namespace net {
+class DrainableIOBuffer;
+class IOBufferWithSize;
+}
+
namespace webkit_blob {
+class FileStreamReader;
class ShareableFileReference;
}
namespace fileapi {
class CopyOrMoveFileValidator;
+class FileStreamWriter;
// A delegate class for recursive copy or move operations.
class CopyOrMoveOperationDelegate
@@ -32,6 +40,43 @@ class CopyOrMoveOperationDelegate
OPERATION_MOVE
};
+ // Helper to copy a file by reader and writer streams.
+ // Export for testing.
+ class WEBKIT_STORAGE_BROWSER_EXPORT StreamCopyHelper {
+ public:
+ StreamCopyHelper(
+ scoped_ptr<webkit_blob::FileStreamReader> reader,
+ scoped_ptr<FileStreamWriter> writer,
+ int buffer_size,
+ const FileSystemOperation::CopyFileProgressCallback&
+ file_progress_callback,
+ const base::TimeDelta& min_progress_callback_invocation_span);
+ ~StreamCopyHelper();
+
+ void Run(const StatusCallback& callback);
+
+ private:
+ // Reads the content from the |reader_|.
+ void Read(const StatusCallback& callback);
+ void DidRead(const StatusCallback& callback, int result);
+
+ // Writes the content in |buffer| to |writer_|.
+ void Write(const StatusCallback& callback,
+ scoped_refptr<net::DrainableIOBuffer> buffer);
+ void DidWrite(const StatusCallback& callback,
+ scoped_refptr<net::DrainableIOBuffer> buffer, int result);
+
+ scoped_ptr<webkit_blob::FileStreamReader> reader_;
+ scoped_ptr<FileStreamWriter> writer_;
+ FileSystemOperation::CopyFileProgressCallback file_progress_callback_;
+ scoped_refptr<net::IOBufferWithSize> io_buffer_;
+ int64 num_copied_bytes_;
+ base::Time last_progress_callback_invocation_time_;
+ base::TimeDelta min_progress_callback_invocation_span_;
+ base::WeakPtrFactory<StreamCopyHelper> weak_factory_;
+ DISALLOW_COPY_AND_ASSIGN(StreamCopyHelper);
+ };
+
CopyOrMoveOperationDelegate(
FileSystemContext* file_system_context,
const FileSystemURL& src_root,
« no previous file with comments | « no previous file | webkit/browser/fileapi/copy_or_move_operation_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698