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