| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_FILEAPI_CROSS_OPERATION_DELEGATE_H_ |
| 6 #define WEBKIT_FILEAPI_CROSS_OPERATION_DELEGATE_H_ |
| 7 |
| 8 #include <stack> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "webkit/fileapi/recursive_operation_delegate.h" |
| 12 |
| 13 namespace webkit_blob { |
| 14 class ShareableFileReference; |
| 15 } |
| 16 |
| 17 namespace fileapi { |
| 18 |
| 19 // A delegate class for recursive copy or move operations. |
| 20 class CrossOperationDelegate |
| 21 : public RecursiveOperationDelegate, |
| 22 public base::SupportsWeakPtr<CrossOperationDelegate> { |
| 23 public: |
| 24 enum OperationType { |
| 25 OPERATION_COPY, |
| 26 OPERATION_MOVE |
| 27 }; |
| 28 |
| 29 CrossOperationDelegate(LocalFileSystemOperation* original_operation, |
| 30 const FileSystemURL& src_root, |
| 31 const FileSystemURL& dest_root, |
| 32 OperationType operation_type, |
| 33 const StatusCallback& callback); |
| 34 virtual ~CrossOperationDelegate(); |
| 35 |
| 36 // RecursiveOperationDelegate overrides: |
| 37 virtual void Run() OVERRIDE; |
| 38 virtual void RunRecursively() OVERRIDE; |
| 39 virtual void ProcessFile(const FileSystemURL& url, |
| 40 const StatusCallback& callback) OVERRIDE; |
| 41 virtual void ProcessDirectory(const FileSystemURL& url, |
| 42 const StatusCallback& callback) OVERRIDE; |
| 43 |
| 44 using base::SupportsWeakPtr<CrossOperationDelegate>::AsWeakPtr; |
| 45 |
| 46 private: |
| 47 void DidTryCopyOrMoveFile(base::PlatformFileError error); |
| 48 void DidTryRemoveDestRoot(base::PlatformFileError error); |
| 49 void CopyOrMoveFile( |
| 50 const FileSystemURL& src, |
| 51 const FileSystemURL& dest, |
| 52 const StatusCallback& callback); |
| 53 void DidCreateSnapshot( |
| 54 const FileSystemURL& dest, |
| 55 const StatusCallback& callback, |
| 56 base::PlatformFileError error, |
| 57 const base::PlatformFileInfo& file_info, |
| 58 const FilePath& platform_path, |
| 59 const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref); |
| 60 void DidFinishCopy( |
| 61 const FileSystemURL& src, |
| 62 const StatusCallback& callback, |
| 63 base::PlatformFileError error); |
| 64 void DidRemoveSourceForMove( |
| 65 const StatusCallback& callback, |
| 66 base::PlatformFileError error); |
| 67 |
| 68 FileSystemURL CreateDestURL(const FileSystemURL& src_url) const; |
| 69 |
| 70 // Create nested operations for recursive task. |
| 71 // When creating the operation fails it fires callback_ with the |
| 72 // error code and returns NULL. |
| 73 // |
| 74 // - NewDesetOperation is basically a thin wrapper of |
| 75 // RecursiveOperationDelegate::NewOperation(). |
| 76 // (Since the original_operation must have been created for the destination |
| 77 // URL (TODO(kinuko): we should have some assertion for this assumption)) |
| 78 // |
| 79 // - NewSourceOperation also redirects the request to |
| 80 // RecursiveOperationDelegate::NewOperation() **iff** it's for |
| 81 // same_file_system_ case. |
| 82 // Otherwise it's for cross-filesystem operation and in needs a |
| 83 // separate FileSystemOperationContext, so it creates a new operation |
| 84 // which inherits context from src_root_operation_. |
| 85 // |
| 86 LocalFileSystemOperation* NewSourceOperation(const FileSystemURL& url); |
| 87 LocalFileSystemOperation* NewDestOperation(const FileSystemURL& url); |
| 88 |
| 89 FileSystemURL src_root_; |
| 90 FileSystemURL dest_root_; |
| 91 bool same_file_system_; |
| 92 OperationType operation_type_; |
| 93 StatusCallback callback_; |
| 94 |
| 95 LocalFileSystemOperation* src_root_operation_; |
| 96 |
| 97 scoped_refptr<webkit_blob::ShareableFileReference> current_file_ref_; |
| 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(CrossOperationDelegate); |
| 100 }; |
| 101 |
| 102 } // namespace fileapi |
| 103 |
| 104 #endif // WEBKIT_FILEAPI_CROSS_OPERATION_DELEGATE_H_ |
| OLD | NEW |