File: web_data_service_wrapper.h

package info (click to toggle)
qt6-webengine 6.8.2%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,834,164 kB
  • sloc: cpp: 20,319,195; ansic: 8,076,006; javascript: 3,260,843; asm: 839,896; python: 814,858; xml: 506,536; java: 215,396; sh: 104,539; objc: 99,126; perl: 71,598; cs: 50,882; fortran: 24,137; makefile: 24,065; sql: 19,787; pascal: 13,725; tcl: 9,530; yacc: 8,012; php: 6,830; lisp: 3,457; lex: 1,323; ruby: 901; awk: 339; csh: 120; sed: 37
file content (110 lines) | stat: -rw-r--r-- 3,700 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_
#define COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_

#include <string>

#include "base/functional/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "build/blink_buildflags.h"
#include "build/build_config.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/sync/model/syncable_service.h"
#include "sql/init_status.h"

class KeywordWebDataService;
class TokenWebData;
class WebDatabaseService;

#if BUILDFLAG(USE_BLINK)
namespace payments {
class PaymentManifestWebDataService;
}  // namespace payments
#endif

namespace autofill {
class AutofillWebDataService;
}  // namespace autofill

namespace base {
class FilePath;
class SequencedTaskRunner;
}  // namespace base

// WebDataServiceWrapper is a KeyedService that owns multiple WebDataServices
// so that they can be associated with a context.
class WebDataServiceWrapper : public KeyedService {
 public:
  // ErrorType indicates which service encountered an error loading its data.
  enum ErrorType {
    ERROR_LOADING_AUTOFILL,
    ERROR_LOADING_ACCOUNT_AUTOFILL,
    ERROR_LOADING_KEYWORD,
    ERROR_LOADING_TOKEN,
    ERROR_LOADING_PASSWORD,
    ERROR_LOADING_PAYMENT_MANIFEST,
  };

  // Shows an error message if a loading error occurs.
  // |error_type| shows which service encountered an error while loading.
  // |init_status| is the returned status of initializing the underlying
  // database.
  // |diagnostics| contains information about the underlying database
  // which can help in identifying the cause of the error.
  using ShowErrorCallback =
      base::RepeatingCallback<void(ErrorType error_type,
                                   sql::InitStatus init_status,
                                   const std::string& diagnostics)>;

  // Constructor for WebDataServiceWrapper that initializes the different
  // WebDataServices.
  WebDataServiceWrapper(
      const base::FilePath& context_path,
      const std::string& application_locale,
      const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
      const ShowErrorCallback& show_error_callback);

  WebDataServiceWrapper(const WebDataServiceWrapper&) = delete;
  WebDataServiceWrapper& operator=(const WebDataServiceWrapper&) = delete;

  ~WebDataServiceWrapper() override;

  // KeyedService:
  void Shutdown() override;

  // Create the various types of service instances.  These methods are virtual
  // for testing purpose.
  virtual scoped_refptr<autofill::AutofillWebDataService>
  GetProfileAutofillWebData();
  virtual scoped_refptr<autofill::AutofillWebDataService>
  GetAccountAutofillWebData();
  virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData();
  virtual scoped_refptr<TokenWebData> GetTokenWebData();
#if BUILDFLAG(USE_BLINK)
  virtual scoped_refptr<payments::PaymentManifestWebDataService>
  GetPaymentManifestWebData();
#endif

 protected:
  // For testing.
  WebDataServiceWrapper();

 private:
  scoped_refptr<WebDatabaseService> profile_database_;
  scoped_refptr<WebDatabaseService> account_database_;

  scoped_refptr<autofill::AutofillWebDataService> profile_autofill_web_data_;
  scoped_refptr<autofill::AutofillWebDataService> account_autofill_web_data_;
  scoped_refptr<KeywordWebDataService> keyword_web_data_;
  scoped_refptr<TokenWebData> token_web_data_;

#if BUILDFLAG(USE_BLINK)
  scoped_refptr<payments::PaymentManifestWebDataService>
      payment_manifest_web_data_;
#endif
};

#endif  // COMPONENTS_WEBDATA_SERVICES_WEB_DATA_SERVICE_WRAPPER_H_