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

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: Formatting 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') | no next file with comments »
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..a0c5b987836af709d2590d8b982c0a8ec3d259bb 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;
@@ -109,7 +115,7 @@ class NET_EXPORT_PRIVATE MDnsClientImpl : public MDnsClient {
// invalidate the core.
class Core : public base::SupportsWeakPtr<Core>, MDnsConnection::Delegate {
public:
- Core();
+ Core(base::Clock* clock, base::Timer* timer);
~Core() override;
// Initialize the core. Returns true on success.
@@ -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;
@@ -159,7 +167,8 @@ class NET_EXPORT_PRIVATE MDnsClientImpl : public MDnsClient {
MDnsCache cache_;
- base::CancelableClosure cleanup_callback_;
+ base::Clock* clock_;
+ base::Timer* cleanup_timer_;
base::Time scheduled_cleanup_;
scoped_ptr<MDnsConnection> connection_;
@@ -189,7 +198,15 @@ class NET_EXPORT_PRIVATE MDnsClientImpl : public MDnsClient {
Core* core() { return core_.get(); }
private:
+ FRIEND_TEST_ALL_PREFIXES(MDnsTest, CacheCleanupWithShortTTL);
+
+ // Test constructor, takes a mock clock and mock timer.
+ MDnsClientImpl(scoped_ptr<base::Clock> clock,
+ scoped_ptr<base::Timer> cleanup_timer);
+
scoped_ptr<Core> core_;
+ scoped_ptr<base::Clock> clock_;
+ scoped_ptr<base::Timer> cleanup_timer_;
DISALLOW_COPY_AND_ASSIGN(MDnsClientImpl);
};
@@ -199,6 +216,7 @@ class MDnsListenerImpl : public MDnsListener,
public:
MDnsListenerImpl(uint16 rrtype,
const std::string& name,
+ base::Clock* clock,
MDnsListener::Delegate* delegate,
MDnsClientImpl* client);
@@ -229,6 +247,7 @@ class MDnsListenerImpl : public MDnsListener,
uint16 rrtype_;
std::string name_;
+ base::Clock* clock_;
MDnsClientImpl* client_;
MDnsListener::Delegate* delegate_;
« no previous file with comments | « no previous file | net/dns/mdns_client_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698