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

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

Issue 1421003007: [Sync] Componentize ProfileSyncComponentsFactoryImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser_tests Created 5 years, 1 month 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"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 syncer::WeakHandle<syncer::JsEventHandler> 119 syncer::WeakHandle<syncer::JsEventHandler>
120 TestProfileSyncService::GetJsEventHandler() { 120 TestProfileSyncService::GetJsEventHandler() {
121 return syncer::WeakHandle<syncer::JsEventHandler>(); 121 return syncer::WeakHandle<syncer::JsEventHandler>();
122 } 122 }
123 123
124 TestProfileSyncService::TestProfileSyncService( 124 TestProfileSyncService::TestProfileSyncService(
125 Profile* profile, 125 Profile* profile,
126 SigninManagerBase* signin, 126 SigninManagerBase* signin,
127 ProfileOAuth2TokenService* oauth2_token_service, 127 ProfileOAuth2TokenService* oauth2_token_service,
128 browser_sync::ProfileSyncServiceStartBehavior behavior) 128 browser_sync::ProfileSyncServiceStartBehavior behavior)
129 : ProfileSyncService(make_scoped_ptr(new browser_sync::ChromeSyncClient( 129 : ProfileSyncService(
130 profile, 130 make_scoped_ptr(new browser_sync::ChromeSyncClient(profile)),
131 make_scoped_ptr(new SyncApiComponentFactoryMock))), 131 make_scoped_ptr(new SigninManagerWrapper(signin)),
132 make_scoped_ptr(new SigninManagerWrapper(signin)), 132 oauth2_token_service,
133 oauth2_token_service, 133 behavior,
134 behavior, 134 base::Bind(&EmptyNetworkTimeUpdate),
135 base::Bind(&EmptyNetworkTimeUpdate), 135 profile->GetPath(),
136 profile->GetPath(), 136 profile->GetRequestContext(),
137 profile->GetRequestContext(), 137 profile->GetDebugName(),
138 profile->GetDebugName(), 138 chrome::GetChannel(),
139 chrome::GetChannel(), 139 content::BrowserThread::GetMessageLoopProxyForThread(
140 content::BrowserThread::GetMessageLoopProxyForThread( 140 content::BrowserThread::DB),
141 content::BrowserThread::DB), 141 content::BrowserThread::GetMessageLoopProxyForThread(
142 content::BrowserThread::GetMessageLoopProxyForThread( 142 content::BrowserThread::FILE),
143 content::BrowserThread::FILE), 143 content::BrowserThread::GetBlockingPool()) {
144 content::BrowserThread::GetBlockingPool()) { 144 GetSyncClient()->Initialize(
145 make_scoped_ptr(new SyncApiComponentFactoryMock()), this);
145 SetSyncSetupCompleted(); 146 SetSyncSetupCompleted();
146 } 147 }
147 148
148 TestProfileSyncService::~TestProfileSyncService() { 149 TestProfileSyncService::~TestProfileSyncService() {
149 } 150 }
150 151
151 // static 152 // static
152 scoped_ptr<KeyedService> TestProfileSyncService::TestFactoryFunction( 153 scoped_ptr<KeyedService> TestProfileSyncService::TestFactoryFunction(
153 content::BrowserContext* context) { 154 content::BrowserContext* context) {
154 Profile* profile = static_cast<Profile*>(context); 155 Profile* profile = static_cast<Profile*>(context);
155 SigninManagerBase* signin = 156 SigninManagerBase* signin =
156 SigninManagerFactory::GetForProfile(profile); 157 SigninManagerFactory::GetForProfile(profile);
157 ProfileOAuth2TokenService* oauth2_token_service = 158 ProfileOAuth2TokenService* oauth2_token_service =
158 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 159 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
159 return make_scoped_ptr(new TestProfileSyncService( 160 return make_scoped_ptr(new TestProfileSyncService(
160 profile, signin, oauth2_token_service, browser_sync::AUTO_START)); 161 profile, signin, oauth2_token_service, browser_sync::AUTO_START));
161 } 162 }
162 163
163 // static 164 // static
164 TestProfileSyncService* TestProfileSyncService::BuildAutoStartAsyncInit( 165 TestProfileSyncService* TestProfileSyncService::BuildAutoStartAsyncInit(
165 Profile* profile, base::Closure callback) { 166 Profile* profile, base::Closure callback) {
166 TestProfileSyncService* sync_service = static_cast<TestProfileSyncService*>( 167 TestProfileSyncService* sync_service = static_cast<TestProfileSyncService*>(
167 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 168 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
168 profile, &TestProfileSyncService::TestFactoryFunction)); 169 profile, &TestProfileSyncService::TestFactoryFunction));
169 SyncApiComponentFactoryMock* components = 170 SyncApiComponentFactoryMock* components =
170 sync_service->GetSyncApiComponentFactoryMock(); 171 sync_service->GetSyncApiComponentFactoryMock();
171 // TODO(tim): Convert to a fake instead of mock. 172 // TODO(tim): Convert to a fake instead of mock.
172 EXPECT_CALL(*components, 173 EXPECT_CALL(*components, CreateSyncBackendHost(testing::_, testing::_,
173 CreateSyncBackendHost(testing::_, testing::_, testing::_, 174 testing::_, testing::_))
174 testing::_, testing::_))
175 .WillOnce( 175 .WillOnce(
176 testing::Return(new browser_sync::SyncBackendHostForProfileSyncTest( 176 testing::Return(new browser_sync::SyncBackendHostForProfileSyncTest(
177 profile, sync_service->GetSyncClient(), 177 profile, sync_service->GetSyncClient(),
178 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 178 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
179 invalidation::ProfileInvalidationProviderFactory::GetForProfile( 179 invalidation::ProfileInvalidationProviderFactory::GetForProfile(
180 profile) 180 profile)
181 ->GetInvalidationService(), 181 ->GetInvalidationService(),
182 sync_service->sync_prefs_.AsWeakPtr(), callback))); 182 sync_service->sync_prefs_.AsWeakPtr(), callback)));
183 return sync_service; 183 return sync_service;
184 } 184 }
(...skipping 11 matching lines...) Expand all
196 base::MessageLoop::current()->QuitWhenIdle(); 196 base::MessageLoop::current()->QuitWhenIdle();
197 } 197 }
198 198
199 UserShare* TestProfileSyncService::GetUserShare() const { 199 UserShare* TestProfileSyncService::GetUserShare() const {
200 return backend_->GetUserShare(); 200 return backend_->GetUserShare();
201 } 201 }
202 202
203 bool TestProfileSyncService::NeedBackup() const { 203 bool TestProfileSyncService::NeedBackup() const {
204 return false; 204 return false;
205 } 205 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698