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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_impl_unittest.cc

Issue 2538023002: [Sync] Pass a TaskRunner into SBHI/SBHC, not a thread or message loop. (Closed)
Patch Set: Remove thread check in destructor. Created 4 years 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 "components/sync/driver/glue/sync_backend_host_impl.h" 5 #include "components/sync/driver/glue/sync_backend_host_impl.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 ~SyncBackendHostTest() override {} 160 ~SyncBackendHostTest() override {}
161 161
162 void SetUp() override { 162 void SetUp() override {
163 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 163 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
164 164
165 SyncPrefs::RegisterProfilePrefs(pref_service_.registry()); 165 SyncPrefs::RegisterProfilePrefs(pref_service_.registry());
166 166
167 sync_prefs_ = base::MakeUnique<SyncPrefs>(&pref_service_); 167 sync_prefs_ = base::MakeUnique<SyncPrefs>(&pref_service_);
168 sync_thread_.StartAndWaitForTesting(); 168 sync_thread_.StartAndWaitForTesting();
169 backend_ = base::MakeUnique<SyncBackendHostImpl>( 169 backend_ = base::MakeUnique<SyncBackendHostImpl>(
170 "dummyDebugName", &sync_client_, base::ThreadTaskRunnerHandle::Get(), 170 "dummyDebugName", &sync_client_, nullptr, sync_prefs_->AsWeakPtr(),
171 nullptr, sync_prefs_->AsWeakPtr(),
172 temp_dir_.GetPath().Append(base::FilePath(kTestSyncDir))); 171 temp_dir_.GetPath().Append(base::FilePath(kTestSyncDir)));
173 credentials_.account_id = "user@example.com"; 172 credentials_.account_id = "user@example.com";
174 credentials_.email = "user@example.com"; 173 credentials_.email = "user@example.com";
175 credentials_.sync_token = "sync_token"; 174 credentials_.sync_token = "sync_token";
176 credentials_.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope); 175 credentials_.scope_set.insert(GaiaConstants::kChromeSyncOAuth2Scope);
177 176
178 fake_manager_factory_ = 177 fake_manager_factory_ =
179 base::MakeUnique<FakeSyncManagerFactory>(&fake_manager_); 178 base::MakeUnique<FakeSyncManagerFactory>(&fake_manager_);
180 179
181 // These types are always implicitly enabled. 180 // These types are always implicitly enabled.
(...skipping 24 matching lines...) Expand all
206 // Synchronously initializes the backend. 205 // Synchronously initializes the backend.
207 void InitializeBackend(bool expect_success) { 206 void InitializeBackend(bool expect_success) {
208 EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, _, _, expect_success)) 207 EXPECT_CALL(mock_frontend_, OnBackendInitialized(_, _, _, expect_success))
209 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); 208 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
210 SyncBackendHost::HttpPostProviderFactoryGetter 209 SyncBackendHost::HttpPostProviderFactoryGetter
211 http_post_provider_factory_getter = 210 http_post_provider_factory_getter =
212 base::Bind(&NetworkResources::GetHttpPostProviderFactory, 211 base::Bind(&NetworkResources::GetHttpPostProviderFactory,
213 base::Unretained(network_resources_.get()), nullptr, 212 base::Unretained(network_resources_.get()), nullptr,
214 base::Bind(&EmptyNetworkTimeUpdate)); 213 base::Bind(&EmptyNetworkTimeUpdate));
215 backend_->Initialize( 214 backend_->Initialize(
216 &mock_frontend_, &sync_thread_, WeakHandle<JsEventHandler>(), 215 &mock_frontend_, sync_thread_.task_runner(),
217 GURL(std::string()), std::string(), credentials_, true, false, 216 WeakHandle<JsEventHandler>(), GURL(std::string()), std::string(),
218 base::FilePath(), std::move(fake_manager_factory_), 217 credentials_, true, false, base::FilePath(),
218 std::move(fake_manager_factory_),
219 MakeWeakHandle(test_unrecoverable_error_handler_.GetWeakPtr()), 219 MakeWeakHandle(test_unrecoverable_error_handler_.GetWeakPtr()),
220 base::Closure(), http_post_provider_factory_getter, 220 base::Closure(), http_post_provider_factory_getter,
221 std::move(saved_nigori_state_)); 221 std::move(saved_nigori_state_));
222 base::RunLoop run_loop; 222 base::RunLoop run_loop;
223 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 223 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
224 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::action_timeout()); 224 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::action_timeout());
225 run_loop.Run(); 225 run_loop.Run();
226 // |fake_manager_factory_|'s fake_manager() is set on the sync 226 // |fake_manager_factory_|'s fake_manager() is set on the sync
227 // thread, but we can rely on the message loop barriers to 227 // thread, but we can rely on the message loop barriers to
228 // guarantee that we see the updated value. 228 // guarantee that we see the updated value.
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 backend_->StopSyncingForShutdown(); 824 backend_->StopSyncingForShutdown();
825 // Verify that call to DeactivateNonBlockingDataType doesn't assert. 825 // Verify that call to DeactivateNonBlockingDataType doesn't assert.
826 backend_->DeactivateNonBlockingDataType(AUTOFILL); 826 backend_->DeactivateNonBlockingDataType(AUTOFILL);
827 backend_->Shutdown(STOP_SYNC); 827 backend_->Shutdown(STOP_SYNC);
828 backend_.reset(); 828 backend_.reset();
829 } 829 }
830 830
831 } // namespace 831 } // namespace
832 832
833 } // namespace syncer 833 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/glue/sync_backend_host_impl.cc ('k') | components/sync/driver/glue/sync_backend_host_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698