• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef DISCOVERY_DNSSD_IMPL_PUBLISHER_IMPL_H_
6 #define DISCOVERY_DNSSD_IMPL_PUBLISHER_IMPL_H_
7 
8 #include "absl/strings/string_view.h"
9 #include "discovery/dnssd/impl/conversion_layer.h"
10 #include "discovery/dnssd/public/dns_sd_instance.h"
11 #include "discovery/dnssd/public/dns_sd_publisher.h"
12 #include "discovery/mdns/mdns_domain_confirmed_provider.h"
13 #include "discovery/mdns/public/mdns_service.h"
14 
15 namespace openscreen {
16 namespace discovery {
17 
18 class NetworkInterfaceConfig;
19 class ReportingClient;
20 
21 class PublisherImpl : public DnsSdPublisher,
22                       public MdnsDomainConfirmedProvider {
23  public:
24   PublisherImpl(MdnsService* publisher,
25                 ReportingClient* reporting_client,
26                 TaskRunner* task_runner,
27                 const NetworkInterfaceConfig* network_config);
28   ~PublisherImpl() override;
29 
30   // DnsSdPublisher overrides.
31   Error Register(const DnsSdInstance& instance, Client* client) override;
32   Error UpdateRegistration(const DnsSdInstance& instance) override;
33   ErrorOr<int> DeregisterAll(const std::string& service) override;
34 
35  private:
36   Error UpdatePublishedRegistration(const DnsSdInstance& instance);
37 
38   // MdnsDomainConfirmedProvider overrides.
39   void OnDomainFound(const DomainName& requested_name,
40                      const DomainName& confirmed_name) override;
41 
42   // The set of instances which will be published once the mDNS Probe phase
43   // completes.
44   std::map<DnsSdInstance, Client* const> pending_instances_;
45 
46   // Maps from the requested instance to the endpoint which was published after
47   // the mDNS Probe phase was completed. The only difference between these
48   // instances should be the instance name.
49   std::map<DnsSdInstance, DnsSdInstanceEndpoint> published_instances_;
50 
51   MdnsService* const mdns_publisher_;
52   ReportingClient* const reporting_client_;
53   TaskRunner* const task_runner_;
54   const NetworkInterfaceConfig* const network_config_;
55 
56   friend class PublisherTesting;
57 };
58 
59 }  // namespace discovery
60 }  // namespace openscreen
61 
62 #endif  // DISCOVERY_DNSSD_IMPL_PUBLISHER_IMPL_H_
63