Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2825)

Unified Diff: net/dns/mdns_client_impl.h

Issue 937743003: Fix MDnsClient's cache entry cleanup logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit tests; miscellaneous lint fixes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/dns/mdns_client_impl.cc » ('j') | net/dns/mdns_client_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/mdns_client_impl.h
diff --git a/net/dns/mdns_client_impl.h b/net/dns/mdns_client_impl.h
index 4ed85f24ac7404b1dafc7411a12ef171f0e49090..f5e7e144d526622c1470910160f5ed3885a545c7 100644
--- a/net/dns/mdns_client_impl.h
+++ b/net/dns/mdns_client_impl.h
@@ -6,6 +6,7 @@
#define NET_DNS_MDNS_CLIENT_IMPL_H_
#include <map>
+#include <queue>
#include <string>
#include <utility>
#include <vector>
@@ -21,11 +22,16 @@
#include "net/udp/udp_server_socket.h"
#include "net/udp/udp_socket.h"
+namespace base {
+class Clock;
+class Timer;
+} // namespace base
+
namespace net {
class MDnsSocketFactoryImpl : public MDnsSocketFactory {
public:
- MDnsSocketFactoryImpl() {};
+ MDnsSocketFactoryImpl() {}
~MDnsSocketFactoryImpl() override{};
void CreateSockets(ScopedVector<DatagramServerSocket>* sockets) override;
@@ -132,6 +138,8 @@ class NET_EXPORT_PRIVATE MDnsClientImpl : public MDnsClient {
void OnConnectionError(int error) override;
private:
+ FRIEND_TEST_ALL_PREFIXES(MDnsTest, CacheCleanupWithShortTTL);
+
typedef std::pair<std::string, uint16> ListenerKey;
typedef std::map<ListenerKey, ObserverList<MDnsListenerImpl>* >
ListenerMap;
@@ -155,11 +163,16 @@ class NET_EXPORT_PRIVATE MDnsClientImpl : public MDnsClient {
// list if is empty.
void CleanupObserverList(const ListenerKey& key);
+ void set_cleanup_timer_for_test(scoped_ptr<base::Timer> timer);
+
+ void set_clock_for_test(scoped_ptr<base::Clock> clock);
+
ListenerMap listeners_;
MDnsCache cache_;
- base::CancelableClosure cleanup_callback_;
+ scoped_ptr<base::Clock> clock_;
+ scoped_ptr<base::Timer> cleanup_timer_;
base::Time scheduled_cleanup_;
scoped_ptr<MDnsConnection> connection_;
« no previous file with comments | « no previous file | net/dns/mdns_client_impl.cc » ('j') | net/dns/mdns_client_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698