diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-07 14:02:09 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-07 14:02:09 +0000 |
commit | 566983eb4954d1615931d7c1aab0a91adedda799 (patch) | |
tree | a2e071a8d2d8d12da4bca53a0e770d2361cc6f16 /webkit | |
parent | b54fe454e42eee761a307595ee4b78b4685b051e (diff) | |
download | chromium_src-566983eb4954d1615931d7c1aab0a91adedda799.zip chromium_src-566983eb4954d1615931d7c1aab0a91adedda799.tar.gz chromium_src-566983eb4954d1615931d7c1aab0a91adedda799.tar.bz2 |
Cancelling SyncFS operation should not crash
BUG=247613
TEST=SyncableFileOperationRunnerTest.Cancel
Review URL: https://chromiumcodereview.appspot.com/16108005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204822 0039d316-1c4b-4281-b951-d872f2087c98
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( |