| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 #if defined(ENABLE_EXTENSIONS) | 46 #if defined(ENABLE_EXTENSIONS) |
| 47 #include "extensions/browser/extension_system_provider.h" | 47 #include "extensions/browser/extension_system_provider.h" |
| 48 #include "extensions/browser/extensions_browser_client.h" | 48 #include "extensions/browser/extensions_browser_client.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 #if !defined(OS_ANDROID) | 51 #if !defined(OS_ANDROID) |
| 52 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 52 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 using browser_sync::ProfileSyncService; |
| 56 |
| 55 namespace { | 57 namespace { |
| 56 | 58 |
| 57 void UpdateNetworkTimeOnUIThread(base::Time network_time, | 59 void UpdateNetworkTimeOnUIThread(base::Time network_time, |
| 58 base::TimeDelta resolution, | 60 base::TimeDelta resolution, |
| 59 base::TimeDelta latency, | 61 base::TimeDelta latency, |
| 60 base::TimeTicks post_time) { | 62 base::TimeTicks post_time) { |
| 61 g_browser_process->network_time_tracker()->UpdateNetworkTime( | 63 g_browser_process->network_time_tracker()->UpdateNetworkTime( |
| 62 network_time, resolution, latency, post_time); | 64 network_time, resolution, latency, post_time); |
| 63 } | 65 } |
| 64 | 66 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 75 | 77 |
| 76 // static | 78 // static |
| 77 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 79 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { |
| 78 return base::Singleton<ProfileSyncServiceFactory>::get(); | 80 return base::Singleton<ProfileSyncServiceFactory>::get(); |
| 79 } | 81 } |
| 80 | 82 |
| 81 // static | 83 // static |
| 82 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 84 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( |
| 83 Profile* profile) { | 85 Profile* profile) { |
| 84 if (!ProfileSyncService::IsSyncAllowedByFlag()) | 86 if (!ProfileSyncService::IsSyncAllowedByFlag()) |
| 85 return NULL; | 87 return nullptr; |
| 86 | 88 |
| 87 return static_cast<ProfileSyncService*>( | 89 return static_cast<ProfileSyncService*>( |
| 88 GetInstance()->GetServiceForBrowserContext(profile, true)); | 90 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 89 } | 91 } |
| 90 | 92 |
| 91 // static | 93 // static |
| 92 sync_driver::SyncService* | 94 sync_driver::SyncService* |
| 93 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext( | 95 ProfileSyncServiceFactory::GetSyncServiceForBrowserContext( |
| 94 content::BrowserContext* context) { | 96 content::BrowserContext* context) { |
| 95 return GetForProfile(Profile::FromBrowserContext(context)); | 97 return GetForProfile(Profile::FromBrowserContext(context)); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 193 |
| 192 auto pss = base::MakeUnique<ProfileSyncService>(std::move(init_params)); | 194 auto pss = base::MakeUnique<ProfileSyncService>(std::move(init_params)); |
| 193 | 195 |
| 194 // Will also initialize the sync client. | 196 // Will also initialize the sync client. |
| 195 pss->Initialize(); | 197 pss->Initialize(); |
| 196 return pss.release(); | 198 return pss.release(); |
| 197 } | 199 } |
| 198 | 200 |
| 199 // static | 201 // static |
| 200 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 202 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
| 201 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 203 return GetInstance()->GetServiceForBrowserContext(profile, false) != nullptr; |
| 202 } | 204 } |
| 203 | 205 |
| 204 // static | 206 // static |
| 205 void ProfileSyncServiceFactory::SetSyncClientFactoryForTest( | 207 void ProfileSyncServiceFactory::SetSyncClientFactoryForTest( |
| 206 SyncClientFactory* client_factory) { | 208 SyncClientFactory* client_factory) { |
| 207 client_factory_ = client_factory; | 209 client_factory_ = client_factory; |
| 208 } | 210 } |
| 209 | 211 |
| 210 // static | 212 // static |
| 211 ProfileSyncServiceFactory::SyncClientFactory* | 213 ProfileSyncServiceFactory::SyncClientFactory* |
| 212 ProfileSyncServiceFactory::client_factory_ = nullptr; | 214 ProfileSyncServiceFactory::client_factory_ = nullptr; |
| OLD | NEW |