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*);
20  raw_ptr<PrefService> prefs_;
21  base::Value::Dict last_;
22  base::Value::Dict curr_;
23  std::size_t changes = 0;
24  std::size_t update_thresh = 1;
25 
26  void save();
27  std::size_t delta() const;
28 
29  public:
30  ChromiumIpfsGatewayConfig(PrefService*);
31 
32  unsigned GetGatewayRate(std::string_view) override;
33  void SetGatewayRate(std::string_view, unsigned) override;
34  std::optional<GatewaySpec> GetGateway(std::size_t index) const override;
35  void AddGateway(std::string_view, unsigned) override;
36  // std::pair<std::string const*, unsigned> at(std::size_t index) const;
37  unsigned RoutingApiDiscoveryDefaultRate() const override;
38  bool RoutingApiDiscoveryOfUnencryptedGateways() const override;
39  int GetTypeAffinity(std::string_view url_prefix,
40  gw::GatewayRequestType) const override;
41  void SetTypeAffinity(std::string_view url_prefix,
42  gw::GatewayRequestType,
43  int) override;
44 };
45 }
46 
47 #endif
Definition: preferences.h:19
Definition: gateway_config.h:11