| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 177 } |
| 178 | 178 |
| 179 void StartModifyFileOnIOThread(CannedSyncableFileSystem* file_system, | 179 void StartModifyFileOnIOThread(CannedSyncableFileSystem* file_system, |
| 180 const FileSystemURL& url) { | 180 const FileSystemURL& url) { |
| 181 ASSERT_TRUE(file_system != nullptr); | 181 ASSERT_TRUE(file_system != nullptr); |
| 182 if (!io_task_runner_->RunsTasksOnCurrentThread()) { | 182 if (!io_task_runner_->RunsTasksOnCurrentThread()) { |
| 183 async_modify_finished_ = false; | 183 async_modify_finished_ = false; |
| 184 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); | 184 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 185 io_task_runner_->PostTask( | 185 io_task_runner_->PostTask( |
| 186 FROM_HERE, | 186 FROM_HERE, |
| 187 base::Bind(&LocalFileSyncContextTest::StartModifyFileOnIOThread, | 187 base::BindOnce(&LocalFileSyncContextTest::StartModifyFileOnIOThread, |
| 188 base::Unretained(this), file_system, url)); | 188 base::Unretained(this), file_system, url)); |
| 189 return; | 189 return; |
| 190 } | 190 } |
| 191 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 191 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 192 file_error_ = base::File::FILE_ERROR_FAILED; | 192 file_error_ = base::File::FILE_ERROR_FAILED; |
| 193 file_system->operation_runner()->Truncate( | 193 file_system->operation_runner()->Truncate( |
| 194 url, 1, base::Bind(&LocalFileSyncContextTest::DidModifyFile, | 194 url, 1, base::Bind(&LocalFileSyncContextTest::DidModifyFile, |
| 195 base::Unretained(this))); | 195 base::Unretained(this))); |
| 196 } | 196 } |
| 197 | 197 |
| 198 base::File::Error WaitUntilModifyFileIsDone() { | 198 base::File::Error WaitUntilModifyFileIsDone() { |
| 199 while (!async_modify_finished_) | 199 while (!async_modify_finished_) |
| 200 base::RunLoop().RunUntilIdle(); | 200 base::RunLoop().RunUntilIdle(); |
| 201 return file_error_; | 201 return file_error_; |
| 202 } | 202 } |
| 203 | 203 |
| 204 void DidModifyFile(base::File::Error error) { | 204 void DidModifyFile(base::File::Error error) { |
| 205 if (!ui_task_runner_->RunsTasksOnCurrentThread()) { | 205 if (!ui_task_runner_->RunsTasksOnCurrentThread()) { |
| 206 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); | 206 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); |
| 207 ui_task_runner_->PostTask( | 207 ui_task_runner_->PostTask( |
| 208 FROM_HERE, | 208 FROM_HERE, base::BindOnce(&LocalFileSyncContextTest::DidModifyFile, |
| 209 base::Bind(&LocalFileSyncContextTest::DidModifyFile, | 209 base::Unretained(this), error)); |
| 210 base::Unretained(this), error)); | |
| 211 return; | 210 return; |
| 212 } | 211 } |
| 213 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); | 212 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 214 file_error_ = error; | 213 file_error_ = error; |
| 215 async_modify_finished_ = true; | 214 async_modify_finished_ = true; |
| 216 } | 215 } |
| 217 | 216 |
| 218 void SimulateFinishSync(FileSystemContext* file_system_context, | 217 void SimulateFinishSync(FileSystemContext* file_system_context, |
| 219 const FileSystemURL& url, | 218 const FileSystemURL& url, |
| 220 SyncStatusCode status, | 219 SyncStatusCode status, |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 | 952 |
| 954 // Make sure kDir and kFile are created by ApplyRemoteChange. | 953 // Make sure kDir and kFile are created by ApplyRemoteChange. |
| 955 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile)); | 954 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile)); |
| 956 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir)); | 955 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir)); |
| 957 | 956 |
| 958 sync_context_->ShutdownOnUIThread(); | 957 sync_context_->ShutdownOnUIThread(); |
| 959 file_system.TearDown(); | 958 file_system.TearDown(); |
| 960 } | 959 } |
| 961 | 960 |
| 962 } // namespace sync_file_system | 961 } // namespace sync_file_system |
| OLD | NEW |