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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 namespace local_discovery { | 25 namespace local_discovery { |
26 | 26 |
27 // Implementation of ServiceDiscoveryClient that delegates all functionality to | 27 // Implementation of ServiceDiscoveryClient that delegates all functionality to |
28 // utility process. | 28 // utility process. |
29 class ServiceDiscoveryHostClient | 29 class ServiceDiscoveryHostClient |
30 : public base::NonThreadSafe, | 30 : public base::NonThreadSafe, |
31 public ServiceDiscoveryClient, | 31 public ServiceDiscoveryClient, |
32 public content::UtilityProcessHostClient, | 32 public content::UtilityProcessHostClient, |
33 public net::NetworkChangeNotifier::IPAddressObserver { | 33 public net::NetworkChangeNotifier::NetworkChangeObserver { |
34 public: | 34 public: |
35 ServiceDiscoveryHostClient(); | 35 ServiceDiscoveryHostClient(); |
36 | 36 |
37 // Starts utility process with ServiceDiscoveryClient. | 37 // Starts utility process with ServiceDiscoveryClient. |
38 void Start(); | 38 void Start(); |
39 | 39 |
40 // Shutdowns utility process. | 40 // Shutdowns utility process. |
41 void Shutdown(); | 41 void Shutdown(); |
42 | 42 |
43 // ServiceDiscoveryClient implementation. | 43 // ServiceDiscoveryClient implementation. |
44 virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher( | 44 virtual scoped_ptr<ServiceWatcher> CreateServiceWatcher( |
45 const std::string& service_type, | 45 const std::string& service_type, |
46 const ServiceWatcher::UpdatedCallback& callback) OVERRIDE; | 46 const ServiceWatcher::UpdatedCallback& callback) OVERRIDE; |
47 virtual scoped_ptr<ServiceResolver> CreateServiceResolver( | 47 virtual scoped_ptr<ServiceResolver> CreateServiceResolver( |
48 const std::string& service_name, | 48 const std::string& service_name, |
49 const ServiceResolver::ResolveCompleteCallback& callback) OVERRIDE; | 49 const ServiceResolver::ResolveCompleteCallback& callback) OVERRIDE; |
50 virtual scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver( | 50 virtual scoped_ptr<LocalDomainResolver> CreateLocalDomainResolver( |
51 const std::string& domain, | 51 const std::string& domain, |
52 net::AddressFamily address_family, | 52 net::AddressFamily address_family, |
53 const LocalDomainResolver::IPAddressCallback& callback) OVERRIDE; | 53 const LocalDomainResolver::IPAddressCallback& callback) OVERRIDE; |
54 | 54 |
55 // UtilityProcessHostClient implementation. | 55 // UtilityProcessHostClient implementation. |
56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
57 | 57 |
58 // net::NetworkChangeNotifier::IPAddressObserver implementation. | 58 // net::NetworkChangeNotifier::NetworkChangeObserver implementation. |
59 virtual void OnIPAddressChanged() OVERRIDE; | 59 virtual void OnNetworkChanged( |
| 60 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
60 | 61 |
61 protected: | 62 protected: |
62 virtual ~ServiceDiscoveryHostClient(); | 63 virtual ~ServiceDiscoveryHostClient(); |
63 | 64 |
64 private: | 65 private: |
65 class ServiceWatcherProxy; | 66 class ServiceWatcherProxy; |
66 class ServiceResolverProxy; | 67 class ServiceResolverProxy; |
67 class LocalDomainResolverProxy; | 68 class LocalDomainResolverProxy; |
68 | 69 |
69 typedef std::map<uint64, ServiceWatcher::UpdatedCallback> WatcherCallbacks; | 70 typedef std::map<uint64, ServiceWatcher::UpdatedCallback> WatcherCallbacks; |
70 typedef std::map<uint64, ServiceResolver::ResolveCompleteCallback> | 71 typedef std::map<uint64, ServiceResolver::ResolveCompleteCallback> |
71 ResolverCallbacks; | 72 ResolverCallbacks; |
72 typedef std::map<uint64, LocalDomainResolver::IPAddressCallback> | 73 typedef std::map<uint64, LocalDomainResolver::IPAddressCallback> |
73 DomainResolverCallbacks; | 74 DomainResolverCallbacks; |
74 | 75 |
75 void StartOnIOThread(); | 76 void StartOnIOThread(); |
76 void ShutdownOnIOThread(); | 77 void ShutdownOnIOThread(); |
77 void RestartOnIOThread(); | 78 void RestartOnIOThread(); |
78 | 79 |
| 80 void Restart(); |
| 81 |
79 void Send(IPC::Message* msg); | 82 void Send(IPC::Message* msg); |
80 void SendOnIOThread(IPC::Message* msg); | 83 void SendOnIOThread(IPC::Message* msg); |
81 | 84 |
82 uint64 RegisterWatcherCallback( | 85 uint64 RegisterWatcherCallback( |
83 const ServiceWatcher::UpdatedCallback& callback); | 86 const ServiceWatcher::UpdatedCallback& callback); |
84 uint64 RegisterResolverCallback( | 87 uint64 RegisterResolverCallback( |
85 const ServiceResolver::ResolveCompleteCallback& callback); | 88 const ServiceResolver::ResolveCompleteCallback& callback); |
86 uint64 RegisterLocalDomainResolverCallback( | 89 uint64 RegisterLocalDomainResolverCallback( |
87 const LocalDomainResolver::IPAddressCallback& callback); | 90 const LocalDomainResolver::IPAddressCallback& callback); |
88 | 91 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 ServiceDiscoveryHostClient* GetClientInternal(); | 150 ServiceDiscoveryHostClient* GetClientInternal(); |
148 void ReleaseClientInternal(); | 151 void ReleaseClientInternal(); |
149 | 152 |
150 scoped_refptr<ServiceDiscoveryHostClient> instance_; | 153 scoped_refptr<ServiceDiscoveryHostClient> instance_; |
151 int references_; | 154 int references_; |
152 }; | 155 }; |
153 | 156 |
154 } // namespace local_discovery | 157 } // namespace local_discovery |
155 | 158 |
156 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ | 159 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ |
OLD | NEW |