| 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 "chrome/browser/sync_file_system/sync_file_system_service.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 SyncStatusCode status, | 66 SyncStatusCode status, |
| 67 typename AssignTrait<R>::ArgumentType value) { | 67 typename AssignTrait<R>::ArgumentType value) { |
| 68 DCHECK(status_out); | 68 DCHECK(status_out); |
| 69 DCHECK(value_out); | 69 DCHECK(value_out); |
| 70 DCHECK(run_loop); | 70 DCHECK(run_loop); |
| 71 *status_out = status; | 71 *status_out = status; |
| 72 *value_out = value; | 72 *value_out = value; |
| 73 run_loop->Quit(); | 73 run_loop->Quit(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // This is called on IO thread. Posts |callback| to be called on UI thread. | 76 // This is called on IO thread. |
| 77 void VerifyFileError(base::Closure callback, | 77 void VerifyFileError(base::RunLoop* run_loop, |
| 78 base::File::Error error) { | 78 base::File::Error error) { |
| 79 DCHECK(run_loop); |
| 79 EXPECT_EQ(base::File::FILE_OK, error); | 80 EXPECT_EQ(base::File::FILE_OK, error); |
| 80 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 81 run_loop->Quit(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // namespace | 84 } // namespace |
| 84 | 85 |
| 85 class MockSyncEventObserver : public SyncEventObserver { | 86 class MockSyncEventObserver : public SyncEventObserver { |
| 86 public: | 87 public: |
| 87 MockSyncEventObserver() {} | 88 MockSyncEventObserver() {} |
| 88 virtual ~MockSyncEventObserver() {} | 89 virtual ~MockSyncEventObserver() {} |
| 89 | 90 |
| 90 MOCK_METHOD3(OnSyncStateUpdated, | 91 MOCK_METHOD3(OnSyncStateUpdated, |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); | 423 mock_remote_service()->NotifyRemoteChangeQueueUpdated(1); |
| 423 | 424 |
| 424 // Start a local operation on the same file (to make it BUSY). | 425 // Start a local operation on the same file (to make it BUSY). |
| 425 base::RunLoop verify_file_error_run_loop; | 426 base::RunLoop verify_file_error_run_loop; |
| 426 BrowserThread::PostTask( | 427 BrowserThread::PostTask( |
| 427 BrowserThread::IO, | 428 BrowserThread::IO, |
| 428 FROM_HERE, | 429 FROM_HERE, |
| 429 base::Bind(&CannedSyncableFileSystem::DoCreateFile, | 430 base::Bind(&CannedSyncableFileSystem::DoCreateFile, |
| 430 base::Unretained(file_system_.get()), | 431 base::Unretained(file_system_.get()), |
| 431 kFile, base::Bind(&VerifyFileError, | 432 kFile, base::Bind(&VerifyFileError, |
| 432 verify_file_error_run_loop.QuitClosure()))); | 433 &verify_file_error_run_loop))); |
| 433 | 434 |
| 434 run_loop.Run(); | 435 run_loop.Run(); |
| 435 | 436 |
| 436 mock_remote_service()->NotifyRemoteChangeQueueUpdated(0); | 437 mock_remote_service()->NotifyRemoteChangeQueueUpdated(0); |
| 437 | 438 |
| 438 verify_file_error_run_loop.Run(); | 439 verify_file_error_run_loop.Run(); |
| 439 } | 440 } |
| 440 | 441 |
| 441 #if defined(THREAD_SANITIZER) | 442 #if defined(THREAD_SANITIZER) |
| 442 // SyncFileSystemServiceTest.GetFileSyncStatus fails under ThreadSanitizer, | 443 // SyncFileSystemServiceTest.GetFileSyncStatus fails under ThreadSanitizer, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 base::Bind(&AssignValueAndQuit<SyncFileStatus>, | 481 base::Bind(&AssignValueAndQuit<SyncFileStatus>, |
| 481 &run_loop, &status, &sync_file_status)); | 482 &run_loop, &status, &sync_file_status)); |
| 482 run_loop.Run(); | 483 run_loop.Run(); |
| 483 | 484 |
| 484 EXPECT_EQ(SYNC_STATUS_OK, status); | 485 EXPECT_EQ(SYNC_STATUS_OK, status); |
| 485 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); | 486 EXPECT_EQ(SYNC_FILE_STATUS_HAS_PENDING_CHANGES, sync_file_status); |
| 486 } | 487 } |
| 487 } | 488 } |
| 488 | 489 |
| 489 } // namespace sync_file_system | 490 } // namespace sync_file_system |
| OLD | NEW |