Bug 1186783 (part 5) - Replace nsBaseHashtable::EnumerateRead() calls in netwerk/ with iterators. r=valentin.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 19 Nov 2015 16:46:35 -0800
changeset 274528 149337c2aa8970ada0aaa78c124d085007db0127
parent 274527 a53d7747369c6d4fc12fd89e2cdb8c2c2195725b
child 274529 8d8a6449cb4edd1f7e13b232085ad7d1c07e2d86
push id68618
push usernnethercote@mozilla.com
push dateSun, 29 Nov 2015 22:39:56 +0000
treeherdermozilla-inbound@149337c2aa89 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin
bugs1186783
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1186783 (part 5) - Replace nsBaseHashtable::EnumerateRead() calls in netwerk/ with iterators. r=valentin.
netwerk/base/nsIOService.cpp
netwerk/base/nsIOService.h
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -1365,33 +1365,16 @@ IsWifiActive()
     }
 #else
     // On anything else than B2G we return true so than wifi-only
     // apps don't think they are offline.
     return true;
 #endif
 }
 
-struct EnumeratorParams {
-    nsIOService *service;
-    int32_t     status;
-};
-
-PLDHashOperator
-nsIOService::EnumerateWifiAppsChangingState(const unsigned int &aKey,
-                                            int32_t aValue,
-                                            void *aUserArg)
-{
-    EnumeratorParams *params = reinterpret_cast<EnumeratorParams*>(aUserArg);
-    if (aValue == nsIAppOfflineInfo::WIFI_ONLY) {
-        params->service->NotifyAppOfflineStatus(aKey, params->status);
-    }
-    return PL_DHASH_NEXT;
-}
-
 class
 nsWakeupNotifier : public nsRunnable
 {
 public:
     explicit nsWakeupNotifier(nsIIOServiceInternal *ioService)
         :mIOService(ioService)
     { }
 
@@ -1501,18 +1484,21 @@ nsIOService::Observe(nsISupports *subjec
         int32_t newWifiState = wifiActive ?
             nsINetworkInfo::NETWORK_TYPE_WIFI :
             nsINetworkInfo::NETWORK_TYPE_MOBILE;
         if (mPreviousWifiState != newWifiState) {
             // Notify wifi-only apps of their new status
             int32_t status = wifiActive ?
                 nsIAppOfflineInfo::ONLINE : nsIAppOfflineInfo::OFFLINE;
 
-            EnumeratorParams params = {this, status};
-            mAppsOfflineStatus.EnumerateRead(EnumerateWifiAppsChangingState, &params);
+            for (auto it = mAppsOfflineStatus.Iter(); !it.Done(); it.Next()) {
+                if (iter.UserData() == nsIAppOfflineInfo::WIFI_ONLY) {
+                    NotifyAppOfflineStatus(iter.Key(), status);
+                }
+            }
         }
 
         mPreviousWifiState = newWifiState;
 #endif
     }
 
     return NS_OK;
 }
--- a/netwerk/base/nsIOService.h
+++ b/netwerk/base/nsIOService.h
@@ -120,17 +120,16 @@ private:
 
     // consolidated helper function
     void LookupProxyInfo(nsIURI *aURI, nsIURI *aProxyURI, uint32_t aProxyFlags,
                          nsCString *aScheme, nsIProxyInfo **outPI);
 
     // notify content processes of offline status
     // 'status' must be a nsIAppOfflineInfo mode constant.
     void NotifyAppOfflineStatus(uint32_t appId, int32_t status);
-    static PLDHashOperator EnumerateWifiAppsChangingState(const unsigned int &, int32_t, void*);
 
     nsresult NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI,
                                                      nsIURI* aProxyURI,
                                                      uint32_t aProxyFlags,
                                                      nsILoadInfo* aLoadInfo,
                                                      nsIChannel** result);
 
     nsresult SpeculativeConnectInternal(nsIURI *aURI,