| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_ENDPOINT_RESOLVER_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_ENDPOINT_RESOLVER_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_ENDPOINT_RESOLVER_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_ENDPOINT_RESOLVER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "chrome/browser/local_discovery/service_discovery_client.h" | 15 #include "chrome/browser/local_discovery/service_discovery_client.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class HostPortPair; | 18 class HostPortPair; |
| 19 class IPAddress; |
| 19 class IPEndPoint; | 20 class IPEndPoint; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace local_discovery { | 23 namespace local_discovery { |
| 23 | 24 |
| 24 class ServiceDiscoverySharedClient; | 25 class ServiceDiscoverySharedClient; |
| 25 | 26 |
| 26 class EndpointResolver { | 27 class EndpointResolver { |
| 27 public: | 28 public: |
| 28 using ResultCallback = base::Callback<void(const net::IPEndPoint& endpoint)>; | 29 using ResultCallback = base::Callback<void(const net::IPEndPoint& endpoint)>; |
| 29 | 30 |
| 30 EndpointResolver(); | 31 EndpointResolver(); |
| 31 ~EndpointResolver(); | 32 ~EndpointResolver(); |
| 32 | 33 |
| 33 void Start(const std::string& service_name, const ResultCallback& callback); | 34 void Start(const std::string& service_name, const ResultCallback& callback); |
| 34 | 35 |
| 35 void Start(const net::HostPortPair& address, const ResultCallback& callback); | 36 void Start(const net::HostPortPair& address, const ResultCallback& callback); |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 void ServiceResolveComplete(const ResultCallback& callback, | 39 void ServiceResolveComplete(const ResultCallback& callback, |
| 39 ServiceResolver::RequestStatus result, | 40 ServiceResolver::RequestStatus result, |
| 40 const ServiceDescription& description); | 41 const ServiceDescription& description); |
| 41 | 42 |
| 42 void DomainResolveComplete(uint16_t port, | 43 void DomainResolveComplete(uint16_t port, |
| 43 const ResultCallback& callback, | 44 const ResultCallback& callback, |
| 44 bool success, | 45 bool success, |
| 45 const net::IPAddressNumber& address_ipv4, | 46 const net::IPAddress& address_ipv4, |
| 46 const net::IPAddressNumber& address_ipv6); | 47 const net::IPAddress& address_ipv6); |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_; | 50 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_; |
| 50 scoped_ptr<ServiceResolver> service_resolver_; | 51 scoped_ptr<ServiceResolver> service_resolver_; |
| 51 scoped_ptr<LocalDomainResolver> domain_resolver_; | 52 scoped_ptr<LocalDomainResolver> domain_resolver_; |
| 52 | 53 |
| 53 DISALLOW_COPY_AND_ASSIGN(EndpointResolver); | 54 DISALLOW_COPY_AND_ASSIGN(EndpointResolver); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 } // namespace local_discovery | 57 } // namespace local_discovery |
| 57 | 58 |
| 58 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_ENDPOINT_RESOLVER_H_ | 59 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_ENDPOINT_RESOLVER_H_ |
| OLD | NEW |