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

Side by Side Diff: webkit/browser/fileapi/async_file_util_adapter.cc

Issue 16413007: Make FileSystemOperation NOT self-destruct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix browser_tests Created 7 years, 6 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
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 #include "webkit/browser/fileapi/async_file_util_adapter.h" 5 #include "webkit/browser/fileapi/async_file_util_adapter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/sequenced_task_runner.h" 8 #include "base/sequenced_task_runner.h"
9 #include "base/task_runner_util.h" 9 #include "base/task_runner_util.h"
10 #include "webkit/browser/fileapi/file_system_context.h" 10 #include "webkit/browser/fileapi/file_system_context.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 AsyncFileUtilAdapter::AsyncFileUtilAdapter( 135 AsyncFileUtilAdapter::AsyncFileUtilAdapter(
136 FileSystemFileUtil* sync_file_util) 136 FileSystemFileUtil* sync_file_util)
137 : sync_file_util_(sync_file_util) { 137 : sync_file_util_(sync_file_util) {
138 DCHECK(sync_file_util_.get()); 138 DCHECK(sync_file_util_.get());
139 } 139 }
140 140
141 AsyncFileUtilAdapter::~AsyncFileUtilAdapter() { 141 AsyncFileUtilAdapter::~AsyncFileUtilAdapter() {
142 } 142 }
143 143
144 bool AsyncFileUtilAdapter::CreateOrOpen( 144 bool AsyncFileUtilAdapter::CreateOrOpen(
145 FileSystemOperationContext* context, 145 scoped_ptr<FileSystemOperationContext> context,
146 const FileSystemURL& url, 146 const FileSystemURL& url,
147 int file_flags, 147 int file_flags,
148 const CreateOrOpenCallback& callback) { 148 const CreateOrOpenCallback& callback) {
149 FileSystemOperationContext* context_ptr = context.release();
149 return base::FileUtilProxy::RelayCreateOrOpen( 150 return base::FileUtilProxy::RelayCreateOrOpen(
150 context->task_runner(), 151 context_ptr->task_runner(),
151 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(sync_file_util_.get()), 152 Bind(&FileSystemFileUtil::CreateOrOpen, Unretained(sync_file_util_.get()),
152 context, url, file_flags), 153 context_ptr, url, file_flags),
153 Bind(&FileSystemFileUtil::Close, Unretained(sync_file_util_.get()), 154 Bind(&FileSystemFileUtil::Close, Unretained(sync_file_util_.get()),
154 context), 155 base::Owned(context_ptr)),
155 callback); 156 callback);
156 } 157 }
157 158
158 bool AsyncFileUtilAdapter::EnsureFileExists( 159 bool AsyncFileUtilAdapter::EnsureFileExists(
159 FileSystemOperationContext* context, 160 scoped_ptr<FileSystemOperationContext> context,
160 const FileSystemURL& url, 161 const FileSystemURL& url,
161 const EnsureFileExistsCallback& callback) { 162 const EnsureFileExistsCallback& callback) {
162 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper; 163 EnsureFileExistsHelper* helper = new EnsureFileExistsHelper;
163 return context->task_runner()->PostTaskAndReply( 164 FileSystemOperationContext* context_ptr = context.release();
165 return context_ptr->task_runner()->PostTaskAndReply(
164 FROM_HERE, 166 FROM_HERE,
165 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper), 167 Bind(&EnsureFileExistsHelper::RunWork, Unretained(helper),
166 sync_file_util_.get(), context, url), 168 sync_file_util_.get(), base::Owned(context_ptr), url),
167 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback)); 169 Bind(&EnsureFileExistsHelper::Reply, Owned(helper), callback));
168 } 170 }
169 171
170 bool AsyncFileUtilAdapter::CreateDirectory( 172 bool AsyncFileUtilAdapter::CreateDirectory(
171 FileSystemOperationContext* context, 173 scoped_ptr<FileSystemOperationContext> context,
172 const FileSystemURL& url, 174 const FileSystemURL& url,
173 bool exclusive, 175 bool exclusive,
174 bool recursive, 176 bool recursive,
175 const StatusCallback& callback) { 177 const StatusCallback& callback) {
178 FileSystemOperationContext* context_ptr = context.release();
176 return base::PostTaskAndReplyWithResult( 179 return base::PostTaskAndReplyWithResult(
177 context->task_runner(), FROM_HERE, 180 context_ptr->task_runner(), FROM_HERE,
178 Bind(&FileSystemFileUtil::CreateDirectory, 181 Bind(&FileSystemFileUtil::CreateDirectory,
179 Unretained(sync_file_util_.get()), 182 Unretained(sync_file_util_.get()),
180 context, url, exclusive, recursive), 183 base::Owned(context_ptr), url, exclusive, recursive),
181 callback); 184 callback);
182 } 185 }
183 186
184 bool AsyncFileUtilAdapter::GetFileInfo( 187 bool AsyncFileUtilAdapter::GetFileInfo(
185 FileSystemOperationContext* context, 188 scoped_ptr<FileSystemOperationContext> context,
186 const FileSystemURL& url, 189 const FileSystemURL& url,
187 const GetFileInfoCallback& callback) { 190 const GetFileInfoCallback& callback) {
191 FileSystemOperationContext* context_ptr = context.release();
188 GetFileInfoHelper* helper = new GetFileInfoHelper; 192 GetFileInfoHelper* helper = new GetFileInfoHelper;
189 return context->task_runner()->PostTaskAndReply( 193 return context_ptr->task_runner()->PostTaskAndReply(
190 FROM_HERE, 194 FROM_HERE,
191 Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper), 195 Bind(&GetFileInfoHelper::GetFileInfo, Unretained(helper),
192 sync_file_util_.get(), context, url), 196 sync_file_util_.get(), base::Owned(context_ptr), url),
193 Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback)); 197 Bind(&GetFileInfoHelper::ReplyFileInfo, Owned(helper), callback));
194 } 198 }
195 199
196 bool AsyncFileUtilAdapter::ReadDirectory( 200 bool AsyncFileUtilAdapter::ReadDirectory(
197 FileSystemOperationContext* context, 201 scoped_ptr<FileSystemOperationContext> context,
198 const FileSystemURL& url, 202 const FileSystemURL& url,
199 const ReadDirectoryCallback& callback) { 203 const ReadDirectoryCallback& callback) {
204 FileSystemOperationContext* context_ptr = context.release();
200 ReadDirectoryHelper* helper = new ReadDirectoryHelper; 205 ReadDirectoryHelper* helper = new ReadDirectoryHelper;
201 return context->task_runner()->PostTaskAndReply( 206 return context_ptr->task_runner()->PostTaskAndReply(
202 FROM_HERE, 207 FROM_HERE,
203 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper), 208 Bind(&ReadDirectoryHelper::RunWork, Unretained(helper),
204 sync_file_util_.get(), context, url), 209 sync_file_util_.get(), base::Owned(context_ptr), url),
205 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback)); 210 Bind(&ReadDirectoryHelper::Reply, Owned(helper), callback));
206 } 211 }
207 212
208 bool AsyncFileUtilAdapter::Touch( 213 bool AsyncFileUtilAdapter::Touch(
209 FileSystemOperationContext* context, 214 scoped_ptr<FileSystemOperationContext> context,
210 const FileSystemURL& url, 215 const FileSystemURL& url,
211 const base::Time& last_access_time, 216 const base::Time& last_access_time,
212 const base::Time& last_modified_time, 217 const base::Time& last_modified_time,
213 const StatusCallback& callback) { 218 const StatusCallback& callback) {
219 FileSystemOperationContext* context_ptr = context.release();
214 return base::PostTaskAndReplyWithResult( 220 return base::PostTaskAndReplyWithResult(
215 context->task_runner(), FROM_HERE, 221 context_ptr->task_runner(), FROM_HERE,
216 Bind(&FileSystemFileUtil::Touch, Unretained(sync_file_util_.get()), 222 Bind(&FileSystemFileUtil::Touch, Unretained(sync_file_util_.get()),
217 context, url, last_access_time, last_modified_time), 223 base::Owned(context_ptr), url,
224 last_access_time, last_modified_time),
218 callback); 225 callback);
219 } 226 }
220 227
221 bool AsyncFileUtilAdapter::Truncate( 228 bool AsyncFileUtilAdapter::Truncate(
222 FileSystemOperationContext* context, 229 scoped_ptr<FileSystemOperationContext> context,
223 const FileSystemURL& url, 230 const FileSystemURL& url,
224 int64 length, 231 int64 length,
225 const StatusCallback& callback) { 232 const StatusCallback& callback) {
233 FileSystemOperationContext* context_ptr = context.release();
226 return base::PostTaskAndReplyWithResult( 234 return base::PostTaskAndReplyWithResult(
227 context->task_runner(), FROM_HERE, 235 context_ptr->task_runner(), FROM_HERE,
228 Bind(&FileSystemFileUtil::Truncate, Unretained(sync_file_util_.get()), 236 Bind(&FileSystemFileUtil::Truncate, Unretained(sync_file_util_.get()),
229 context, url, length), 237 base::Owned(context_ptr), url, length),
230 callback); 238 callback);
231 } 239 }
232 240
233 bool AsyncFileUtilAdapter::CopyFileLocal( 241 bool AsyncFileUtilAdapter::CopyFileLocal(
234 FileSystemOperationContext* context, 242 scoped_ptr<FileSystemOperationContext> context,
235 const FileSystemURL& src_url, 243 const FileSystemURL& src_url,
236 const FileSystemURL& dest_url, 244 const FileSystemURL& dest_url,
237 const StatusCallback& callback) { 245 const StatusCallback& callback) {
246 FileSystemOperationContext* context_ptr = context.release();
238 return base::PostTaskAndReplyWithResult( 247 return base::PostTaskAndReplyWithResult(
239 context->task_runner(), FROM_HERE, 248 context_ptr->task_runner(), FROM_HERE,
240 Bind(&FileSystemFileUtil::CopyOrMoveFile, 249 Bind(&FileSystemFileUtil::CopyOrMoveFile,
241 Unretained(sync_file_util_.get()), 250 Unretained(sync_file_util_.get()),
242 context, src_url, dest_url, true /* copy */), 251 base::Owned(context_ptr), src_url, dest_url, true /* copy */),
243 callback); 252 callback);
244 } 253 }
245 254
246 bool AsyncFileUtilAdapter::MoveFileLocal( 255 bool AsyncFileUtilAdapter::MoveFileLocal(
247 FileSystemOperationContext* context, 256 scoped_ptr<FileSystemOperationContext> context,
248 const FileSystemURL& src_url, 257 const FileSystemURL& src_url,
249 const FileSystemURL& dest_url, 258 const FileSystemURL& dest_url,
250 const StatusCallback& callback) { 259 const StatusCallback& callback) {
260 FileSystemOperationContext* context_ptr = context.release();
251 return base::PostTaskAndReplyWithResult( 261 return base::PostTaskAndReplyWithResult(
252 context->task_runner(), FROM_HERE, 262 context_ptr->task_runner(), FROM_HERE,
253 Bind(&FileSystemFileUtil::CopyOrMoveFile, 263 Bind(&FileSystemFileUtil::CopyOrMoveFile,
254 Unretained(sync_file_util_.get()), 264 Unretained(sync_file_util_.get()),
255 context, src_url, dest_url, false /* copy */), 265 base::Owned(context_ptr), src_url, dest_url, false /* copy */),
256 callback); 266 callback);
257 } 267 }
258 268
259 bool AsyncFileUtilAdapter::CopyInForeignFile( 269 bool AsyncFileUtilAdapter::CopyInForeignFile(
260 FileSystemOperationContext* context, 270 scoped_ptr<FileSystemOperationContext> context,
261 const base::FilePath& src_file_path, 271 const base::FilePath& src_file_path,
262 const FileSystemURL& dest_url, 272 const FileSystemURL& dest_url,
263 const StatusCallback& callback) { 273 const StatusCallback& callback) {
274 FileSystemOperationContext* context_ptr = context.release();
264 return base::PostTaskAndReplyWithResult( 275 return base::PostTaskAndReplyWithResult(
265 context->task_runner(), FROM_HERE, 276 context_ptr->task_runner(), FROM_HERE,
266 Bind(&FileSystemFileUtil::CopyInForeignFile, 277 Bind(&FileSystemFileUtil::CopyInForeignFile,
267 Unretained(sync_file_util_.get()), 278 Unretained(sync_file_util_.get()),
268 context, src_file_path, dest_url), 279 base::Owned(context_ptr), src_file_path, dest_url),
269 callback); 280 callback);
270 } 281 }
271 282
272 bool AsyncFileUtilAdapter::DeleteFile( 283 bool AsyncFileUtilAdapter::DeleteFile(
273 FileSystemOperationContext* context, 284 scoped_ptr<FileSystemOperationContext> context,
274 const FileSystemURL& url, 285 const FileSystemURL& url,
275 const StatusCallback& callback) { 286 const StatusCallback& callback) {
287 FileSystemOperationContext* context_ptr = context.release();
276 return base::PostTaskAndReplyWithResult( 288 return base::PostTaskAndReplyWithResult(
277 context->task_runner(), FROM_HERE, 289 context_ptr->task_runner(), FROM_HERE,
278 Bind(&FileSystemFileUtil::DeleteFile, 290 Bind(&FileSystemFileUtil::DeleteFile,
279 Unretained(sync_file_util_.get()), context, url), 291 Unretained(sync_file_util_.get()),
292 base::Owned(context_ptr), url),
280 callback); 293 callback);
281 } 294 }
282 295
283 bool AsyncFileUtilAdapter::DeleteDirectory( 296 bool AsyncFileUtilAdapter::DeleteDirectory(
284 FileSystemOperationContext* context, 297 scoped_ptr<FileSystemOperationContext> context,
285 const FileSystemURL& url, 298 const FileSystemURL& url,
286 const StatusCallback& callback) { 299 const StatusCallback& callback) {
300 FileSystemOperationContext* context_ptr = context.release();
287 return base::PostTaskAndReplyWithResult( 301 return base::PostTaskAndReplyWithResult(
288 context->task_runner(), FROM_HERE, 302 context_ptr->task_runner(), FROM_HERE,
289 Bind(&FileSystemFileUtil::DeleteDirectory, 303 Bind(&FileSystemFileUtil::DeleteDirectory,
290 Unretained(sync_file_util_.get()), 304 Unretained(sync_file_util_.get()),
291 context, url), 305 base::Owned(context_ptr), url),
292 callback); 306 callback);
293 } 307 }
294 308
295 bool AsyncFileUtilAdapter::CreateSnapshotFile( 309 bool AsyncFileUtilAdapter::CreateSnapshotFile(
296 FileSystemOperationContext* context, 310 scoped_ptr<FileSystemOperationContext> context,
297 const FileSystemURL& url, 311 const FileSystemURL& url,
298 const CreateSnapshotFileCallback& callback) { 312 const CreateSnapshotFileCallback& callback) {
313 FileSystemOperationContext* context_ptr = context.release();
299 GetFileInfoHelper* helper = new GetFileInfoHelper; 314 GetFileInfoHelper* helper = new GetFileInfoHelper;
300 return context->task_runner()->PostTaskAndReply( 315 return context_ptr->task_runner()->PostTaskAndReply(
301 FROM_HERE, 316 FROM_HERE,
302 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper), 317 Bind(&GetFileInfoHelper::CreateSnapshotFile, Unretained(helper),
303 sync_file_util_.get(), context, url), 318 sync_file_util_.get(), base::Owned(context_ptr), url),
304 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback)); 319 Bind(&GetFileInfoHelper::ReplySnapshotFile, Owned(helper), callback));
305 } 320 }
306 321
307 } // namespace fileapi 322 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/async_file_util_adapter.h ('k') | webkit/browser/fileapi/file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698