summaryrefslogtreecommitdiff
path: root/chromium/services/network/http_server_properties_pref_delegate.h
blob: 76357102577adb889a43e8397451c6f3df947a65 (plain)
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
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_NETWORK_HTTP_SERVER_PROPERTIES_PREF_DELEGATE_H_
#define SERVICES_NETWORK_HTTP_SERVER_PROPERTIES_PREF_DELEGATE_H_

#include "base/callback.h"
#include "base/macros.h"
#include "components/prefs/pref_change_registrar.h"
#include "net/http/http_server_properties.h"

class PrefRegistrySimple;

namespace network {

// Manages disk storage for a net::HttpServerPropertiesManager.
class HttpServerPropertiesPrefDelegate
    : public net::HttpServerProperties::PrefDelegate {
 public:
  // The created object must be destroyed before |pref_service|.
  explicit HttpServerPropertiesPrefDelegate(PrefService* pref_service);
  ~HttpServerPropertiesPrefDelegate() override;

  static void RegisterPrefs(PrefRegistrySimple* pref_registry);

  // net::HttpServerProperties::PrefDelegate implementation.
  const base::Value* GetServerProperties() const override;
  void SetServerProperties(const base::Value& value,
                           base::OnceClosure callback) override;
  void WaitForPrefLoad(base::OnceClosure callback) override;

 private:
  PrefService* pref_service_;
  PrefChangeRegistrar pref_change_registrar_;

  DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesPrefDelegate);
};

}  // namespace network

#endif  // SERVICES_NETWORK_HTTP_SERVER_PROPERTIES_PREF_DELEGATE_H_