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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/browser/fileapi/copy_or_move_operation_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ 5 #ifndef WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_
6 #define WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ 6 #define WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_
7 7
8 #include <stack> 8 #include <stack>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/time/time.h"
12 #include "webkit/browser/fileapi/recursive_operation_delegate.h" 13 #include "webkit/browser/fileapi/recursive_operation_delegate.h"
13 14
15 namespace net {
16 class DrainableIOBuffer;
17 class IOBufferWithSize;
18 }
19
14 namespace webkit_blob { 20 namespace webkit_blob {
21 class FileStreamReader;
15 class ShareableFileReference; 22 class ShareableFileReference;
16 } 23 }
17 24
18 namespace fileapi { 25 namespace fileapi {
19 26
20 class CopyOrMoveFileValidator; 27 class CopyOrMoveFileValidator;
28 class FileStreamWriter;
21 29
22 // A delegate class for recursive copy or move operations. 30 // A delegate class for recursive copy or move operations.
23 class CopyOrMoveOperationDelegate 31 class CopyOrMoveOperationDelegate
24 : public RecursiveOperationDelegate { 32 : public RecursiveOperationDelegate {
25 public: 33 public:
26 class CopyOrMoveImpl; 34 class CopyOrMoveImpl;
27 typedef FileSystemOperation::CopyProgressCallback CopyProgressCallback; 35 typedef FileSystemOperation::CopyProgressCallback CopyProgressCallback;
28 typedef FileSystemOperation::CopyOrMoveOption CopyOrMoveOption; 36 typedef FileSystemOperation::CopyOrMoveOption CopyOrMoveOption;
29 37
30 enum OperationType { 38 enum OperationType {
31 OPERATION_COPY, 39 OPERATION_COPY,
32 OPERATION_MOVE 40 OPERATION_MOVE
33 }; 41 };
34 42
43 // Helper to copy a file by reader and writer streams.
44 // Export for testing.
45 class WEBKIT_STORAGE_BROWSER_EXPORT StreamCopyHelper {
46 public:
47 StreamCopyHelper(
48 scoped_ptr<webkit_blob::FileStreamReader> reader,
49 scoped_ptr<FileStreamWriter> writer,
50 int buffer_size,
51 const FileSystemOperation::CopyFileProgressCallback&
52 file_progress_callback,
53 const base::TimeDelta& min_progress_callback_invocation_span);
54 ~StreamCopyHelper();
55
56 void Run(const StatusCallback& callback);
57
58 private:
59 // Reads the content from the |reader_|.
60 void Read(const StatusCallback& callback);
61 void DidRead(const StatusCallback& callback, int result);
62
63 // Writes the content in |buffer| to |writer_|.
64 void Write(const StatusCallback& callback,
65 scoped_refptr<net::DrainableIOBuffer> buffer);
66 void DidWrite(const StatusCallback& callback,
67 scoped_refptr<net::DrainableIOBuffer> buffer, int result);
68
69 scoped_ptr<webkit_blob::FileStreamReader> reader_;
70 scoped_ptr<FileStreamWriter> writer_;
71 FileSystemOperation::CopyFileProgressCallback file_progress_callback_;
72 scoped_refptr<net::IOBufferWithSize> io_buffer_;
73 int64 num_copied_bytes_;
74 base::Time last_progress_callback_invocation_time_;
75 base::TimeDelta min_progress_callback_invocation_span_;
76 base::WeakPtrFactory<StreamCopyHelper> weak_factory_;
77 DISALLOW_COPY_AND_ASSIGN(StreamCopyHelper);
78 };
79
35 CopyOrMoveOperationDelegate( 80 CopyOrMoveOperationDelegate(
36 FileSystemContext* file_system_context, 81 FileSystemContext* file_system_context,
37 const FileSystemURL& src_root, 82 const FileSystemURL& src_root,
38 const FileSystemURL& dest_root, 83 const FileSystemURL& dest_root,
39 OperationType operation_type, 84 OperationType operation_type,
40 CopyOrMoveOption option, 85 CopyOrMoveOption option,
41 const CopyProgressCallback& progress_callback, 86 const CopyProgressCallback& progress_callback,
42 const StatusCallback& callback); 87 const StatusCallback& callback);
43 virtual ~CopyOrMoveOperationDelegate(); 88 virtual ~CopyOrMoveOperationDelegate();
44 89
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 128
84 std::set<CopyOrMoveImpl*> running_copy_set_; 129 std::set<CopyOrMoveImpl*> running_copy_set_;
85 base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_; 130 base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_;
86 131
87 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate); 132 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate);
88 }; 133 };
89 134
90 } // namespace fileapi 135 } // namespace fileapi
91 136
92 #endif // WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ 137 #endif // WEBKIT_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_
OLDNEW
« 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