| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ | 5 #ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ |
| 6 #define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ | 6 #define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
| 15 #include "components/sync/model/syncable_service.h" | 15 #include "components/sync/model/syncable_service.h" |
| 16 #include "sql/init_status.h" | 16 #include "sql/init_status.h" |
| 17 | 17 |
| 18 class KeywordWebDataService; | 18 class KeywordWebDataService; |
| 19 class TokenWebData; | 19 class TokenWebData; |
| 20 class WebDatabaseService; | 20 class WebDatabaseService; |
| 21 | 21 |
| 22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 23 class PasswordWebDataService; | 23 class PasswordWebDataService; |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #if defined(OS_ANDROID) |
| 27 namespace payments { |
| 28 class PaymentManifestWebDataService; |
| 29 } // namespace payments |
| 30 #endif |
| 31 |
| 26 namespace autofill { | 32 namespace autofill { |
| 27 class AutofillWebDataService; | 33 class AutofillWebDataService; |
| 28 } // namespace autofill | 34 } // namespace autofill |
| 29 | 35 |
| 30 namespace base { | 36 namespace base { |
| 31 class FilePath; | 37 class FilePath; |
| 32 class SingleThreadTaskRunner; | 38 class SingleThreadTaskRunner; |
| 33 } // namespace base | 39 } // namespace base |
| 34 | 40 |
| 35 // WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices | 41 // WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices |
| 36 // so that they can be associated with a context. | 42 // so that they can be associated with a context. |
| 37 class WebDataServiceWrapper : public KeyedService { | 43 class WebDataServiceWrapper : public KeyedService { |
| 38 public: | 44 public: |
| 39 // ErrorType indicates which service encountered an error loading its data. | 45 // ErrorType indicates which service encountered an error loading its data. |
| 40 enum ErrorType { | 46 enum ErrorType { |
| 41 ERROR_LOADING_AUTOFILL, | 47 ERROR_LOADING_AUTOFILL, |
| 42 ERROR_LOADING_KEYWORD, | 48 ERROR_LOADING_KEYWORD, |
| 43 ERROR_LOADING_TOKEN, | 49 ERROR_LOADING_TOKEN, |
| 44 ERROR_LOADING_PASSWORD, | 50 ERROR_LOADING_PASSWORD, |
| 51 ERROR_LOADING_PAYMENT_MANIFEST, |
| 45 }; | 52 }; |
| 46 | 53 |
| 47 // Shows an error message if a loading error occurs. | 54 // Shows an error message if a loading error occurs. |
| 48 // |error_type| shows which service encountered an error while loading. | 55 // |error_type| shows which service encountered an error while loading. |
| 49 // |init_status| is the returned status of initializing the underlying | 56 // |init_status| is the returned status of initializing the underlying |
| 50 // database. | 57 // database. |
| 51 // |diagnostics| contains information about the underlying database | 58 // |diagnostics| contains information about the underlying database |
| 52 // which can help in identifying the cause of the error. | 59 // which can help in identifying the cause of the error. |
| 53 using ShowErrorCallback = void (*)(ErrorType error_type, | 60 using ShowErrorCallback = void (*)(ErrorType error_type, |
| 54 sql::InitStatus init_status, | 61 sql::InitStatus init_status, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 72 void Shutdown() override; | 79 void Shutdown() override; |
| 73 | 80 |
| 74 // Create the various types of service instances. These methods are virtual | 81 // Create the various types of service instances. These methods are virtual |
| 75 // for testing purpose. | 82 // for testing purpose. |
| 76 virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData(); | 83 virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData(); |
| 77 virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData(); | 84 virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData(); |
| 78 virtual scoped_refptr<TokenWebData> GetTokenWebData(); | 85 virtual scoped_refptr<TokenWebData> GetTokenWebData(); |
| 79 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 80 virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData(); | 87 virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData(); |
| 81 #endif | 88 #endif |
| 89 #if defined(OS_ANDROID) |
| 90 virtual scoped_refptr<payments::PaymentManifestWebDataService> |
| 91 GetPaymentManifestWebData(); |
| 92 #endif |
| 82 | 93 |
| 83 protected: | 94 protected: |
| 84 // For testing. | 95 // For testing. |
| 85 WebDataServiceWrapper(); | 96 WebDataServiceWrapper(); |
| 86 | 97 |
| 87 private: | 98 private: |
| 88 scoped_refptr<WebDatabaseService> web_database_; | 99 scoped_refptr<WebDatabaseService> web_database_; |
| 89 | 100 |
| 90 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_; | 101 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_; |
| 91 scoped_refptr<KeywordWebDataService> keyword_web_data_; | 102 scoped_refptr<KeywordWebDataService> keyword_web_data_; |
| 92 scoped_refptr<TokenWebData> token_web_data_; | 103 scoped_refptr<TokenWebData> token_web_data_; |
| 93 | 104 |
| 94 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
| 95 scoped_refptr<PasswordWebDataService> password_web_data_; | 106 scoped_refptr<PasswordWebDataService> password_web_data_; |
| 96 #endif | 107 #endif |
| 97 | 108 |
| 109 #if defined(OS_ANDROID) |
| 110 scoped_refptr<payments::PaymentManifestWebDataService> |
| 111 payment_manifest_web_data_; |
| 112 #endif |
| 113 |
| 98 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); | 114 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); |
| 99 }; | 115 }; |
| 100 | 116 |
| 101 #endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ | 117 #endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ |
| OLD | NEW |