| 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/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 Loading... |
| 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( | 129 : ProfileSyncService(make_scoped_ptr(new browser_sync::ChromeSyncClient( |
| 130 make_scoped_ptr(new browser_sync::ChromeSyncClient(profile)), | 130 profile, |
| 131 make_scoped_ptr(new SigninManagerWrapper(signin)), | 131 make_scoped_ptr(new SyncApiComponentFactoryMock))), |
| 132 oauth2_token_service, | 132 make_scoped_ptr(new SigninManagerWrapper(signin)), |
| 133 behavior, | 133 oauth2_token_service, |
| 134 base::Bind(&EmptyNetworkTimeUpdate), | 134 behavior, |
| 135 profile->GetPath(), | 135 base::Bind(&EmptyNetworkTimeUpdate), |
| 136 profile->GetRequestContext(), | 136 profile->GetPath(), |
| 137 profile->GetDebugName(), | 137 profile->GetRequestContext(), |
| 138 chrome::GetChannel(), | 138 profile->GetDebugName(), |
| 139 content::BrowserThread::GetMessageLoopProxyForThread( | 139 chrome::GetChannel(), |
| 140 content::BrowserThread::DB), | 140 content::BrowserThread::GetMessageLoopProxyForThread( |
| 141 content::BrowserThread::GetMessageLoopProxyForThread( | 141 content::BrowserThread::DB), |
| 142 content::BrowserThread::FILE), | 142 content::BrowserThread::GetMessageLoopProxyForThread( |
| 143 content::BrowserThread::GetBlockingPool()) { | 143 content::BrowserThread::FILE), |
| 144 static_cast<browser_sync::ChromeSyncClient*>(GetSyncClient()) | 144 content::BrowserThread::GetBlockingPool()) { |
| 145 ->SetSyncApiComponentFactoryForTesting( | |
| 146 make_scoped_ptr(new SyncApiComponentFactoryMock)); | |
| 147 SetSyncSetupCompleted(); | 145 SetSyncSetupCompleted(); |
| 148 } | 146 } |
| 149 | 147 |
| 150 TestProfileSyncService::~TestProfileSyncService() { | 148 TestProfileSyncService::~TestProfileSyncService() { |
| 151 } | 149 } |
| 152 | 150 |
| 153 // static | 151 // static |
| 154 scoped_ptr<KeyedService> TestProfileSyncService::TestFactoryFunction( | 152 scoped_ptr<KeyedService> TestProfileSyncService::TestFactoryFunction( |
| 155 content::BrowserContext* context) { | 153 content::BrowserContext* context) { |
| 156 Profile* profile = static_cast<Profile*>(context); | 154 Profile* profile = static_cast<Profile*>(context); |
| 157 SigninManagerBase* signin = | 155 SigninManagerBase* signin = |
| 158 SigninManagerFactory::GetForProfile(profile); | 156 SigninManagerFactory::GetForProfile(profile); |
| 159 ProfileOAuth2TokenService* oauth2_token_service = | 157 ProfileOAuth2TokenService* oauth2_token_service = |
| 160 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 158 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 161 return make_scoped_ptr(new TestProfileSyncService( | 159 return make_scoped_ptr(new TestProfileSyncService( |
| 162 profile, signin, oauth2_token_service, browser_sync::AUTO_START)); | 160 profile, signin, oauth2_token_service, browser_sync::AUTO_START)); |
| 163 } | 161 } |
| 164 | 162 |
| 165 // static | 163 // static |
| 166 TestProfileSyncService* TestProfileSyncService::BuildAutoStartAsyncInit( | 164 TestProfileSyncService* TestProfileSyncService::BuildAutoStartAsyncInit( |
| 167 Profile* profile, base::Closure callback) { | 165 Profile* profile, base::Closure callback) { |
| 168 TestProfileSyncService* sync_service = static_cast<TestProfileSyncService*>( | 166 TestProfileSyncService* sync_service = static_cast<TestProfileSyncService*>( |
| 169 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 167 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 170 profile, &TestProfileSyncService::TestFactoryFunction)); | 168 profile, &TestProfileSyncService::TestFactoryFunction)); |
| 171 SyncApiComponentFactoryMock* components = | 169 SyncApiComponentFactoryMock* components = |
| 172 sync_service->GetSyncApiComponentFactoryMock(); | 170 sync_service->GetSyncApiComponentFactoryMock(); |
| 173 // TODO(tim): Convert to a fake instead of mock. | 171 // TODO(tim): Convert to a fake instead of mock. |
| 174 EXPECT_CALL(*components, CreateSyncBackendHost(testing::_, testing::_, | 172 EXPECT_CALL(*components, |
| 175 testing::_, testing::_)) | 173 CreateSyncBackendHost(testing::_, testing::_, testing::_, |
| 174 testing::_, testing::_)) |
| 176 .WillOnce( | 175 .WillOnce( |
| 177 testing::Return(new browser_sync::SyncBackendHostForProfileSyncTest( | 176 testing::Return(new browser_sync::SyncBackendHostForProfileSyncTest( |
| 178 profile, sync_service->GetSyncClient(), | 177 profile, sync_service->GetSyncClient(), |
| 179 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 178 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
| 180 invalidation::ProfileInvalidationProviderFactory::GetForProfile( | 179 invalidation::ProfileInvalidationProviderFactory::GetForProfile( |
| 181 profile) | 180 profile) |
| 182 ->GetInvalidationService(), | 181 ->GetInvalidationService(), |
| 183 sync_service->sync_prefs_.AsWeakPtr(), callback))); | 182 sync_service->sync_prefs_.AsWeakPtr(), callback))); |
| 184 return sync_service; | 183 return sync_service; |
| 185 } | 184 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 197 base::MessageLoop::current()->QuitWhenIdle(); | 196 base::MessageLoop::current()->QuitWhenIdle(); |
| 198 } | 197 } |
| 199 | 198 |
| 200 UserShare* TestProfileSyncService::GetUserShare() const { | 199 UserShare* TestProfileSyncService::GetUserShare() const { |
| 201 return backend_->GetUserShare(); | 200 return backend_->GetUserShare(); |
| 202 } | 201 } |
| 203 | 202 |
| 204 bool TestProfileSyncService::NeedBackup() const { | 203 bool TestProfileSyncService::NeedBackup() const { |
| 205 return false; | 204 return false; |
| 206 } | 205 } |
| OLD | NEW |