| 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_SERVICE_DISCOVERY_HOST_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
| 13 #include "chrome/common/local_discovery/service_discovery_client.h" | 13 #include "chrome/common/local_discovery/service_discovery_client.h" |
| 14 #include "content/public/browser/utility_process_host_client.h" | 14 #include "content/public/browser/utility_process_host_client.h" |
| 15 #include "net/base/network_change_notifier.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class TaskRunner; | 18 class TaskRunner; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class UtilityProcessHost; | 22 class UtilityProcessHost; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace local_discovery { | 25 namespace local_discovery { |
| 25 | 26 |
| 26 // Implementation of ServiceDiscoveryClient that delegates all functionality to | 27 // Implementation of ServiceDiscoveryClient that delegates all functionality to |
| 27 // utility process. | 28 // utility process. |
| 28 class ServiceDiscoveryHostClient : public base::NonThreadSafe, | 29 class ServiceDiscoveryHostClient |
| 29 public ServiceDiscoveryClient, | 30 : public base::NonThreadSafe, |
| 30 public content::UtilityProcessHostClient { | 31 public ServiceDiscoveryClient, |
| 32 public content::UtilityProcessHostClient, |
| 33 public net::NetworkChangeNotifier::IPAddressObserver { |
| 31 public: | 34 public: |
| 32 ServiceDiscoveryHostClient(); | 35 ServiceDiscoveryHostClient(); |
| 33 | 36 |
| 34 // Starts utility process with ServiceDiscoveryClient. | 37 // Starts utility process with ServiceDiscoveryClient. |
| 35 void Start(); | 38 void Start(); |
| 36 | 39 |
| 37 // Shutdowns utility process. | 40 // Shutdowns utility process. |
| 38 void Shutdown(); | 41 void Shutdown(); |
| 39 | 42 |
| 40 // ServiceDiscoveryClient implementation. | 43 // ServiceDiscoveryClient implementation. |
| 41 virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher( | 44 virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher( |
| 42 const std::string& service_type, | 45 const std::string& service_type, |
| 43 const ServiceWatcher::UpdatedCallback& callback) OVERRIDE; | 46 const ServiceWatcher::UpdatedCallback& callback) OVERRIDE; |
| 44 virtual scoped_ptr<ServiceResolver> CreateServiceResolver( | 47 virtual scoped_ptr<ServiceResolver> CreateServiceResolver( |
| 45 const std::string& service_name, | 48 const std::string& service_name, |
| 46 const ServiceResolver::ResolveCompleteCallback& callback) OVERRIDE; | 49 const ServiceResolver::ResolveCompleteCallback& callback) OVERRIDE; |
| 47 virtual scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver( | 50 virtual scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver( |
| 48 const std::string& domain, | 51 const std::string& domain, |
| 49 net::AddressFamily address_family, | 52 net::AddressFamily address_family, |
| 50 const LocalDomainResolver::IPAddressCallback& callback) OVERRIDE; | 53 const LocalDomainResolver::IPAddressCallback& callback) OVERRIDE; |
| 51 | 54 |
| 52 // UtilityProcessHostClient implementation. | 55 // UtilityProcessHostClient implementation. |
| 53 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 54 | 57 |
| 58 // net::NetworkChangeNotifier::IPAddressObserver implementation. |
| 59 virtual void OnIPAddressChanged() OVERRIDE; |
| 60 |
| 55 protected: | 61 protected: |
| 56 virtual ~ServiceDiscoveryHostClient(); | 62 virtual ~ServiceDiscoveryHostClient(); |
| 57 | 63 |
| 58 private: | 64 private: |
| 59 class ServiceWatcherProxy; | 65 class ServiceWatcherProxy; |
| 60 class ServiceResolverProxy; | 66 class ServiceResolverProxy; |
| 61 class LocalDomainResolverProxy; | 67 class LocalDomainResolverProxy; |
| 62 | 68 |
| 63 typedef std::map<uint64, ServiceWatcher::UpdatedCallback> WatcherCallbacks; | 69 typedef std::map<uint64, ServiceWatcher::UpdatedCallback> WatcherCallbacks; |
| 64 typedef std::map<uint64, ServiceResolver::ResolveCompleteCallback> | 70 typedef std::map<uint64, ServiceResolver::ResolveCompleteCallback> |
| 65 ResolverCallbacks; | 71 ResolverCallbacks; |
| 66 typedef std::map<uint64, LocalDomainResolver::IPAddressCallback> | 72 typedef std::map<uint64, LocalDomainResolver::IPAddressCallback> |
| 67 DomainResolverCallbacks; | 73 DomainResolverCallbacks; |
| 68 | 74 |
| 69 void StartOnIOThread(); | 75 void StartOnIOThread(); |
| 70 void ShutdownOnIOThread(); | 76 void ShutdownOnIOThread(); |
| 77 void RestartOnIOThread(); |
| 71 | 78 |
| 72 void Send(IPC::Message* msg); | 79 void Send(IPC::Message* msg); |
| 73 void SendOnIOThread(IPC::Message* msg); | 80 void SendOnIOThread(IPC::Message* msg); |
| 74 | 81 |
| 75 uint64 RegisterWatcherCallback( | 82 uint64 RegisterWatcherCallback( |
| 76 const ServiceWatcher::UpdatedCallback& callback); | 83 const ServiceWatcher::UpdatedCallback& callback); |
| 77 uint64 RegisterResolverCallback( | 84 uint64 RegisterResolverCallback( |
| 78 const ServiceResolver::ResolveCompleteCallback& callback); | 85 const ServiceResolver::ResolveCompleteCallback& callback); |
| 79 uint64 RegisterLocalDomainResolverCallback( | 86 uint64 RegisterLocalDomainResolverCallback( |
| 80 const LocalDomainResolver::IPAddressCallback& callback); | 87 const LocalDomainResolver::IPAddressCallback& callback); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ServiceDiscoveryHostClient* GetClientInternal(); | 146 ServiceDiscoveryHostClient* GetClientInternal(); |
| 140 void ReleaseClientInternal(); | 147 void ReleaseClientInternal(); |
| 141 | 148 |
| 142 scoped_refptr<ServiceDiscoveryHostClient> instance_; | 149 scoped_refptr<ServiceDiscoveryHostClient> instance_; |
| 143 int references_; | 150 int references_; |
| 144 }; | 151 }; |
| 145 | 152 |
| 146 } // namespace local_discovery | 153 } // namespace local_discovery |
| 147 | 154 |
| 148 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ | 155 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ |
| OLD | NEW |