diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc | 19 | ||||
-rw-r--r-- | webkit/browser/fileapi/syncable/syncable_file_system_operation.cc | 3 |
2 files changed, 20 insertions, 2 deletions
diff --git a/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc b/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc index 26567cc..9f2d871 100644 --- a/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc +++ b/webkit/browser/fileapi/syncable/syncable_file_operation_runner_unittest.cc @@ -368,4 +368,23 @@ TEST_F(SyncableFileOperationRunnerTest, CopyInForeignFile) { EXPECT_EQ(1, callback_count_); } +TEST_F(SyncableFileOperationRunnerTest, Cancel) { + // Prepare a file. + file_system_.NewOperation()->CreateFile( + URL(kFile), false /* exclusive */, + ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); + base::MessageLoop::current()->RunUntilIdle(); + EXPECT_EQ(1, callback_count_); + + // Run Truncate and immediately cancel. This shouldn't crash. + ResetCallbackStatus(); + FileSystemOperation* operation = file_system_.NewOperation(); + operation->Truncate( + URL(kFile), 10, + ExpectStatus(FROM_HERE, base::PLATFORM_FILE_ERROR_ABORT)); + operation->Cancel(ExpectStatus(FROM_HERE, base::PLATFORM_FILE_OK)); + base::MessageLoop::current()->RunUntilIdle(); + EXPECT_EQ(2, callback_count_); +} + } // namespace sync_file_system diff --git a/webkit/browser/fileapi/syncable/syncable_file_system_operation.cc b/webkit/browser/fileapi/syncable/syncable_file_system_operation.cc index 73b18fb..25d4a2d 100644 --- a/webkit/browser/fileapi/syncable/syncable_file_system_operation.cc +++ b/webkit/browser/fileapi/syncable/syncable_file_system_operation.cc @@ -304,8 +304,7 @@ void SyncableFileSystemOperation::Cancel( const StatusCallback& cancel_callback) { DCHECK(CalledOnValidThread()); DCHECK(inflight_operation_); - completion_callback_ = cancel_callback; - NewOperation()->Cancel(base::Bind(&self::DidFinish, base::Owned(this))); + inflight_operation_->Cancel(cancel_callback); } void SyncableFileSystemOperation::CreateSnapshotFile( |