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 NET_DNS_MDNS_CLIENT_IMPL_H_ | 5 #ifndef NET_DNS_MDNS_CLIENT_IMPL_H_ |
6 #define NET_DNS_MDNS_CLIENT_IMPL_H_ | 6 #define NET_DNS_MDNS_CLIENT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 bool Init(MDnsSocketFactory* socket_factory); | 112 bool Init(MDnsSocketFactory* socket_factory); |
113 | 113 |
114 // Send a query with a specific rrtype and name. Returns true on success. | 114 // Send a query with a specific rrtype and name. Returns true on success. |
115 bool SendQuery(uint16 rrtype, std::string name); | 115 bool SendQuery(uint16 rrtype, std::string name); |
116 | 116 |
117 // Add/remove a listener to the list of listeners. | 117 // Add/remove a listener to the list of listeners. |
118 void AddListener(MDnsListenerImpl* listener); | 118 void AddListener(MDnsListenerImpl* listener); |
119 void RemoveListener(MDnsListenerImpl* listener); | 119 void RemoveListener(MDnsListenerImpl* listener); |
120 | 120 |
121 // Query the cache for records of a specific type and name. | 121 // Query the cache for records of a specific type and name. |
122 void QueryCache(uint16 rrtype, const std::string& name, | 122 void QueryCache(uint16 rrtype, |
| 123 const std::string& name, |
123 std::vector<const RecordParsed*>* records) const; | 124 std::vector<const RecordParsed*>* records) const; |
124 | 125 |
125 // Parse the response and alert relevant listeners. | 126 // Parse the response and alert relevant listeners. |
126 virtual void HandlePacket(DnsResponse* response, int bytes_read) OVERRIDE; | 127 virtual void HandlePacket(DnsResponse* response, int bytes_read) OVERRIDE; |
127 | 128 |
128 virtual void OnConnectionError(int error) OVERRIDE; | 129 virtual void OnConnectionError(int error) OVERRIDE; |
129 | 130 |
130 private: | 131 private: |
131 typedef std::pair<std::string, uint16> ListenerKey; | 132 typedef std::pair<std::string, uint16> ListenerKey; |
132 typedef std::map<ListenerKey, ObserverList<MDnsListenerImpl>* > | 133 typedef std::map<ListenerKey, ObserverList<MDnsListenerImpl>*> ListenerMap; |
133 ListenerMap; | |
134 | 134 |
135 // Alert listeners of an update to the cache. | 135 // Alert listeners of an update to the cache. |
136 void AlertListeners(MDnsCache::UpdateType update_type, | 136 void AlertListeners(MDnsCache::UpdateType update_type, |
137 const ListenerKey& key, const RecordParsed* record); | 137 const ListenerKey& key, |
| 138 const RecordParsed* record); |
138 | 139 |
139 // Schedule a cache cleanup to a specific time, cancelling other cleanups. | 140 // Schedule a cache cleanup to a specific time, cancelling other cleanups. |
140 void ScheduleCleanup(base::Time cleanup); | 141 void ScheduleCleanup(base::Time cleanup); |
141 | 142 |
142 // Clean up the cache and schedule a new cleanup. | 143 // Clean up the cache and schedule a new cleanup. |
143 void DoCleanup(); | 144 void DoCleanup(); |
144 | 145 |
145 // Callback for when a record is removed from the cache. | 146 // Callback for when a record is removed from the cache. |
146 void OnRecordRemoved(const RecordParsed* record); | 147 void OnRecordRemoved(const RecordParsed* record); |
147 | 148 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 MDnsClientImpl* client_; | 297 MDnsClientImpl* client_; |
297 | 298 |
298 bool started_; | 299 bool started_; |
299 int flags_; | 300 int flags_; |
300 | 301 |
301 DISALLOW_COPY_AND_ASSIGN(MDnsTransactionImpl); | 302 DISALLOW_COPY_AND_ASSIGN(MDnsTransactionImpl); |
302 }; | 303 }; |
303 | 304 |
304 } // namespace net | 305 } // namespace net |
305 #endif // NET_DNS_MDNS_CLIENT_IMPL_H_ | 306 #endif // NET_DNS_MDNS_CLIENT_IMPL_H_ |
OLD | NEW |