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_SERVICE_INSTANCE_H_ 6 #define DISCOVERY_DNSSD_IMPL_SERVICE_INSTANCE_H_ 7 8 #include <memory> 9 10 #include "discovery/dnssd/impl/network_interface_config.h" 11 #include "discovery/dnssd/impl/publisher_impl.h" 12 #include "discovery/dnssd/impl/querier_impl.h" 13 #include "discovery/dnssd/public/dns_sd_service.h" 14 #include "platform/base/interface_info.h" 15 16 namespace openscreen { 17 18 class TaskRunner; 19 20 namespace discovery { 21 22 class MdnsService; 23 24 class ServiceInstance final : public DnsSdService { 25 public: 26 ServiceInstance(TaskRunner* task_runner, 27 ReportingClient* reporting_client, 28 const Config& config, 29 const InterfaceInfo& network_info); 30 ServiceInstance(const ServiceInstance& other) = delete; 31 ServiceInstance(ServiceInstance&& other) noexcept = delete; 32 ~ServiceInstance() override; 33 34 ServiceInstance& operator=(const ServiceInstance& other) = delete; 35 ServiceInstance& operator=(ServiceInstance&& other) = delete; 36 network_config()37 const NetworkInterfaceConfig& network_config() const { 38 return network_config_; 39 } 40 41 // DnsSdService overrides. GetQuerier()42 DnsSdQuerier* GetQuerier() override { return querier_.get(); } GetPublisher()43 DnsSdPublisher* GetPublisher() override { return publisher_.get(); } 44 45 private: 46 TaskRunner* const task_runner_; 47 48 std::unique_ptr<MdnsService> mdns_service_; 49 50 std::unique_ptr<QuerierImpl> querier_; 51 std::unique_ptr<PublisherImpl> publisher_; 52 53 const NetworkInterfaceConfig network_config_; 54 }; 55 56 } // namespace discovery 57 } // namespace openscreen 58 59 #endif // DISCOVERY_DNSSD_IMPL_SERVICE_INSTANCE_H_ 60