| 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 <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 #include <string> | 11 #include <string> |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 14 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 14 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "build/build_config.h" |
| 15 #include "chrome/common/local_discovery/service_discovery_client.h" | 19 #include "chrome/common/local_discovery/service_discovery_client.h" |
| 16 #include "content/public/browser/utility_process_host_client.h" | 20 #include "content/public/browser/utility_process_host_client.h" |
| 17 | 21 |
| 18 struct LocalDiscoveryMsg_SocketInfo; | 22 struct LocalDiscoveryMsg_SocketInfo; |
| 19 | 23 |
| 20 namespace base { | 24 namespace base { |
| 21 class TaskRunner; | 25 class TaskRunner; |
| 22 } | 26 } |
| 23 | 27 |
| 24 namespace content { | 28 namespace content { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 67 |
| 64 protected: | 68 protected: |
| 65 ~ServiceDiscoveryHostClient() override; | 69 ~ServiceDiscoveryHostClient() override; |
| 66 | 70 |
| 67 private: | 71 private: |
| 68 class ServiceWatcherProxy; | 72 class ServiceWatcherProxy; |
| 69 class ServiceResolverProxy; | 73 class ServiceResolverProxy; |
| 70 class LocalDomainResolverProxy; | 74 class LocalDomainResolverProxy; |
| 71 friend class ServiceDiscoveryClientUtility; | 75 friend class ServiceDiscoveryClientUtility; |
| 72 | 76 |
| 73 typedef std::map<uint64, ServiceWatcher::UpdatedCallback> WatcherCallbacks; | 77 typedef std::map<uint64_t, ServiceWatcher::UpdatedCallback> WatcherCallbacks; |
| 74 typedef std::map<uint64, ServiceResolver::ResolveCompleteCallback> | 78 typedef std::map<uint64_t, ServiceResolver::ResolveCompleteCallback> |
| 75 ResolverCallbacks; | 79 ResolverCallbacks; |
| 76 typedef std::map<uint64, LocalDomainResolver::IPAddressCallback> | 80 typedef std::map<uint64_t, LocalDomainResolver::IPAddressCallback> |
| 77 DomainResolverCallbacks; | 81 DomainResolverCallbacks; |
| 78 | 82 |
| 79 void StartOnIOThread(); | 83 void StartOnIOThread(); |
| 80 void ShutdownOnIOThread(); | 84 void ShutdownOnIOThread(); |
| 81 | 85 |
| 82 #if defined(OS_POSIX) | 86 #if defined(OS_POSIX) |
| 83 void OnSocketsReady(const SocketInfoList& interfaces); | 87 void OnSocketsReady(const SocketInfoList& interfaces); |
| 84 #endif // OS_POSIX | 88 #endif // OS_POSIX |
| 85 | 89 |
| 86 void InvalidateWatchers(); | 90 void InvalidateWatchers(); |
| 87 | 91 |
| 88 void Send(IPC::Message* msg); | 92 void Send(IPC::Message* msg); |
| 89 void SendOnIOThread(IPC::Message* msg); | 93 void SendOnIOThread(IPC::Message* msg); |
| 90 | 94 |
| 91 uint64 RegisterWatcherCallback( | 95 uint64_t RegisterWatcherCallback( |
| 92 const ServiceWatcher::UpdatedCallback& callback); | 96 const ServiceWatcher::UpdatedCallback& callback); |
| 93 uint64 RegisterResolverCallback( | 97 uint64_t RegisterResolverCallback( |
| 94 const ServiceResolver::ResolveCompleteCallback& callback); | 98 const ServiceResolver::ResolveCompleteCallback& callback); |
| 95 uint64 RegisterLocalDomainResolverCallback( | 99 uint64_t RegisterLocalDomainResolverCallback( |
| 96 const LocalDomainResolver::IPAddressCallback& callback); | 100 const LocalDomainResolver::IPAddressCallback& callback); |
| 97 | 101 |
| 98 void UnregisterWatcherCallback(uint64 id); | 102 void UnregisterWatcherCallback(uint64_t id); |
| 99 void UnregisterResolverCallback(uint64 id); | 103 void UnregisterResolverCallback(uint64_t id); |
| 100 void UnregisterLocalDomainResolverCallback(uint64 id); | 104 void UnregisterLocalDomainResolverCallback(uint64_t id); |
| 101 | 105 |
| 102 // IPC Message handlers. | 106 // IPC Message handlers. |
| 103 void OnError(); | 107 void OnError(); |
| 104 void OnWatcherCallback(uint64 id, | 108 void OnWatcherCallback(uint64_t id, |
| 105 ServiceWatcher::UpdateType update, | 109 ServiceWatcher::UpdateType update, |
| 106 const std::string& service_name); | 110 const std::string& service_name); |
| 107 void OnResolverCallback(uint64 id, | 111 void OnResolverCallback(uint64_t id, |
| 108 ServiceResolver::RequestStatus status, | 112 ServiceResolver::RequestStatus status, |
| 109 const ServiceDescription& description); | 113 const ServiceDescription& description); |
| 110 void OnLocalDomainResolverCallback(uint64 id, | 114 void OnLocalDomainResolverCallback(uint64_t id, |
| 111 bool success, | 115 bool success, |
| 112 const net::IPAddressNumber& address_ipv4, | 116 const net::IPAddressNumber& address_ipv4, |
| 113 const net::IPAddressNumber& address_ipv6); | 117 const net::IPAddressNumber& address_ipv6); |
| 114 | 118 |
| 115 | |
| 116 // Runs watcher callback on owning thread. | 119 // Runs watcher callback on owning thread. |
| 117 void RunWatcherCallback(uint64 id, | 120 void RunWatcherCallback(uint64_t id, |
| 118 ServiceWatcher::UpdateType update, | 121 ServiceWatcher::UpdateType update, |
| 119 const std::string& service_name); | 122 const std::string& service_name); |
| 120 // Runs resolver callback on owning thread. | 123 // Runs resolver callback on owning thread. |
| 121 void RunResolverCallback(uint64 id, | 124 void RunResolverCallback(uint64_t id, |
| 122 ServiceResolver::RequestStatus status, | 125 ServiceResolver::RequestStatus status, |
| 123 const ServiceDescription& description); | 126 const ServiceDescription& description); |
| 124 // Runs local domain resolver callback on owning thread. | 127 // Runs local domain resolver callback on owning thread. |
| 125 void RunLocalDomainResolverCallback(uint64 id, | 128 void RunLocalDomainResolverCallback(uint64_t id, |
| 126 bool success, | 129 bool success, |
| 127 const net::IPAddressNumber& address_ipv4, | 130 const net::IPAddressNumber& address_ipv4, |
| 128 const net::IPAddressNumber& address_ipv6); | 131 const net::IPAddressNumber& address_ipv6); |
| 129 | 132 |
| 130 | |
| 131 base::WeakPtr<content::UtilityProcessHost> utility_host_; | 133 base::WeakPtr<content::UtilityProcessHost> utility_host_; |
| 132 | 134 |
| 133 // Incrementing counter to assign ID to watchers and resolvers. | 135 // Incrementing counter to assign ID to watchers and resolvers. |
| 134 uint64 current_id_; | 136 uint64_t current_id_; |
| 135 base::Closure error_callback_; | 137 base::Closure error_callback_; |
| 136 WatcherCallbacks service_watcher_callbacks_; | 138 WatcherCallbacks service_watcher_callbacks_; |
| 137 ResolverCallbacks service_resolver_callbacks_; | 139 ResolverCallbacks service_resolver_callbacks_; |
| 138 DomainResolverCallbacks domain_resolver_callbacks_; | 140 DomainResolverCallbacks domain_resolver_callbacks_; |
| 139 scoped_refptr<base::TaskRunner> callback_runner_; | 141 scoped_refptr<base::TaskRunner> callback_runner_; |
| 140 scoped_refptr<base::TaskRunner> io_runner_; | 142 scoped_refptr<base::TaskRunner> io_runner_; |
| 141 ScopedVector<IPC::Message> delayed_messages_; | 143 ScopedVector<IPC::Message> delayed_messages_; |
| 142 | 144 |
| 143 DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryHostClient); | 145 DISALLOW_COPY_AND_ASSIGN(ServiceDiscoveryHostClient); |
| 144 }; | 146 }; |
| 145 | 147 |
| 146 } // namespace local_discovery | 148 } // namespace local_discovery |
| 147 | 149 |
| 148 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ | 150 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_SERVICE_DISCOVERY_HOST_CLIENT_H_ |
| OLD | NEW |