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

Side by Side Diff: webkit/fileapi/cross_operation_delegate.h

Issue 12036022: Split recursive Copy/Move into async tasks and support cross operation (in local case) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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/fileapi/cross_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
(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 the creation fails it fires callback_ with the
72 // error code and returns NULL.
73 //
74 // - NewDestOperation 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** same_file_system_
81 // is true.
82 // Otherwise it's for cross-filesystem operation and it 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_
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/cross_operation_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698