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/syncable/syncable_file_system_operation.h" | 5 #include "webkit/fileapi/syncable/syncable_file_system_operation.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "webkit/blob/shareable_file_reference.h" | 8 #include "webkit/blob/shareable_file_reference.h" |
9 #include "webkit/fileapi/file_system_context.h" | 9 #include "webkit/fileapi/file_system_context.h" |
10 #include "webkit/fileapi/file_system_url.h" | 10 #include "webkit/fileapi/file_system_url.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 const StatusCallback& cancel_callback) { | 307 const StatusCallback& cancel_callback) { |
308 DCHECK(CalledOnValidThread()); | 308 DCHECK(CalledOnValidThread()); |
309 DCHECK(file_system_operation_); | 309 DCHECK(file_system_operation_); |
310 completion_callback_ = cancel_callback; | 310 completion_callback_ = cancel_callback; |
311 file_system_operation_->Cancel( | 311 file_system_operation_->Cancel( |
312 base::Bind(&self::DidFinish, base::Owned(this))); | 312 base::Bind(&self::DidFinish, base::Owned(this))); |
313 } | 313 } |
314 | 314 |
315 LocalFileSystemOperation* | 315 LocalFileSystemOperation* |
316 SyncableFileSystemOperation::AsLocalFileSystemOperation() { | 316 SyncableFileSystemOperation::AsLocalFileSystemOperation() { |
317 NOTREACHED(); | 317 // This must be called for nested sub-task operations |
318 return NULL; | 318 // where we don't need extra task queueing. |
| 319 // Just return the internal file_system_operation_ and let this |
| 320 // instance goes away when the operation dies. |
| 321 file_system_operation_->set_termination_callback( |
| 322 base::Bind(&SyncableFileSystemOperation::Destruct, |
| 323 base::Unretained(this))); |
| 324 return file_system_operation_; |
319 } | 325 } |
320 | 326 |
321 void SyncableFileSystemOperation::CreateSnapshotFile( | 327 void SyncableFileSystemOperation::CreateSnapshotFile( |
322 const FileSystemURL& path, | 328 const FileSystemURL& path, |
323 const SnapshotFileCallback& callback) { | 329 const SnapshotFileCallback& callback) { |
324 DCHECK(CalledOnValidThread()); | 330 DCHECK(CalledOnValidThread()); |
325 if (!operation_runner_) { | 331 if (!operation_runner_) { |
326 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, | 332 callback.Run(base::PLATFORM_FILE_ERROR_NOT_FOUND, |
327 base::PlatformFileInfo(), FilePath(), NULL); | 333 base::PlatformFileInfo(), FilePath(), NULL); |
328 delete file_system_operation_; | 334 delete file_system_operation_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 387 } |
382 | 388 |
383 void SyncableFileSystemOperation::AbortOperation( | 389 void SyncableFileSystemOperation::AbortOperation( |
384 const StatusCallback& callback, | 390 const StatusCallback& callback, |
385 base::PlatformFileError error) { | 391 base::PlatformFileError error) { |
386 callback.Run(error); | 392 callback.Run(error); |
387 delete file_system_operation_; | 393 delete file_system_operation_; |
388 delete this; | 394 delete this; |
389 } | 395 } |
390 | 396 |
| 397 void SyncableFileSystemOperation::Destruct() { |
| 398 delete this; |
| 399 } |
| 400 |
391 } // namespace fileapi | 401 } // namespace fileapi |
OLD | NEW |