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_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_ | 5 #ifndef CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_ |
6 #define CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_ | 6 #define CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <string> | 11 #include <string> |
10 | 12 |
11 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "build/build_config.h" |
12 #include "chrome/common/local_discovery/service_discovery_client.h" | 15 #include "chrome/common/local_discovery/service_discovery_client.h" |
13 #include "chrome/utility/utility_message_handler.h" | 16 #include "chrome/utility/utility_message_handler.h" |
14 | 17 |
15 struct LocalDiscoveryMsg_SocketInfo; | 18 struct LocalDiscoveryMsg_SocketInfo; |
16 | 19 |
17 namespace net { | 20 namespace net { |
18 class MDnsClient; | 21 class MDnsClient; |
19 } | 22 } |
20 | 23 |
21 namespace base { | 24 namespace base { |
(...skipping 15 matching lines...) Expand all Loading... |
37 public: | 40 public: |
38 ServiceDiscoveryMessageHandler(); | 41 ServiceDiscoveryMessageHandler(); |
39 ~ServiceDiscoveryMessageHandler() override; | 42 ~ServiceDiscoveryMessageHandler() override; |
40 | 43 |
41 // UtilityMessageHandler implementation. | 44 // UtilityMessageHandler implementation. |
42 bool OnMessageReceived(const IPC::Message& message) override; | 45 bool OnMessageReceived(const IPC::Message& message) override; |
43 | 46 |
44 static void PreSandboxStartup(); | 47 static void PreSandboxStartup(); |
45 | 48 |
46 private: | 49 private: |
47 typedef std::map<uint64, linked_ptr<ServiceWatcher> > ServiceWatchers; | 50 typedef std::map<uint64_t, linked_ptr<ServiceWatcher>> ServiceWatchers; |
48 typedef std::map<uint64, linked_ptr<ServiceResolver> > ServiceResolvers; | 51 typedef std::map<uint64_t, linked_ptr<ServiceResolver>> ServiceResolvers; |
49 typedef std::map<uint64, linked_ptr<LocalDomainResolver> > | 52 typedef std::map<uint64_t, linked_ptr<LocalDomainResolver>> |
50 LocalDomainResolvers; | 53 LocalDomainResolvers; |
51 | 54 |
52 // Lazy initializes ServiceDiscoveryClient. | 55 // Lazy initializes ServiceDiscoveryClient. |
53 bool InitializeThread(); | 56 bool InitializeThread(); |
54 void PostTask(const tracked_objects::Location& from_here, | 57 void PostTask(const tracked_objects::Location& from_here, |
55 const base::Closure& task); | 58 const base::Closure& task); |
56 | 59 |
57 // IPC message handlers. | 60 // IPC message handlers. |
58 #if defined(OS_POSIX) | 61 #if defined(OS_POSIX) |
59 void OnSetSockets(const std::vector<LocalDiscoveryMsg_SocketInfo>& sockets); | 62 void OnSetSockets(const std::vector<LocalDiscoveryMsg_SocketInfo>& sockets); |
60 #endif // OS_POSIX | 63 #endif // OS_POSIX |
61 void OnStartWatcher(uint64 id, const std::string& service_type); | 64 void OnStartWatcher(uint64_t id, const std::string& service_type); |
62 void OnDiscoverServices(uint64 id, bool force_update); | 65 void OnDiscoverServices(uint64_t id, bool force_update); |
63 void OnSetActivelyRefreshServices(uint64 id, bool actively_refresh_services); | 66 void OnSetActivelyRefreshServices(uint64_t id, |
64 void OnDestroyWatcher(uint64 id); | 67 bool actively_refresh_services); |
65 void OnResolveService(uint64 id, const std::string& service_name); | 68 void OnDestroyWatcher(uint64_t id); |
66 void OnDestroyResolver(uint64 id); | 69 void OnResolveService(uint64_t id, const std::string& service_name); |
67 void OnResolveLocalDomain(uint64 id, const std::string& domain, | 70 void OnDestroyResolver(uint64_t id); |
| 71 void OnResolveLocalDomain(uint64_t id, |
| 72 const std::string& domain, |
68 net::AddressFamily address_family); | 73 net::AddressFamily address_family); |
69 void OnDestroyLocalDomainResolver(uint64 id); | 74 void OnDestroyLocalDomainResolver(uint64_t id); |
70 | 75 |
71 void InitializeMdns(); | 76 void InitializeMdns(); |
72 void StartWatcher(uint64 id, const std::string& service_type); | 77 void StartWatcher(uint64_t id, const std::string& service_type); |
73 void DiscoverServices(uint64 id, bool force_update); | 78 void DiscoverServices(uint64_t id, bool force_update); |
74 void SetActivelyRefreshServices(uint64 id, bool actively_refresh_services); | 79 void SetActivelyRefreshServices(uint64_t id, bool actively_refresh_services); |
75 void DestroyWatcher(uint64 id); | 80 void DestroyWatcher(uint64_t id); |
76 void ResolveService(uint64 id, const std::string& service_name); | 81 void ResolveService(uint64_t id, const std::string& service_name); |
77 void DestroyResolver(uint64 id); | 82 void DestroyResolver(uint64_t id); |
78 void ResolveLocalDomain(uint64 id, const std::string& domain, | 83 void ResolveLocalDomain(uint64_t id, |
| 84 const std::string& domain, |
79 net::AddressFamily address_family); | 85 net::AddressFamily address_family); |
80 void DestroyLocalDomainResolver(uint64 id); | 86 void DestroyLocalDomainResolver(uint64_t id); |
81 | 87 |
82 void ShutdownLocalDiscovery(); | 88 void ShutdownLocalDiscovery(); |
83 void ShutdownOnIOThread(); | 89 void ShutdownOnIOThread(); |
84 | 90 |
85 // Is called by ServiceWatcher as callback. | 91 // Is called by ServiceWatcher as callback. |
86 void OnServiceUpdated(uint64 id, | 92 void OnServiceUpdated(uint64_t id, |
87 ServiceWatcher::UpdateType update, | 93 ServiceWatcher::UpdateType update, |
88 const std::string& name); | 94 const std::string& name); |
89 | 95 |
90 // Is called by ServiceResolver as callback. | 96 // Is called by ServiceResolver as callback. |
91 void OnServiceResolved(uint64 id, | 97 void OnServiceResolved(uint64_t id, |
92 ServiceResolver::RequestStatus status, | 98 ServiceResolver::RequestStatus status, |
93 const ServiceDescription& description); | 99 const ServiceDescription& description); |
94 | 100 |
95 // Is called by LocalDomainResolver as callback. | 101 // Is called by LocalDomainResolver as callback. |
96 void OnLocalDomainResolved(uint64 id, | 102 void OnLocalDomainResolved(uint64_t id, |
97 bool success, | 103 bool success, |
98 const net::IPAddressNumber& address_ipv4, | 104 const net::IPAddressNumber& address_ipv4, |
99 const net::IPAddressNumber& address_ipv6); | 105 const net::IPAddressNumber& address_ipv6); |
100 | 106 |
101 void Send(IPC::Message* msg); | 107 void Send(IPC::Message* msg); |
102 | 108 |
103 ServiceWatchers service_watchers_; | 109 ServiceWatchers service_watchers_; |
104 ServiceResolvers service_resolvers_; | 110 ServiceResolvers service_resolvers_; |
105 LocalDomainResolvers local_domain_resolvers_; | 111 LocalDomainResolvers local_domain_resolvers_; |
106 | 112 |
107 scoped_ptr<net::MDnsClient> mdns_client_; | 113 scoped_ptr<net::MDnsClient> mdns_client_; |
108 scoped_ptr<ServiceDiscoveryClient> service_discovery_client_; | 114 scoped_ptr<ServiceDiscoveryClient> service_discovery_client_; |
109 | 115 |
110 scoped_refptr<base::TaskRunner> utility_task_runner_; | 116 scoped_refptr<base::TaskRunner> utility_task_runner_; |
111 scoped_refptr<base::TaskRunner> discovery_task_runner_; | 117 scoped_refptr<base::TaskRunner> discovery_task_runner_; |
112 scoped_ptr<base::Thread> discovery_thread_; | 118 scoped_ptr<base::Thread> discovery_thread_; |
113 }; | 119 }; |
114 | 120 |
115 } // namespace local_discovery | 121 } // namespace local_discovery |
116 | 122 |
117 #endif // CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_ | 123 #endif // CHROME_UTILITY_LOCAL_DISCOVERY_SERVICE_DISCOVERY_MESSAGE_HANDLER_H_ |
OLD | NEW |