summaryrefslogtreecommitdiff
path: root/chromium/services/network/dns_config_change_manager.h
blob: 31df8f98537b6ed786074abf8fdc36c24be8a188 (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
43
44
45
46
47
// Copyright 2018 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_DNS_CONFIG_CHANGE_MANAGER_H_
#define SERVICES_NETWORK_DNS_CONFIG_CHANGE_MANAGER_H_

#include <memory>
#include <set>

#include "base/component_export.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "net/base/network_change_notifier.h"
#include "services/network/public/mojom/host_resolver.mojom.h"

namespace network {

class COMPONENT_EXPORT(NETWORK_SERVICE) DnsConfigChangeManager
    : public mojom::DnsConfigChangeManager,
      public net::NetworkChangeNotifier::DNSObserver {
 public:
  DnsConfigChangeManager();
  ~DnsConfigChangeManager() override;

  void AddReceiver(
      mojo::PendingReceiver<mojom::DnsConfigChangeManager> receiver);

  // mojom::DnsConfigChangeManager implementation:
  void RequestNotifications(
      mojo::PendingRemote<mojom::DnsConfigChangeManagerClient> client) override;

 private:
  // net::NetworkChangeNotifier::DNSObserver implementation:
  void OnDNSChanged() override;

  mojo::ReceiverSet<mojom::DnsConfigChangeManager> receivers_;
  mojo::RemoteSet<mojom::DnsConfigChangeManagerClient> clients_;

  DISALLOW_COPY_AND_ASSIGN(DnsConfigChangeManager);
};

}  // namespace network

#endif  // SERVICES_NETWORK_DNS_CONFIG_CHANGE_MANAGER_H_