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.
5 #ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_
6 #define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_
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"
16 class KeywordWebDataService
;
18 class WebDatabaseService
;
21 class PasswordWebDataService
;
25 class AutofillWebDataBackend
;
26 class AutofillWebDataService
;
27 } // namespace autofill
31 class MessageLoopProxy
;
34 // WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices
35 // so that they can be associated with a context.
36 class WebDataServiceWrapper
: public KeyedService
{
38 // ErrorType indicates which service encountered an error loading its data.
40 ERROR_LOADING_AUTOFILL
,
41 ERROR_LOADING_KEYWORD
,
43 ERROR_LOADING_PASSWORD
,
46 // Shows an error message if a loading error occurs.
47 using ShowErrorCallback
= void (*)(ErrorType
, sql::InitStatus
);
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
;
57 WebDataServiceWrapper();
60 void Shutdown() override
;
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();
68 virtual scoped_refptr
<PasswordWebDataService
> GetPasswordWebData();
72 scoped_refptr
<WebDatabaseService
> web_database_
;
74 scoped_refptr
<autofill::AutofillWebDataService
> autofill_web_data_
;
75 scoped_refptr
<KeywordWebDataService
> keyword_web_data_
;
76 scoped_refptr
<TokenWebData
> token_web_data_
;
79 scoped_refptr
<PasswordWebDataService
> password_web_data_
;
82 DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper
);
85 #endif // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_