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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc

Issue 2871303004: Rename TaskRunner::RunsTasksOnCurrentThread() in //chrome (Closed)
Patch Set: fixed build error Created 3 years, 7 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
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 base::Unretained(file_system_context), 122 base::Unretained(file_system_context),
123 url, sync_mode, metadata, changes, snapshot); 123 url, sync_mode, metadata, changes, snapshot);
124 } 124 }
125 125
126 void DidPrepareForSync(SyncFileMetadata* metadata_out, 126 void DidPrepareForSync(SyncFileMetadata* metadata_out,
127 FileChangeList* changes_out, 127 FileChangeList* changes_out,
128 storage::ScopedFile* snapshot_out, 128 storage::ScopedFile* snapshot_out,
129 SyncStatusCode status, 129 SyncStatusCode status,
130 const LocalFileSyncInfo& sync_file_info, 130 const LocalFileSyncInfo& sync_file_info,
131 storage::ScopedFile snapshot) { 131 storage::ScopedFile snapshot) {
132 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); 132 ASSERT_TRUE(ui_task_runner_->RunsTasksInCurrentSequence());
133 has_inflight_prepare_for_sync_ = false; 133 has_inflight_prepare_for_sync_ = false;
134 status_ = status; 134 status_ = status;
135 *metadata_out = sync_file_info.metadata; 135 *metadata_out = sync_file_info.metadata;
136 *changes_out = sync_file_info.changes; 136 *changes_out = sync_file_info.changes;
137 if (snapshot_out) 137 if (snapshot_out)
138 *snapshot_out = std::move(snapshot); 138 *snapshot_out = std::move(snapshot);
139 base::MessageLoop::current()->QuitWhenIdle(); 139 base::MessageLoop::current()->QuitWhenIdle();
140 } 140 }
141 141
142 SyncStatusCode ApplyRemoteChange(FileSystemContext* file_system_context, 142 SyncStatusCode ApplyRemoteChange(FileSystemContext* file_system_context,
(...skipping 29 matching lines...) Expand all
172 status_ = status; 172 status_ = status;
173 sync_context_->FinalizeExclusiveSync( 173 sync_context_->FinalizeExclusiveSync(
174 file_system_context, url, 174 file_system_context, url,
175 status == SYNC_STATUS_OK /* clear_local_changes */, 175 status == SYNC_STATUS_OK /* clear_local_changes */,
176 base::MessageLoop::QuitWhenIdleClosure()); 176 base::MessageLoop::QuitWhenIdleClosure());
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_->RunsTasksInCurrentSequence()) {
183 async_modify_finished_ = false; 183 async_modify_finished_ = false;
184 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); 184 ASSERT_TRUE(ui_task_runner_->RunsTasksInCurrentSequence());
185 io_task_runner_->PostTask( 185 io_task_runner_->PostTask(
186 FROM_HERE, 186 FROM_HERE,
187 base::BindOnce(&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_->RunsTasksInCurrentSequence());
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_->RunsTasksInCurrentSequence()) {
206 ASSERT_TRUE(io_task_runner_->RunsTasksOnCurrentThread()); 206 ASSERT_TRUE(io_task_runner_->RunsTasksInCurrentSequence());
207 ui_task_runner_->PostTask( 207 ui_task_runner_->PostTask(
208 FROM_HERE, base::BindOnce(&LocalFileSyncContextTest::DidModifyFile, 208 FROM_HERE, base::BindOnce(&LocalFileSyncContextTest::DidModifyFile,
209 base::Unretained(this), error)); 209 base::Unretained(this), error));
210 return; 210 return;
211 } 211 }
212 ASSERT_TRUE(ui_task_runner_->RunsTasksOnCurrentThread()); 212 ASSERT_TRUE(ui_task_runner_->RunsTasksInCurrentSequence());
213 file_error_ = error; 213 file_error_ = error;
214 async_modify_finished_ = true; 214 async_modify_finished_ = true;
215 } 215 }
216 216
217 void SimulateFinishSync(FileSystemContext* file_system_context, 217 void SimulateFinishSync(FileSystemContext* file_system_context,
218 const FileSystemURL& url, 218 const FileSystemURL& url,
219 SyncStatusCode status, 219 SyncStatusCode status,
220 LocalFileSyncContext::SyncMode sync_mode) { 220 LocalFileSyncContext::SyncMode sync_mode) {
221 if (sync_mode == LocalFileSyncContext::SYNC_SNAPSHOT) { 221 if (sync_mode == LocalFileSyncContext::SYNC_SNAPSHOT) {
222 sync_context_->FinalizeSnapshotSync( 222 sync_context_->FinalizeSnapshotSync(
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 952
953 // Make sure kDir and kFile are created by ApplyRemoteChange. 953 // Make sure kDir and kFile are created by ApplyRemoteChange.
954 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile)); 954 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile));
955 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir)); 955 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir));
956 956
957 sync_context_->ShutdownOnUIThread(); 957 sync_context_->ShutdownOnUIThread();
958 file_system.TearDown(); 958 file_system.TearDown();
959 } 959 }
960 960
961 } // namespace sync_file_system 961 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698