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_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ | 5 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ |
6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ | 6 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/singleton.h" | |
11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
12 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" | 11 #include "components/keyed_service/content/browser_context_keyed_service_factory .h" |
13 #include "components/keyed_service/core/keyed_service.h" | |
14 #include "components/webdata/common/web_database_service.h" | |
15 | 12 |
13 template <typename T> | |
14 struct DefaultSingletonTraits; | |
Peter Kasting
2014/12/05 21:47:56
Please put this on the same line as above so it's
sdefresne
2014/12/08 10:54:42
Done.
| |
16 class KeywordWebDataService; | 15 class KeywordWebDataService; |
17 class TokenWebData; | 16 class TokenWebData; |
17 class WebDataServiceWrapper; | |
18 | 18 |
19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
20 class PasswordWebDataService; | 20 class PasswordWebDataService; |
21 #endif | 21 #endif |
22 | 22 |
23 namespace autofill { | 23 namespace autofill { |
24 class AutofillWebDataBackend; | |
24 class AutofillWebDataService; | 25 class AutofillWebDataService; |
25 } // namespace autofill | 26 } // namespace autofill |
26 | 27 |
27 // A wrapper of WebDataService so that we can use it as a profile keyed service. | 28 // Initialize syncable services on database thread. |
28 class WebDataServiceWrapper : public KeyedService { | 29 // (visible for testing) |
Peter Kasting
2014/12/05 21:47:56
Nit: Use sentences. Perhaps "Exposed here for use
| |
29 public: | 30 void InitSyncableServicesOnDBThread( |
30 explicit WebDataServiceWrapper(Profile* profile); | 31 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data, |
31 | 32 const base::FilePath& profile_path, |
32 // For testing. | 33 const std::string& app_locale, |
33 WebDataServiceWrapper(); | 34 autofill::AutofillWebDataBackend* autofill_backend); |
34 | |
35 ~WebDataServiceWrapper() override; | |
36 | |
37 // KeyedService: | |
38 void Shutdown() override; | |
39 | |
40 virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData(); | |
41 | |
42 virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData(); | |
43 | |
44 virtual scoped_refptr<TokenWebData> GetTokenWebData(); | |
45 | |
46 #if defined(OS_WIN) | |
47 virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData(); | |
48 #endif | |
49 | |
50 private: | |
51 scoped_refptr<WebDatabaseService> web_database_; | |
52 | |
53 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_; | |
54 scoped_refptr<KeywordWebDataService> keyword_web_data_; | |
55 scoped_refptr<TokenWebData> token_web_data_; | |
56 | |
57 #if defined(OS_WIN) | |
58 scoped_refptr<PasswordWebDataService> password_web_data_; | |
59 #endif | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); | |
62 }; | |
63 | 35 |
64 // Singleton that owns all WebDataServiceWrappers and associates them with | 36 // Singleton that owns all WebDataServiceWrappers and associates them with |
65 // Profiles. | 37 // Profiles. |
66 class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { | 38 class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { |
67 public: | 39 public: |
68 // Returns the WebDataServiceWrapper associated with the |profile|. | 40 // Returns the WebDataServiceWrapper associated with the |profile|. |
69 static WebDataServiceWrapper* GetForProfile( | 41 static WebDataServiceWrapper* GetForProfile( |
70 Profile* profile, | 42 Profile* profile, |
71 Profile::ServiceAccessType access_type); | 43 Profile::ServiceAccessType access_type); |
72 | 44 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 content::BrowserContext* GetBrowserContextToUse( | 80 content::BrowserContext* GetBrowserContextToUse( |
109 content::BrowserContext* context) const override; | 81 content::BrowserContext* context) const override; |
110 KeyedService* BuildServiceInstanceFor( | 82 KeyedService* BuildServiceInstanceFor( |
111 content::BrowserContext* profile) const override; | 83 content::BrowserContext* profile) const override; |
112 bool ServiceIsNULLWhileTesting() const override; | 84 bool ServiceIsNULLWhileTesting() const override; |
113 | 85 |
114 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory); | 86 DISALLOW_COPY_AND_ASSIGN(WebDataServiceFactory); |
115 }; | 87 }; |
116 | 88 |
117 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ | 89 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__ |
OLD | NEW |