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

Side by Side Diff: chrome/browser/sync/test/integration/single_client_directory_sync_test.cc

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "base/message_loop/message_loop.h" 5 #include "base/location.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/single_thread_task_runner.h"
7 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
8 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/thread_task_runner_handle.h"
9 #include "base/time/time.h" 11 #include "base/time/time.h"
10 #include "chrome/browser/sync/profile_sync_service.h" 12 #include "chrome/browser/sync/profile_sync_service.h"
11 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 13 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
12 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h" 14 #include "chrome/browser/sync/test/integration/single_client_status_change_check er.h"
13 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" 15 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h"
14 #include "chrome/browser/sync/test/integration/sync_test.h" 16 #include "chrome/browser/sync/test/integration/sync_test.h"
15 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
16 #include "sync/syncable/directory.h" 18 #include "sync/syncable/directory.h"
17 #include "sync/test/directory_backing_store_corruption_testing.h" 19 #include "sync/test/directory_backing_store_corruption_testing.h"
18 #include "url/gurl.h" 20 #include "url/gurl.h"
(...skipping 11 matching lines...) Expand all
30 private: 32 private:
31 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest); 33 DISALLOW_COPY_AND_ASSIGN(SingleClientDirectorySyncTest);
32 }; 34 };
33 35
34 void SignalEvent(base::WaitableEvent* e) { 36 void SignalEvent(base::WaitableEvent* e) {
35 e->Signal(); 37 e->Signal();
36 } 38 }
37 39
38 bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) { 40 bool WaitForExistingTasksOnLoop(base::MessageLoop* loop) {
39 base::WaitableEvent e(true, false); 41 base::WaitableEvent e(true, false);
40 loop->PostTask(FROM_HERE, base::Bind(&SignalEvent, &e)); 42 loop->task_runner()->PostTask(FROM_HERE, base::Bind(&SignalEvent, &e));
41 // Timeout stolen from StatusChangeChecker::GetTimeoutDuration(). 43 // Timeout stolen from StatusChangeChecker::GetTimeoutDuration().
42 return e.TimedWait(base::TimeDelta::FromSeconds(45)); 44 return e.TimedWait(base::TimeDelta::FromSeconds(45));
43 } 45 }
44 46
45 // A status change checker that waits for an unrecoverable sync error to occur. 47 // A status change checker that waits for an unrecoverable sync error to occur.
46 class SyncUnrecoverableErrorChecker : public SingleClientStatusChangeChecker { 48 class SyncUnrecoverableErrorChecker : public SingleClientStatusChangeChecker {
47 public: 49 public:
48 explicit SyncUnrecoverableErrorChecker(ProfileSyncService* service) 50 explicit SyncUnrecoverableErrorChecker(ProfileSyncService* service)
49 : SingleClientStatusChangeChecker(service) {} 51 : SingleClientStatusChangeChecker(service) {}
50 52
(...skipping 10 matching lines...) Expand all
61 StopThenDisableDeletesDirectory) { 63 StopThenDisableDeletesDirectory) {
62 ASSERT_TRUE(SetupSync()) << "SetupSync() failed."; 64 ASSERT_TRUE(SetupSync()) << "SetupSync() failed.";
63 ProfileSyncService* sync_service = GetSyncService(0); 65 ProfileSyncService* sync_service = GetSyncService(0);
64 base::FilePath directory_path = sync_service->GetDirectoryPathForTest(); 66 base::FilePath directory_path = sync_service->GetDirectoryPathForTest();
65 ASSERT_TRUE(base::DirectoryExists(directory_path)); 67 ASSERT_TRUE(base::DirectoryExists(directory_path));
66 sync_service->RequestStop(); 68 sync_service->RequestStop();
67 sync_service->DisableForUser(); 69 sync_service->DisableForUser();
68 70
69 // Wait for StartupController::StartUp()'s tasks to finish. 71 // Wait for StartupController::StartUp()'s tasks to finish.
70 base::RunLoop run_loop; 72 base::RunLoop run_loop;
71 base::MessageLoop::current()->PostTask(FROM_HERE, run_loop.QuitClosure()); 73 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
74 run_loop.QuitClosure());
72 run_loop.Run(); 75 run_loop.Run();
73 // Wait for the directory deletion to finish. 76 // Wait for the directory deletion to finish.
74 base::MessageLoop* sync_loop = sync_service->GetSyncLoopForTest(); 77 base::MessageLoop* sync_loop = sync_service->GetSyncLoopForTest();
75 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); 78 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop));
76 79
77 ASSERT_FALSE(base::DirectoryExists(directory_path)); 80 ASSERT_FALSE(base::DirectoryExists(directory_path));
78 } 81 }
79 82
80 // Verify that when the sync directory's backing store becomes corrupted, we 83 // Verify that when the sync directory's backing store becomes corrupted, we
81 // trigger an unrecoverable error and delete the database. 84 // trigger an unrecoverable error and delete the database.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 SyncUnrecoverableErrorChecker checker(sync_service); 122 SyncUnrecoverableErrorChecker checker(sync_service);
120 checker.Wait(); 123 checker.Wait();
121 ASSERT_TRUE(!checker.TimedOut()); 124 ASSERT_TRUE(!checker.TimedOut());
122 ASSERT_TRUE(sync_service->HasUnrecoverableError()); 125 ASSERT_TRUE(sync_service->HasUnrecoverableError());
123 126
124 // Wait until the sync loop has processed any existing tasks and see that the 127 // Wait until the sync loop has processed any existing tasks and see that the
125 // directory no longer exists. 128 // directory no longer exists.
126 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop)); 129 ASSERT_TRUE(WaitForExistingTasksOnLoop(sync_loop));
127 ASSERT_FALSE(base::DirectoryExists(directory_path)); 130 ASSERT_FALSE(base::DirectoryExists(directory_path));
128 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698