| OLD | NEW |
| 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 STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ | 5 #ifndef STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ |
| 6 #define STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ | 6 #define STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <stack> | 9 #include <stack> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 class CopyOrMoveFileValidator; | 29 class CopyOrMoveFileValidator; |
| 30 class FileStreamWriter; | 30 class FileStreamWriter; |
| 31 | 31 |
| 32 // A delegate class for recursive copy or move operations. | 32 // A delegate class for recursive copy or move operations. |
| 33 class CopyOrMoveOperationDelegate | 33 class CopyOrMoveOperationDelegate |
| 34 : public RecursiveOperationDelegate { | 34 : public RecursiveOperationDelegate { |
| 35 public: | 35 public: |
| 36 class CopyOrMoveImpl; | 36 class CopyOrMoveImpl; |
| 37 typedef FileSystemOperation::CopyProgressCallback CopyProgressCallback; | 37 typedef FileSystemOperation::CopyProgressCallback CopyProgressCallback; |
| 38 typedef FileSystemOperation::CopyOrMoveErrorCallback CopyOrMoveErrorCallback; |
| 38 typedef FileSystemOperation::CopyOrMoveOption CopyOrMoveOption; | 39 typedef FileSystemOperation::CopyOrMoveOption CopyOrMoveOption; |
| 39 | 40 |
| 40 enum OperationType { | 41 enum OperationType { |
| 41 OPERATION_COPY, | 42 OPERATION_COPY, |
| 42 OPERATION_MOVE | 43 OPERATION_MOVE |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 // Helper to copy a file by reader and writer streams. | 46 // Helper to copy a file by reader and writer streams. |
| 46 // Export for testing. | 47 // Export for testing. |
| 47 class STORAGE_EXPORT StreamCopyHelper { | 48 class STORAGE_EXPORT StreamCopyHelper { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 scoped_refptr<net::IOBufferWithSize> io_buffer_; | 85 scoped_refptr<net::IOBufferWithSize> io_buffer_; |
| 85 int64 num_copied_bytes_; | 86 int64 num_copied_bytes_; |
| 86 int64 previous_flush_offset_; | 87 int64 previous_flush_offset_; |
| 87 base::Time last_progress_callback_invocation_time_; | 88 base::Time last_progress_callback_invocation_time_; |
| 88 base::TimeDelta min_progress_callback_invocation_span_; | 89 base::TimeDelta min_progress_callback_invocation_span_; |
| 89 bool cancel_requested_; | 90 bool cancel_requested_; |
| 90 base::WeakPtrFactory<StreamCopyHelper> weak_factory_; | 91 base::WeakPtrFactory<StreamCopyHelper> weak_factory_; |
| 91 DISALLOW_COPY_AND_ASSIGN(StreamCopyHelper); | 92 DISALLOW_COPY_AND_ASSIGN(StreamCopyHelper); |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 CopyOrMoveOperationDelegate( | 95 CopyOrMoveOperationDelegate(FileSystemContext* file_system_context, |
| 95 FileSystemContext* file_system_context, | 96 const FileSystemURL& src_root, |
| 96 const FileSystemURL& src_root, | 97 const FileSystemURL& dest_root, |
| 97 const FileSystemURL& dest_root, | 98 OperationType operation_type, |
| 98 OperationType operation_type, | 99 CopyOrMoveOption option, |
| 99 CopyOrMoveOption option, | 100 const bool continue_with_error, |
| 100 const CopyProgressCallback& progress_callback, | 101 const CopyOrMoveErrorCallback& error_callback, |
| 101 const StatusCallback& callback); | 102 const CopyProgressCallback& progress_callback, |
| 103 const StatusCallback& callback); |
| 102 ~CopyOrMoveOperationDelegate() override; | 104 ~CopyOrMoveOperationDelegate() override; |
| 103 | 105 |
| 104 // RecursiveOperationDelegate overrides: | 106 // RecursiveOperationDelegate overrides: |
| 105 void Run() override; | 107 void Run() override; |
| 106 void RunRecursively() override; | 108 void RunRecursively() override; |
| 107 void ProcessFile(const FileSystemURL& url, | 109 void ProcessFile(const FileSystemURL& url, |
| 108 const StatusCallback& callback) override; | 110 const StatusCallback& callback) override; |
| 109 void ProcessDirectory(const FileSystemURL& url, | 111 void ProcessDirectory(const FileSystemURL& url, |
| 110 const StatusCallback& callback) override; | 112 const StatusCallback& callback) override; |
| 111 void PostProcessDirectory(const FileSystemURL& url, | 113 void PostProcessDirectory(const FileSystemURL& url, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 141 base::File::Error error); | 143 base::File::Error error); |
| 142 | 144 |
| 143 void OnCopyFileProgress(const FileSystemURL& src_url, int64 size); | 145 void OnCopyFileProgress(const FileSystemURL& src_url, int64 size); |
| 144 FileSystemURL CreateDestURL(const FileSystemURL& src_url) const; | 146 FileSystemURL CreateDestURL(const FileSystemURL& src_url) const; |
| 145 | 147 |
| 146 FileSystemURL src_root_; | 148 FileSystemURL src_root_; |
| 147 FileSystemURL dest_root_; | 149 FileSystemURL dest_root_; |
| 148 bool same_file_system_; | 150 bool same_file_system_; |
| 149 OperationType operation_type_; | 151 OperationType operation_type_; |
| 150 CopyOrMoveOption option_; | 152 CopyOrMoveOption option_; |
| 153 const bool continue_with_error_; |
| 154 CopyOrMoveErrorCallback error_callback_; |
| 151 CopyProgressCallback progress_callback_; | 155 CopyProgressCallback progress_callback_; |
| 152 StatusCallback callback_; | 156 StatusCallback callback_; |
| 153 | 157 |
| 154 std::set<CopyOrMoveImpl*> running_copy_set_; | 158 std::set<CopyOrMoveImpl*> running_copy_set_; |
| 155 base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_; | 159 base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_; |
| 156 | 160 |
| 157 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate); | 161 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate); |
| 158 }; | 162 }; |
| 159 | 163 |
| 160 } // namespace storage | 164 } // namespace storage |
| 161 | 165 |
| 162 #endif // STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ | 166 #endif // STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ |
| OLD | NEW |