OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "webkit/fileapi/file_system_file_util_proxy.h" | 5 #include "webkit/fileapi/file_system_file_util_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/task_runner.h" |
10 #include "webkit/fileapi/file_system_file_util.h" | 10 #include "webkit/fileapi/file_system_file_util.h" |
11 #include "webkit/fileapi/file_system_operation_context.h" | 11 #include "webkit/fileapi/file_system_operation_context.h" |
12 #include "webkit/fileapi/file_util_helper.h" | 12 #include "webkit/fileapi/file_util_helper.h" |
13 | 13 |
14 namespace fileapi { | 14 namespace fileapi { |
15 | 15 |
16 using base::Bind; | 16 using base::Bind; |
17 using base::Callback; | 17 using base::Callback; |
18 using base::Owned; | 18 using base::Owned; |
19 using base::PlatformFileError; | 19 using base::PlatformFileError; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 private: | 85 private: |
86 base::PlatformFileError error_; | 86 base::PlatformFileError error_; |
87 std::vector<Proxy::Entry> entries_; | 87 std::vector<Proxy::Entry> entries_; |
88 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); | 88 DISALLOW_COPY_AND_ASSIGN(ReadDirectoryHelper); |
89 }; | 89 }; |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 // static | 93 // static |
94 bool FileSystemFileUtilProxy::Delete( | 94 bool FileSystemFileUtilProxy::Delete( |
95 MessageLoopProxy* message_loop_proxy, | 95 base::TaskRunner* task_runner, |
96 FileSystemOperationContext* context, | 96 FileSystemOperationContext* context, |
97 FileSystemFileUtil* file_util, | 97 FileSystemFileUtil* file_util, |
98 const FileSystemPath& path, | 98 const FileSystemPath& path, |
99 bool recursive, | 99 bool recursive, |
100 const StatusCallback& callback) { | 100 const StatusCallback& callback) { |
101 return base::FileUtilProxy::RelayFileTask( | 101 return base::FileUtilProxy::RelayFileTask( |
102 message_loop_proxy, FROM_HERE, | 102 task_runner, FROM_HERE, |
103 Bind(&FileUtilHelper::Delete, context, file_util, path, recursive), | 103 Bind(&FileUtilHelper::Delete, context, file_util, path, recursive), |
104 callback); | 104 callback); |
105 } | 105 } |
106 | 106 |
107 // static | 107 // static |
108 bool FileSystemFileUtilProxy::CreateOrOpen( | 108 bool FileSystemFileUtilProxy::CreateOrOpen( |
109 MessageLoopProxy* message_loop_proxy, | 109 base::TaskRunner* task_runner, |
110 FileSystemOperationContext* context, | 110 FileSystemOperationContext* context, |
111 FileSystemFileUtil* file_util, | 111 FileSystemFileUtil* file_util, |
112 const FileSystemPath& path, | 112 const FileSystemPath& path, |
113 int file_flags, | 113 int file_flags, |
114 const CreateOrOpenCallback& callback) { | 114 const CreateOrOpenCallback& callback) { |
115 return base::FileUtilProxy::RelayCreateOrOpen( | 115 return base::FileUtilProxy::RelayCreateOrOpen( |
116 message_loop_proxy, | 116 task_runner, |
117 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), | 117 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(file_util), |
118 context, path, file_flags), | 118 context, path, file_flags), |
119 Bind(&FileSystemFileUtil::Close, Unretained(file_util), | 119 Bind(&FileSystemFileUtil::Close, Unretained(file_util), |
120 context), | 120 context), |
121 callback); | 121 callback); |
122 } | 122 } |
123 | 123 |
124 // static | 124 // static |
125 bool FileSystemFileUtilProxy::Copy( | 125 bool FileSystemFileUtilProxy::Copy( |
126 MessageLoopProxy* message_loop_proxy, | 126 base::TaskRunner* task_runner, |
127 FileSystemOperationContext* context, | 127 FileSystemOperationContext* context, |
128 FileSystemFileUtil* src_util, | 128 FileSystemFileUtil* src_util, |
129 FileSystemFileUtil* dest_util, | 129 FileSystemFileUtil* dest_util, |
130 const FileSystemPath& src_path, | 130 const FileSystemPath& src_path, |
131 const FileSystemPath& dest_path, | 131 const FileSystemPath& dest_path, |
132 const StatusCallback& callback) { | 132 const StatusCallback& callback) { |
133 return base::FileUtilProxy::RelayFileTask( | 133 return base::FileUtilProxy::RelayFileTask( |
134 message_loop_proxy, FROM_HERE, | 134 task_runner, FROM_HERE, |
135 Bind(&FileUtilHelper::Copy, | 135 Bind(&FileUtilHelper::Copy, |
136 context, src_util, dest_util, src_path, dest_path), | 136 context, src_util, dest_util, src_path, dest_path), |
137 callback); | 137 callback); |
138 } | 138 } |
139 | 139 |
140 // static | 140 // static |
141 bool FileSystemFileUtilProxy::Move( | 141 bool FileSystemFileUtilProxy::Move( |
142 MessageLoopProxy* message_loop_proxy, | 142 base::TaskRunner* task_runner, |
143 FileSystemOperationContext* context, | 143 FileSystemOperationContext* context, |
144 FileSystemFileUtil* src_util, | 144 FileSystemFileUtil* src_util, |
145 FileSystemFileUtil* dest_util, | 145 FileSystemFileUtil* dest_util, |
146 const FileSystemPath& src_path, | 146 const FileSystemPath& src_path, |
147 const FileSystemPath& dest_path, | 147 const FileSystemPath& dest_path, |
148 const StatusCallback& callback) { | 148 const StatusCallback& callback) { |
149 return base::FileUtilProxy::RelayFileTask( | 149 return base::FileUtilProxy::RelayFileTask( |
150 message_loop_proxy, FROM_HERE, | 150 task_runner, FROM_HERE, |
151 Bind(&FileUtilHelper::Move, | 151 Bind(&FileUtilHelper::Move, |
152 context, src_util, dest_util, src_path, dest_path), | 152 context, src_util, dest_util, src_path, dest_path), |
153 callback); | 153 callback); |
154 } | 154 } |
155 | 155 |
156 // static | 156 // static |
157 bool FileSystemFileUtilProxy::EnsureFileExists( | 157 bool FileSystemFileUtilProxy::EnsureFileExists( |
158 MessageLoopProxy* message_loop_proxy, | 158 base::TaskRunner* task_runner, |
159 FileSystemOperationContext* context, | 159 FileSystemOperationContext* context, |
160 FileSystemFileUtil* file_util, | 160 FileSystemFileUtil* file_util, |
161 const FileSystemPath& path, | 161 const FileSystemPath& path, |
162 const EnsureFileExistsCallback& callback) { | 162 const EnsureFileExistsCallback& callback) { |
163 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; | 163 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; |
164 return message_loop_proxy->PostTaskAndReply( | 164 return task_runner->PostTaskAndReply( |
165 FROM_HERE, | 165 FROM_HERE, |
166 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), | 166 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), |
167 file_util, context, path), | 167 file_util, context, path), |
168 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); | 168 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); |
169 } | 169 } |
170 | 170 |
171 // static | 171 // static |
172 bool FileSystemFileUtilProxy::CreateDirectory( | 172 bool FileSystemFileUtilProxy::CreateDirectory( |
173 MessageLoopProxy* message_loop_proxy, | 173 base::TaskRunner* task_runner, |
174 FileSystemOperationContext* context, | 174 FileSystemOperationContext* context, |
175 FileSystemFileUtil* file_util, | 175 FileSystemFileUtil* file_util, |
176 const FileSystemPath& path, | 176 const FileSystemPath& path, |
177 bool exclusive, | 177 bool exclusive, |
178 bool recursive, | 178 bool recursive, |
179 const StatusCallback& callback) { | 179 const StatusCallback& callback) { |
180 return base::FileUtilProxy::RelayFileTask( | 180 return base::FileUtilProxy::RelayFileTask( |
181 message_loop_proxy, FROM_HERE, | 181 task_runner, FROM_HERE, |
182 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), | 182 Bind(&FileSystemFileUtil::CreateDirectory, Unretained(file_util), |
183 context, path, exclusive, recursive), | 183 context, path, exclusive, recursive), |
184 callback); | 184 callback); |
185 } | 185 } |
186 | 186 |
187 // static | 187 // static |
188 bool FileSystemFileUtilProxy::GetFileInfo( | 188 bool FileSystemFileUtilProxy::GetFileInfo( |
189 MessageLoopProxy* message_loop_proxy, | 189 base::TaskRunner* task_runner, |
190 FileSystemOperationContext* context, | 190 FileSystemOperationContext* context, |
191 FileSystemFileUtil* file_util, | 191 FileSystemFileUtil* file_util, |
192 const FileSystemPath& path, | 192 const FileSystemPath& path, |
193 const GetFileInfoCallback& callback) { | 193 const GetFileInfoCallback& callback) { |
194 GetFileInfoHelper* helper = new GetFileInfoHelper; | 194 GetFileInfoHelper* helper = new GetFileInfoHelper; |
195 return message_loop_proxy->PostTaskAndReply( | 195 return task_runner->PostTaskAndReply( |
196 FROM_HERE, | 196 FROM_HERE, |
197 Bind(&GetFileInfoHelper::RunWork, Unretained(helper), | 197 Bind(&GetFileInfoHelper::RunWork, Unretained(helper), |
198 file_util, context, path), | 198 file_util, context, path), |
199 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); | 199 Bind(&GetFileInfoHelper::Reply, Owned(helper), callback)); |
200 } | 200 } |
201 | 201 |
202 // static | 202 // static |
203 bool FileSystemFileUtilProxy::ReadDirectory( | 203 bool FileSystemFileUtilProxy::ReadDirectory( |
204 MessageLoopProxy* message_loop_proxy, | 204 base::TaskRunner* task_runner, |
205 FileSystemOperationContext* context, | 205 FileSystemOperationContext* context, |
206 FileSystemFileUtil* file_util, | 206 FileSystemFileUtil* file_util, |
207 const FileSystemPath& path, | 207 const FileSystemPath& path, |
208 const ReadDirectoryCallback& callback) { | 208 const ReadDirectoryCallback& callback) { |
209 ReadDirectoryHelper* helper = new ReadDirectoryHelper; | 209 ReadDirectoryHelper* helper = new ReadDirectoryHelper; |
210 return message_loop_proxy->PostTaskAndReply( | 210 return task_runner->PostTaskAndReply( |
211 FROM_HERE, | 211 FROM_HERE, |
212 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), | 212 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), |
213 file_util, context, path), | 213 file_util, context, path), |
214 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); | 214 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); |
215 } | 215 } |
216 | 216 |
217 // static | 217 // static |
218 bool FileSystemFileUtilProxy::Touch( | 218 bool FileSystemFileUtilProxy::Touch( |
219 MessageLoopProxy* message_loop_proxy, | 219 base::TaskRunner* task_runner, |
220 FileSystemOperationContext* context, | 220 FileSystemOperationContext* context, |
221 FileSystemFileUtil* file_util, | 221 FileSystemFileUtil* file_util, |
222 const FileSystemPath& path, | 222 const FileSystemPath& path, |
223 const base::Time& last_access_time, | 223 const base::Time& last_access_time, |
224 const base::Time& last_modified_time, | 224 const base::Time& last_modified_time, |
225 const StatusCallback& callback) { | 225 const StatusCallback& callback) { |
226 return base::FileUtilProxy::RelayFileTask( | 226 return base::FileUtilProxy::RelayFileTask( |
227 message_loop_proxy, FROM_HERE, | 227 task_runner, FROM_HERE, |
228 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), | 228 Bind(&FileSystemFileUtil::Touch, Unretained(file_util), |
229 context, path, last_access_time, last_modified_time), | 229 context, path, last_access_time, last_modified_time), |
230 callback); | 230 callback); |
231 } | 231 } |
232 | 232 |
233 // static | 233 // static |
234 bool FileSystemFileUtilProxy::Truncate( | 234 bool FileSystemFileUtilProxy::Truncate( |
235 MessageLoopProxy* message_loop_proxy, | 235 base::TaskRunner* task_runner, |
236 FileSystemOperationContext* context, | 236 FileSystemOperationContext* context, |
237 FileSystemFileUtil* file_util, | 237 FileSystemFileUtil* file_util, |
238 const FileSystemPath& path, | 238 const FileSystemPath& path, |
239 int64 length, | 239 int64 length, |
240 const StatusCallback& callback) { | 240 const StatusCallback& callback) { |
241 return base::FileUtilProxy::RelayFileTask( | 241 return base::FileUtilProxy::RelayFileTask( |
242 message_loop_proxy, FROM_HERE, | 242 task_runner, FROM_HERE, |
243 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), | 243 Bind(&FileSystemFileUtil::Truncate, Unretained(file_util), |
244 context, path, length), | 244 context, path, length), |
245 callback); | 245 callback); |
246 } | 246 } |
247 | 247 |
248 } // namespace fileapi | 248 } // namespace fileapi |
OLD | NEW |