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