ipfs-chromium
preferences.h
1 #ifndef IPFS_PREFERENCES_H_INCLUDED
2 #define IPFS_PREFERENCES_H_INCLUDED 1
3 
4 #include "export.h"
5 
6 #include <base/memory/raw_ptr.h>
7 #include <base/values.h>
8 
9 #include <ipfs_client/ctx/gateway_config.h>
10 
11 #include <ranges>
12 
13 class PrefRegistrySimple;
14 class PrefService;
15 
16 namespace ipfs {
17 COMPONENT_EXPORT(IPFS) void RegisterPreferences(PrefRegistrySimple*);
18 bool DnsFallbackPref(PrefService const*);
19 
23  raw_ptr<PrefService> prefs_;
24  base::Value::Dict last_;
25  base::Value::Dict curr_;
26  std::size_t changes = 0;
27  std::size_t update_thresh = 1;
28 
29  void save();
30  std::size_t delta() const;
31 
32  public:
33  ChromiumIpfsGatewayConfig(PrefService*);
34 
35  unsigned GetGatewayRate(std::string_view) override;
36  void SetGatewayRate(std::string_view, unsigned) override;
37  std::optional<GatewaySpec> GetGateway(std::size_t index) const override;
38  void AddGateway(std::string_view, unsigned) override;
39  // std::pair<std::string const*, unsigned> at(std::size_t index) const;
40  unsigned RoutingApiDiscoveryDefaultRate() const override;
41  bool RoutingApiDiscoveryOfUnencryptedGateways() const override;
42  int GetTypeAffinity(std::string_view url_prefix,
43  gw::GatewayRequestType) const override;
44  void SetTypeAffinity(std::string_view url_prefix,
45  gw::GatewayRequestType,
46  int) override;
47 };
48 }
49 
50 #endif
Definition: preferences.h:22
std::optional< GatewaySpec > GetGateway(std::size_t index) const override
Definition: gateway_config.h:13