OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ |
| 6 #define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback_forward.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" |
| 14 #include "sql/init_status.h" |
| 15 |
| 16 class KeywordWebDataService; |
| 17 class TokenWebData; |
| 18 class WebDatabaseService; |
| 19 |
| 20 #if defined(OS_WIN) |
| 21 class PasswordWebDataService; |
| 22 #endif |
| 23 |
| 24 namespace autofill { |
| 25 class AutofillWebDataBackend; |
| 26 class AutofillWebDataService; |
| 27 } // namespace autofill |
| 28 |
| 29 namespace base { |
| 30 class FilePath; |
| 31 class MessageLoopProxy; |
| 32 } // namespace base |
| 33 |
| 34 // WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices |
| 35 // so that they can be associated with a context. |
| 36 class WebDataServiceWrapper : public KeyedService { |
| 37 public: |
| 38 // ErrorType indicates which service encountered an error loading its data. |
| 39 enum ErrorType { |
| 40 ERROR_LOADING_AUTOFILL, |
| 41 ERROR_LOADING_KEYWORD, |
| 42 ERROR_LOADING_TOKEN, |
| 43 ERROR_LOADING_PASSWORD, |
| 44 }; |
| 45 |
| 46 // Shows an error message if a loading error occurs. |
| 47 using ShowErrorCallback = void (*)(ErrorType, sql::InitStatus); |
| 48 |
| 49 WebDataServiceWrapper(const base::FilePath& profile_path, |
| 50 const std::string& application_locale, |
| 51 const scoped_refptr<base::MessageLoopProxy>& ui_thread, |
| 52 const scoped_refptr<base::MessageLoopProxy>& db_thread, |
| 53 ShowErrorCallback show_error_callback); |
| 54 ~WebDataServiceWrapper() override; |
| 55 |
| 56 // For testing. |
| 57 WebDataServiceWrapper(); |
| 58 |
| 59 // KeyedService: |
| 60 void Shutdown() override; |
| 61 |
| 62 // Create the various types of service instances. These methods are virtual |
| 63 // for testing purpose. |
| 64 virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData(); |
| 65 virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData(); |
| 66 virtual scoped_refptr<TokenWebData> GetTokenWebData(); |
| 67 #if defined(OS_WIN) |
| 68 virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData(); |
| 69 #endif |
| 70 |
| 71 private: |
| 72 scoped_refptr<WebDatabaseService> web_database_; |
| 73 |
| 74 scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_; |
| 75 scoped_refptr<KeywordWebDataService> keyword_web_data_; |
| 76 scoped_refptr<TokenWebData> token_web_data_; |
| 77 |
| 78 #if defined(OS_WIN) |
| 79 scoped_refptr<PasswordWebDataService> password_web_data_; |
| 80 #endif |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); |
| 83 }; |
| 84 |
| 85 #endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_ |
OLD | NEW |