| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_PRIVET_HTTP_ASYNCHRONOUS_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_ASYNCHRONOUS_FACTORY_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_ASYNCHRONOUS_FACTORY_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_ASYNCHRONOUS_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/local_discovery/privet_http.h" | 10 #include "base/callback.h" |
| 11 #include "chrome/browser/local_discovery/privet_http_impl.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/common/local_discovery/service_discovery_client.h" | 12 |
| 13 namespace net { |
| 14 class HostPortPair; |
| 15 class URLRequestContextGetter; |
| 16 } |
| 13 | 17 |
| 14 namespace local_discovery { | 18 namespace local_discovery { |
| 15 | 19 |
| 20 class PrivetHTTPClient; |
| 21 class ServiceDiscoveryClient; |
| 22 |
| 23 class PrivetHTTPResolution { |
| 24 public: |
| 25 virtual ~PrivetHTTPResolution() {} |
| 26 virtual void Start() = 0; |
| 27 }; |
| 28 |
| 16 class PrivetHTTPAsynchronousFactory { | 29 class PrivetHTTPAsynchronousFactory { |
| 17 public: | 30 public: |
| 18 typedef base::Callback<void(scoped_ptr<PrivetHTTPClient>)> ResultCallback; | 31 typedef base::Callback<void(scoped_ptr<PrivetHTTPClient>)> ResultCallback; |
| 19 | 32 |
| 20 class Resolution { | |
| 21 public: | |
| 22 virtual ~Resolution() {} | |
| 23 virtual void Start() = 0; | |
| 24 }; | |
| 25 | |
| 26 virtual ~PrivetHTTPAsynchronousFactory() {} | 33 virtual ~PrivetHTTPAsynchronousFactory() {} |
| 27 | 34 |
| 28 virtual scoped_ptr<Resolution> CreatePrivetHTTP( | 35 static scoped_ptr<PrivetHTTPAsynchronousFactory> CreateInstance( |
| 36 ServiceDiscoveryClient* service_discovery_client, |
| 37 net::URLRequestContextGetter* request_context); |
| 38 |
| 39 virtual scoped_ptr<PrivetHTTPResolution> CreatePrivetHTTP( |
| 29 const std::string& name, | 40 const std::string& name, |
| 30 const net::HostPortPair& address, | 41 const net::HostPortPair& address, |
| 31 const ResultCallback& callback) = 0; | 42 const ResultCallback& callback) = 0; |
| 32 }; | 43 }; |
| 33 | 44 |
| 34 class PrivetHTTPAsynchronousFactoryImpl : public PrivetHTTPAsynchronousFactory { | |
| 35 public: | |
| 36 PrivetHTTPAsynchronousFactoryImpl( | |
| 37 ServiceDiscoveryClient* service_discovery_client, | |
| 38 net::URLRequestContextGetter* request_context); | |
| 39 virtual ~PrivetHTTPAsynchronousFactoryImpl(); | |
| 40 | |
| 41 virtual scoped_ptr<Resolution> CreatePrivetHTTP( | |
| 42 const std::string& name, | |
| 43 const net::HostPortPair& address, | |
| 44 const ResultCallback& callback) OVERRIDE; | |
| 45 | |
| 46 private: | |
| 47 class ResolutionImpl : public Resolution { | |
| 48 public: | |
| 49 ResolutionImpl(const std::string& name, | |
| 50 const net::HostPortPair& address, | |
| 51 const ResultCallback& callback, | |
| 52 ServiceDiscoveryClient* service_discovery_client, | |
| 53 net::URLRequestContextGetter* request_context); | |
| 54 virtual ~ResolutionImpl(); | |
| 55 | |
| 56 virtual void Start() OVERRIDE; | |
| 57 private: | |
| 58 void ResolveComplete(bool success, | |
| 59 const net::IPAddressNumber& address_ipv4, | |
| 60 const net::IPAddressNumber& address_ipv6); | |
| 61 | |
| 62 std::string name_; | |
| 63 scoped_ptr<LocalDomainResolver> resolver_; | |
| 64 net::HostPortPair hostport_; | |
| 65 ResultCallback callback_; | |
| 66 scoped_refptr<net::URLRequestContextGetter> request_context_; | |
| 67 }; | |
| 68 | |
| 69 ServiceDiscoveryClient* service_discovery_client_; | |
| 70 scoped_refptr<net::URLRequestContextGetter> request_context_; | |
| 71 }; | |
| 72 | |
| 73 } // namespace local_discovery | 45 } // namespace local_discovery |
| 74 | 46 |
| 75 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_ASYNCHRONOUS_FACTORY_H_ | 47 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_ASYNCHRONOUS_FACTORY_H_ |
| OLD | NEW |