Bug 1128311 - Only flush the DNS cache when the last private browsing window is closed; r=mcmanus a=jcristau
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 29 Dec 2016 21:45:30 -0500
changeset 353475 6eca9e254f67364ac11753757f092724e3798534
parent 353474 adba84d693a69f2ee1c8dd23493128d6879b2288
child 353476 5425255d6615a46ce08b86b37d93153ad659100a
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, jcristau
bugs1128311
milestone52.0a2
Bug 1128311 - Only flush the DNS cache when the last private browsing window is closed; r=mcmanus a=jcristau
netwerk/dns/nsDNSService2.cpp
--- a/netwerk/dns/nsDNSService2.cpp
+++ b/netwerk/dns/nsDNSService2.cpp
@@ -939,21 +939,27 @@ nsDNSService::Observe(nsISupports *subje
 {
     // We are only getting called if a preference has changed or there's a
     // network link event.
     NS_ASSERTION(strcmp(topic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0 ||
                  strcmp(topic, "last-pb-context-exited") == 0 ||
                  strcmp(topic, NS_NETWORK_LINK_TOPIC) == 0,
                  "unexpected observe call");
 
+    bool flushCache = false;
     if (!strcmp(topic, NS_NETWORK_LINK_TOPIC)) {
         nsAutoCString converted = NS_ConvertUTF16toUTF8(data);
         if (mResolver && !strcmp(converted.get(), NS_NETWORK_LINK_DATA_CHANGED)) {
-            mResolver->FlushCache();
+            flushCache = true;
         }
+    } else if (!strcmp(topic, "last-pb-context-exited")) {
+        flushCache = true;
+    }
+    if (flushCache) {
+        mResolver->FlushCache();
         return NS_OK;
     }
 
     //
     // Shutdown and this function are both only called on the UI thread, so we don't
     // have to worry about mResolver being cleared out from under us.
     //
     // NOTE Shutting down and reinitializing the service like this is obviously