| 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/profile_sync_service_factory.h" | 5 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync | 163 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync |
| 164 // is set up and *not* a browser restart for a manual-start platform (where | 164 // is set up and *not* a browser restart for a manual-start platform (where |
| 165 // sync has already been set up, and should be able to start without user | 165 // sync has already been set up, and should be able to start without user |
| 166 // intervention). We can get rid of the browser_default eventually, but | 166 // intervention). We can get rid of the browser_default eventually, but |
| 167 // need to take care that ProfileSyncService doesn't get tripped up between | 167 // need to take care that ProfileSyncService doesn't get tripped up between |
| 168 // those two cases. Bug 88109. | 168 // those two cases. Bug 88109. |
| 169 init_params.start_behavior = browser_defaults::kSyncAutoStarts | 169 init_params.start_behavior = browser_defaults::kSyncAutoStarts |
| 170 ? ProfileSyncService::AUTO_START | 170 ? ProfileSyncService::AUTO_START |
| 171 : ProfileSyncService::MANUAL_START; | 171 : ProfileSyncService::MANUAL_START; |
| 172 | 172 |
| 173 init_params.sync_client = | 173 if (!client_factory_) { |
| 174 base::MakeUnique<browser_sync::ChromeSyncClient>(profile); | 174 init_params.sync_client = |
| 175 base::MakeUnique<browser_sync::ChromeSyncClient>(profile); |
| 176 } else { |
| 177 init_params.sync_client = client_factory_->Run(profile); |
| 178 } |
| 175 | 179 |
| 176 init_params.network_time_update_callback = base::Bind(&UpdateNetworkTime); | 180 init_params.network_time_update_callback = base::Bind(&UpdateNetworkTime); |
| 177 init_params.base_directory = profile->GetPath(); | 181 init_params.base_directory = profile->GetPath(); |
| 178 init_params.url_request_context = profile->GetRequestContext(); | 182 init_params.url_request_context = profile->GetRequestContext(); |
| 179 init_params.debug_identifier = profile->GetDebugName(); | 183 init_params.debug_identifier = profile->GetDebugName(); |
| 180 init_params.channel = chrome::GetChannel(); | 184 init_params.channel = chrome::GetChannel(); |
| 181 | 185 |
| 182 init_params.db_thread = content::BrowserThread::GetTaskRunnerForThread( | 186 init_params.db_thread = content::BrowserThread::GetTaskRunnerForThread( |
| 183 content::BrowserThread::DB); | 187 content::BrowserThread::DB); |
| 184 init_params.file_thread = content::BrowserThread::GetTaskRunnerForThread( | 188 init_params.file_thread = content::BrowserThread::GetTaskRunnerForThread( |
| 185 content::BrowserThread::FILE); | 189 content::BrowserThread::FILE); |
| 186 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); | 190 init_params.blocking_pool = content::BrowserThread::GetBlockingPool(); |
| 187 | 191 |
| 188 auto pss = base::MakeUnique<ProfileSyncService>(std::move(init_params)); | 192 auto pss = base::MakeUnique<ProfileSyncService>(std::move(init_params)); |
| 189 | 193 |
| 190 // Will also initialize the sync client. | 194 // Will also initialize the sync client. |
| 191 pss->Initialize(); | 195 pss->Initialize(); |
| 192 return pss.release(); | 196 return pss.release(); |
| 193 } | 197 } |
| 194 | 198 |
| 195 // static | 199 // static |
| 196 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 200 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
| 197 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 201 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
| 198 } | 202 } |
| 203 |
| 204 // static |
| 205 void ProfileSyncServiceFactory::SetSyncClientFactoryForTest( |
| 206 SyncClientFactory* client_factory) { |
| 207 client_factory_ = client_factory; |
| 208 } |
| 209 |
| 210 // static |
| 211 ProfileSyncServiceFactory::SyncClientFactory* |
| 212 ProfileSyncServiceFactory::client_factory_ = nullptr; |
| OLD | NEW |