| 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 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_FACTORY_H_ |
| 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_FACTORY_H_ | 6 #define CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | 8 #include "base/macros.h" |
| 11 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 9 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 12 | 10 |
| 13 class Profile; | |
| 14 | |
| 15 namespace base { | 11 namespace base { |
| 16 template <typename T> | 12 template <typename T> |
| 17 struct DefaultSingletonTraits; | 13 struct DefaultSingletonTraits; |
| 18 } // namespace base | 14 } |
| 19 | 15 |
| 20 namespace browser_sync { | 16 namespace browser_sync { |
| 21 class ProfileSyncService; | 17 class ProfileSyncService; |
| 22 } // namespace browser_sync | 18 } // namespace browser_sync |
| 23 | 19 |
| 24 namespace syncer { | 20 namespace sync_driver { |
| 25 class SyncClient; | 21 class SyncClient; |
| 26 class SyncService; | 22 class SyncService; |
| 27 } // namespace syncer | 23 } |
| 24 |
| 25 class Profile; |
| 28 | 26 |
| 29 class ProfileSyncServiceFactory : public BrowserContextKeyedServiceFactory { | 27 class ProfileSyncServiceFactory : public BrowserContextKeyedServiceFactory { |
| 30 public: | 28 public: |
| 31 typedef base::Callback<std::unique_ptr<syncer::SyncClient>(Profile*)> | 29 typedef base::Callback<std::unique_ptr<sync_driver::SyncClient>(Profile*)> |
| 32 SyncClientFactory; | 30 SyncClientFactory; |
| 33 | 31 |
| 34 static browser_sync::ProfileSyncService* GetForProfile(Profile* profile); | 32 static browser_sync::ProfileSyncService* GetForProfile(Profile* profile); |
| 35 static bool HasProfileSyncService(Profile* profile); | 33 static bool HasProfileSyncService(Profile* profile); |
| 36 | 34 |
| 37 // Convenience method that returns the ProfileSyncService as a | 35 // Convenience method that returns the ProfileSyncService as a |
| 38 // syncer::SyncService. | 36 // sync_driver::SyncService. |
| 39 static syncer::SyncService* GetSyncServiceForBrowserContext( | 37 static sync_driver::SyncService* GetSyncServiceForBrowserContext( |
| 40 content::BrowserContext* context); | 38 content::BrowserContext* context); |
| 41 | 39 |
| 42 static ProfileSyncServiceFactory* GetInstance(); | 40 static ProfileSyncServiceFactory* GetInstance(); |
| 43 | 41 |
| 44 // Overrides how the SyncClient is created for testing purposes. | 42 // Overrides how the SyncClient is created for testing purposes. |
| 45 static void SetSyncClientFactoryForTest(SyncClientFactory* client_factory); | 43 static void SetSyncClientFactoryForTest(SyncClientFactory* client_factory); |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 friend struct base::DefaultSingletonTraits<ProfileSyncServiceFactory>; | 46 friend struct base::DefaultSingletonTraits<ProfileSyncServiceFactory>; |
| 49 | 47 |
| 50 ProfileSyncServiceFactory(); | 48 ProfileSyncServiceFactory(); |
| 51 ~ProfileSyncServiceFactory() override; | 49 ~ProfileSyncServiceFactory() override; |
| 52 | 50 |
| 53 // BrowserContextKeyedServiceFactory: | 51 // BrowserContextKeyedServiceFactory: |
| 54 KeyedService* BuildServiceInstanceFor( | 52 KeyedService* BuildServiceInstanceFor( |
| 55 content::BrowserContext* context) const override; | 53 content::BrowserContext* context) const override; |
| 56 | 54 |
| 57 // A factory function for overriding the way the SyncClient is created. | 55 // A factory function for overriding the way the SyncClient is created. |
| 58 // This is a raw pointer so it can be statically initialized. | 56 // This is a raw pointer so it can be statically initialized. |
| 59 static SyncClientFactory* client_factory_; | 57 static SyncClientFactory* client_factory_; |
| 60 | 58 |
| 61 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceFactory); | 59 DISALLOW_COPY_AND_ASSIGN(ProfileSyncServiceFactory); |
| 62 }; | 60 }; |
| 63 | 61 |
| 64 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_FACTORY_H_ | 62 #endif // CHROME_BROWSER_SYNC_PROFILE_SYNC_SERVICE_FACTORY_H_ |
| OLD | NEW |