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

Side by Side Diff: chrome/browser/sync/test_profile_sync_service.cc

Issue 1310553005: [Sync] Replace ProfileSyncComponentsFactory with SyncClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really fix GN Created 5 years, 3 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) 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/test_profile_sync_service.h" 5 #include "chrome/browser/sync/test_profile_sync_service.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 12 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
15 #include "chrome/browser/signin/signin_manager_factory.h" 15 #include "chrome/browser/signin/signin_manager_factory.h"
16 #include "chrome/browser/sync/glue/sync_backend_host.h" 16 #include "chrome/browser/sync/glue/sync_backend_host.h"
17 #include "chrome/browser/sync/glue/sync_backend_host_core.h" 17 #include "chrome/browser/sync/glue/sync_backend_host_core.h"
18 #include "chrome/browser/sync/profile_sync_components_factory_mock.h" 18 #include "chrome/browser/sync/profile_sync_components_factory_mock.h"
19 #include "chrome/browser/sync/profile_sync_service_factory.h" 19 #include "chrome/browser/sync/profile_sync_service_factory.h"
20 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" 20 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
21 #include "chrome/browser/sync/test/test_http_bridge_factory.h" 21 #include "chrome/browser/sync/test/test_http_bridge_factory.h"
22 #include "components/invalidation/impl/profile_invalidation_provider.h" 22 #include "components/invalidation/impl/profile_invalidation_provider.h"
23 #include "components/signin/core/browser/signin_manager.h" 23 #include "components/signin/core/browser/signin_manager.h"
24 #include "components/sync_driver/profile_sync_components_factory.h"
25 #include "google_apis/gaia/gaia_constants.h" 24 #include "google_apis/gaia/gaia_constants.h"
26 #include "sync/internal_api/public/test/sync_manager_factory_for_profile_sync_te st.h" 25 #include "sync/internal_api/public/test/sync_manager_factory_for_profile_sync_te st.h"
27 #include "sync/internal_api/public/test/test_internal_components_factory.h" 26 #include "sync/internal_api/public/test/test_internal_components_factory.h"
28 #include "sync/internal_api/public/user_share.h" 27 #include "sync/internal_api/public/user_share.h"
29 #include "sync/protocol/encryption.pb.h" 28 #include "sync/protocol/encryption.pb.h"
30 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
31 30
32 using syncer::InternalComponentsFactory; 31 using syncer::InternalComponentsFactory;
33 using syncer::TestInternalComponentsFactory; 32 using syncer::TestInternalComponentsFactory;
34 using syncer::UserShare; 33 using syncer::UserShare;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 syncer::TestIdFactory* TestProfileSyncService::id_factory() { 104 syncer::TestIdFactory* TestProfileSyncService::id_factory() {
106 return &id_factory_; 105 return &id_factory_;
107 } 106 }
108 107
109 syncer::WeakHandle<syncer::JsEventHandler> 108 syncer::WeakHandle<syncer::JsEventHandler>
110 TestProfileSyncService::GetJsEventHandler() { 109 TestProfileSyncService::GetJsEventHandler() {
111 return syncer::WeakHandle<syncer::JsEventHandler>(); 110 return syncer::WeakHandle<syncer::JsEventHandler>();
112 } 111 }
113 112
114 TestProfileSyncService::TestProfileSyncService( 113 TestProfileSyncService::TestProfileSyncService(
115 scoped_ptr<ProfileSyncComponentsFactory> factory, 114 scoped_ptr<sync_driver::SyncApiComponentFactory> factory,
116 Profile* profile, 115 Profile* profile,
117 SigninManagerBase* signin, 116 SigninManagerBase* signin,
118 ProfileOAuth2TokenService* oauth2_token_service, 117 ProfileOAuth2TokenService* oauth2_token_service,
119 browser_sync::ProfileSyncServiceStartBehavior behavior) 118 browser_sync::ProfileSyncServiceStartBehavior behavior)
120 : ProfileSyncService( 119 : ProfileSyncService(
121 factory.Pass(), 120 factory.Pass(),
122 profile, 121 profile,
123 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile, 122 make_scoped_ptr(new SupervisedUserSigninManagerWrapper(profile,
124 signin)), 123 signin)),
125 oauth2_token_service, 124 oauth2_token_service,
126 behavior) { 125 behavior) {
127 SetSyncSetupCompleted(); 126 SetSyncSetupCompleted();
128 } 127 }
129 128
130 TestProfileSyncService::~TestProfileSyncService() { 129 TestProfileSyncService::~TestProfileSyncService() {
131 } 130 }
132 131
133 // static 132 // static
134 scoped_ptr<KeyedService> TestProfileSyncService::TestFactoryFunction( 133 scoped_ptr<KeyedService> TestProfileSyncService::TestFactoryFunction(
135 content::BrowserContext* context) { 134 content::BrowserContext* context) {
136 Profile* profile = static_cast<Profile*>(context); 135 Profile* profile = static_cast<Profile*>(context);
137 SigninManagerBase* signin = 136 SigninManagerBase* signin =
138 SigninManagerFactory::GetForProfile(profile); 137 SigninManagerFactory::GetForProfile(profile);
139 ProfileOAuth2TokenService* oauth2_token_service = 138 ProfileOAuth2TokenService* oauth2_token_service =
140 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 139 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
141 return make_scoped_ptr(new TestProfileSyncService( 140 return make_scoped_ptr(new TestProfileSyncService(
142 scoped_ptr<ProfileSyncComponentsFactory>( 141 scoped_ptr<sync_driver::SyncApiComponentFactory>(
143 new ProfileSyncComponentsFactoryMock()), 142 new ProfileSyncComponentsFactoryMock()),
144 profile, signin, oauth2_token_service, browser_sync::AUTO_START)); 143 profile, signin, oauth2_token_service, browser_sync::AUTO_START));
145 } 144 }
146 145
147 // static 146 // static
148 TestProfileSyncService* TestProfileSyncService::BuildAutoStartAsyncInit( 147 TestProfileSyncService* TestProfileSyncService::BuildAutoStartAsyncInit(
149 Profile* profile, base::Closure callback) { 148 Profile* profile, base::Closure callback) {
150 TestProfileSyncService* sync_service = static_cast<TestProfileSyncService*>( 149 TestProfileSyncService* sync_service = static_cast<TestProfileSyncService*>(
151 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 150 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
152 profile, &TestProfileSyncService::TestFactoryFunction)); 151 profile, &TestProfileSyncService::TestFactoryFunction));
153 ProfileSyncComponentsFactoryMock* components = 152 ProfileSyncComponentsFactoryMock* components =
154 sync_service->components_factory_mock(); 153 sync_service->components_factory_mock();
155 // TODO(tim): Convert to a fake instead of mock. 154 // TODO(tim): Convert to a fake instead of mock.
156 EXPECT_CALL(*components, 155 EXPECT_CALL(*components,
157 CreateSyncBackendHost(testing::_,testing::_, testing::_, 156 CreateSyncBackendHost(testing::_, testing::_,
158 testing::_, testing::_)). 157 testing::_, testing::_)).
159 WillOnce(testing::Return( 158 WillOnce(testing::Return(
160 new browser_sync::SyncBackendHostForProfileSyncTest( 159 new browser_sync::SyncBackendHostForProfileSyncTest(
161 profile, 160 profile,
162 invalidation::ProfileInvalidationProviderFactory::GetForProfile( 161 invalidation::ProfileInvalidationProviderFactory::GetForProfile(
163 profile)->GetInvalidationService(), 162 profile)->GetInvalidationService(),
164 sync_service->sync_prefs_.AsWeakPtr(), 163 sync_service->sync_prefs_.AsWeakPtr(),
165 callback))); 164 callback)));
166 return sync_service; 165 return sync_service;
167 } 166 }
(...skipping 10 matching lines...) Expand all
178 base::MessageLoop::current()->Quit(); 177 base::MessageLoop::current()->Quit();
179 } 178 }
180 179
181 UserShare* TestProfileSyncService::GetUserShare() const { 180 UserShare* TestProfileSyncService::GetUserShare() const {
182 return backend_->GetUserShare(); 181 return backend_->GetUserShare();
183 } 182 }
184 183
185 bool TestProfileSyncService::NeedBackup() const { 184 bool TestProfileSyncService::NeedBackup() const {
186 return false; 185 return false;
187 } 186 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test_profile_sync_service.h ('k') | chrome/browser/ui/sync/one_click_signin_sync_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698