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

Side by Side Diff: storage/browser/fileapi/recursive_operation_delegate.h

Issue 1619733004: Run recursive file operations sequentially. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 STORAGE_BROWSER_FILEAPI_RECURSIVE_OPERATION_DELEGATE_H_ 5 #ifndef STORAGE_BROWSER_FILEAPI_RECURSIVE_OPERATION_DELEGATE_H_
6 #define STORAGE_BROWSER_FILEAPI_RECURSIVE_OPERATION_DELEGATE_H_ 6 #define STORAGE_BROWSER_FILEAPI_RECURSIVE_OPERATION_DELEGATE_H_
7 7
8 #include <queue> 8 #include <queue>
9 #include <stack> 9 #include <stack>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // This will call ProcessFile and ProcessDirectory on each file or directory. 67 // This will call ProcessFile and ProcessDirectory on each file or directory.
68 // 68 //
69 // First, this tries to call ProcessFile with |root| regardless whether it is 69 // First, this tries to call ProcessFile with |root| regardless whether it is
70 // actually a file or a directory. If it is a directory, ProcessFile should 70 // actually a file or a directory. If it is a directory, ProcessFile should
71 // return File::FILE_NOT_A_FILE. 71 // return File::FILE_NOT_A_FILE.
72 // 72 //
73 // For each directory, the recursive operation works as follows: 73 // For each directory, the recursive operation works as follows:
74 // ProcessDirectory is called first for the directory. 74 // ProcessDirectory is called first for the directory.
75 // Then the directory contents are read (to obtain its sub directories and 75 // Then the directory contents are read (to obtain its sub directories and
76 // files in it). 76 // files in it).
77 // ProcessFile is called for found files. This may run in parallel. 77 // ProcessFile is called for found files.
78 // The same step is recursively applied to each subdirectory. 78 // The same step is recursively applied to each subdirectory.
79 // After all files and subdirectories in a directory are processed, 79 // After all files and subdirectories in a directory are processed,
80 // PostProcessDirectory is called for the directory. 80 // PostProcessDirectory is called for the directory.
81 // Here is an example; 81 // Here is an example;
82 // a_dir/ -+- b1_dir/ -+- c1_dir/ -+- d1_file 82 // a_dir/ -+- b1_dir/ -+- c1_dir/ -+- d1_file
83 // | | | 83 // | | |
84 // | +- c2_file +- d2_file 84 // | +- c2_file +- d2_file
85 // | 85 // |
86 // +- b2_dir/ --- e_dir/ 86 // +- b2_dir/ --- e_dir/
87 // | 87 // |
88 // +- b3_file 88 // +- b3_file
89 // | 89 // |
90 // +- b4_file 90 // +- b4_file
91 // Then traverse order is: 91 // Then traverse order is:
92 // ProcessFile(a_dir) (This should return File::FILE_NOT_A_FILE). 92 // ProcessFile(a_dir) (This should return File::FILE_NOT_A_FILE).
93 // ProcessDirectory(a_dir). 93 // ProcessDirectory(a_dir).
94 // ProcessFile(b3_file), ProcessFile(b4_file). (in parallel). 94 // ProcessFile(b3_file).
95 // ProcessFile(b4_file).
95 // ProcessDirectory(b1_dir). 96 // ProcessDirectory(b1_dir).
96 // ProcessFile(c2_file) 97 // ProcessFile(c2_file)
97 // ProcessDirectory(c1_dir). 98 // ProcessDirectory(c1_dir).
98 // ProcessFile(d1_file), ProcessFile(d2_file). (in parallel). 99 // ProcessFile(d1_file).
100 // ProcessFile(d2_file).
99 // PostProcessDirectory(c1_dir) 101 // PostProcessDirectory(c1_dir)
100 // PostProcessDirectory(b1_dir). 102 // PostProcessDirectory(b1_dir).
101 // ProcessDirectory(b2_dir) 103 // ProcessDirectory(b2_dir)
102 // ProcessDirectory(e_dir) 104 // ProcessDirectory(e_dir)
103 // PostProcessDirectory(e_dir) 105 // PostProcessDirectory(e_dir)
104 // PostProcessDirectory(b2_dir) 106 // PostProcessDirectory(b2_dir)
105 // PostProcessDirectory(a_dir) 107 // PostProcessDirectory(a_dir)
106 // 108 //
107 // |error_behavior| is to specify how this behaves when an operation have 109 // |error_behavior| is to specify how this behaves when an operation have
108 // failed. 110 // failed.
(...skipping 30 matching lines...) Expand all
139 void DidPostProcessDirectory(base::File::Error error); 141 void DidPostProcessDirectory(base::File::Error error);
140 142
141 // Called when all recursive operation is done (or an error occurs). 143 // Called when all recursive operation is done (or an error occurs).
142 void Done(base::File::Error error); 144 void Done(base::File::Error error);
143 145
144 FileSystemContext* file_system_context_; 146 FileSystemContext* file_system_context_;
145 StatusCallback callback_; 147 StatusCallback callback_;
146 std::stack<FileSystemURL> pending_directories_; 148 std::stack<FileSystemURL> pending_directories_;
147 std::stack<std::queue<FileSystemURL> > pending_directory_stack_; 149 std::stack<std::queue<FileSystemURL> > pending_directory_stack_;
148 std::queue<FileSystemURL> pending_files_; 150 std::queue<FileSystemURL> pending_files_;
149 int inflight_operations_;
150 bool canceled_; 151 bool canceled_;
151 ErrorBehavior error_behavior_; 152 ErrorBehavior error_behavior_;
152 bool failed_some_operations_; 153 bool failed_some_operations_;
153 154
154 DISALLOW_COPY_AND_ASSIGN(RecursiveOperationDelegate); 155 DISALLOW_COPY_AND_ASSIGN(RecursiveOperationDelegate);
155 }; 156 };
156 157
157 } // namespace storage 158 } // namespace storage
158 159
159 #endif // STORAGE_BROWSER_FILEAPI_RECURSIVE_OPERATION_DELEGATE_H_ 160 #endif // STORAGE_BROWSER_FILEAPI_RECURSIVE_OPERATION_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698