Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 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::CopyOrMoveOption CopyOrMoveOption; | 38 typedef FileSystemOperation::CopyOrMoveOption CopyOrMoveOption; |
| 39 typedef FileSystemOperation::ErrorBehavior ErrorBehavior; | |
| 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 { |
| 48 public: | 49 public: |
| (...skipping 35 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 ErrorBehavior error_behavior, |
|
tzik
2015/06/24 05:01:24
nit: we usually pass enums by value without const.
yawano
2015/06/24 06:02:22
Done.
| |
| 100 const CopyProgressCallback& progress_callback, | 101 const CopyProgressCallback& progress_callback, |
| 101 const StatusCallback& callback); | 102 const StatusCallback& callback); |
| 102 ~CopyOrMoveOperationDelegate() override; | 103 ~CopyOrMoveOperationDelegate() override; |
| 103 | 104 |
| 104 // RecursiveOperationDelegate overrides: | 105 // RecursiveOperationDelegate overrides: |
| 105 void Run() override; | 106 void Run() override; |
| 106 void RunRecursively() override; | 107 void RunRecursively() override; |
| 107 void ProcessFile(const FileSystemURL& url, | 108 void ProcessFile(const FileSystemURL& url, |
| 108 const StatusCallback& callback) override; | 109 const StatusCallback& callback) override; |
| 109 void ProcessDirectory(const FileSystemURL& url, | 110 void ProcessDirectory(const FileSystemURL& url, |
| 110 const StatusCallback& callback) override; | 111 const StatusCallback& callback) override; |
| 111 void PostProcessDirectory(const FileSystemURL& url, | 112 void PostProcessDirectory(const FileSystemURL& url, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 141 base::File::Error error); | 142 base::File::Error error); |
| 142 | 143 |
| 143 void OnCopyFileProgress(const FileSystemURL& src_url, int64 size); | 144 void OnCopyFileProgress(const FileSystemURL& src_url, int64 size); |
| 144 FileSystemURL CreateDestURL(const FileSystemURL& src_url) const; | 145 FileSystemURL CreateDestURL(const FileSystemURL& src_url) const; |
| 145 | 146 |
| 146 FileSystemURL src_root_; | 147 FileSystemURL src_root_; |
| 147 FileSystemURL dest_root_; | 148 FileSystemURL dest_root_; |
| 148 bool same_file_system_; | 149 bool same_file_system_; |
| 149 OperationType operation_type_; | 150 OperationType operation_type_; |
| 150 CopyOrMoveOption option_; | 151 CopyOrMoveOption option_; |
| 152 const ErrorBehavior error_behavior_; | |
| 151 CopyProgressCallback progress_callback_; | 153 CopyProgressCallback progress_callback_; |
| 152 StatusCallback callback_; | 154 StatusCallback callback_; |
| 153 | 155 |
| 154 std::set<CopyOrMoveImpl*> running_copy_set_; | 156 std::set<CopyOrMoveImpl*> running_copy_set_; |
| 155 base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_; | 157 base::WeakPtrFactory<CopyOrMoveOperationDelegate> weak_factory_; |
| 156 | 158 |
| 157 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate); | 159 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationDelegate); |
| 158 }; | 160 }; |
| 159 | 161 |
| 160 } // namespace storage | 162 } // namespace storage |
| 161 | 163 |
| 162 #endif // STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ | 164 #endif // STORAGE_BROWSER_FILEAPI_COPY_OR_MOVE_OPERATION_DELEGATE_H_ |
| OLD | NEW |