From 7ca9f8abdbbb51b566355b83da975f0c24fc8b3a Mon Sep 17 00:00:00 2001 From: roytam1 Date: Thu, 21 Nov 2024 21:43:07 +0800 Subject: [PATCH] import from UXP: Issue #2652 - Part 1: Add a way to programmatically clear the DNS cache. (f5ef3275) --- netwerk/dns/ChildDNSService.cpp | 7 +++++++ netwerk/dns/nsDNSService2.cpp | 6 ++++++ netwerk/dns/nsIDNSService.idl | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/netwerk/dns/ChildDNSService.cpp b/netwerk/dns/ChildDNSService.cpp index a3a1f3347..c95c3551f 100644 --- a/netwerk/dns/ChildDNSService.cpp +++ b/netwerk/dns/ChildDNSService.cpp @@ -202,6 +202,13 @@ ChildDNSService::GetDNSCacheEntries(nsTArray *arg return NS_ERROR_NOT_AVAILABLE; } +NS_IMETHODIMP +ChildDNSService::ClearCache() +{ + // Not available in IPC children. + return NS_ERROR_NOT_AVAILABLE; +} + NS_IMETHODIMP ChildDNSService::GetMyHostName(nsACString &result) { diff --git a/netwerk/dns/nsDNSService2.cpp b/netwerk/dns/nsDNSService2.cpp index bdf0615a6..f2d3f7e18 100644 --- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -1053,6 +1053,12 @@ nsDNSService::GetDNSCacheEntries(nsTArray *args) return NS_OK; } +NS_IMETHODIMP +nsDNSService::ClearCache() { + mResolver->FlushCache(); + return NS_OK; +} + size_t nsDNSService::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { diff --git a/netwerk/dns/nsIDNSService.idl b/netwerk/dns/nsIDNSService.idl index 2704790dc..816d01dd6 100644 --- a/netwerk/dns/nsIDNSService.idl +++ b/netwerk/dns/nsIDNSService.idl @@ -115,6 +115,11 @@ interface nsIDNSService : nsISupports */ [noscript] void getDNSCacheEntries(in EntriesArray args); + /** + * Clears the DNS cache. + */ + void clearCache(); + /** * @return the hostname of the operating system. */