From a53f4ae31695eca1b420d2f48a20c6eeaeaa6615 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 19 Nov 2015 16:46:24 -0800 Subject: [PATCH] Bug 1186783 (part 4) - Replace nsBaseHashtable::EnumerateRead() calls in netwerk/ with iterators. r=valentin. --- netwerk/base/nsBaseChannel.cpp | 17 +++++------------ netwerk/protocol/http/HttpBaseChannel.cpp | 16 +++++----------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 278134fc0ca..a736b7965dd 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -23,16 +23,6 @@ #include "nsContentSecurityManager.h" #include "LoadInfo.h" -static PLDHashOperator -CopyProperties(const nsAString &key, nsIVariant *data, void *closure) -{ - nsIWritablePropertyBag *bag = - static_cast(closure); - - bag->SetProperty(key, data); - return PL_DHASH_NEXT; -} - // This class is used to suspend a request across a function scope. class ScopedRequestSuspender { public: @@ -121,8 +111,11 @@ nsBaseChannel::Redirect(nsIChannel *newChannel, uint32_t redirectFlags, } nsCOMPtr bag = ::do_QueryInterface(newChannel); - if (bag) - mPropertyHash.EnumerateRead(CopyProperties, bag.get()); + if (bag) { + for (auto iter = mPropertyHash.Iter(); !iter.Done(); iter.Next()) { + bag->SetProperty(iter.Key(), iter.UserData()); + } + } // Notify consumer, giving chance to cancel redirect. For backwards compat, // we support nsIHttpEventSink if we are an HTTP channel and if this is not diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 3a8b39ea089..82075c34334 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -2530,15 +2530,6 @@ HttpBaseChannel::AddCookiesToRequest() SetRequestHeader(nsDependentCString(nsHttp::Cookie), cookie, false); } -static PLDHashOperator -CopyProperties(const nsAString& aKey, nsIVariant *aData, void *aClosure) -{ - nsIWritablePropertyBag* bag = static_cast - (aClosure); - bag->SetProperty(aKey, aData); - return PL_DHASH_NEXT; -} - bool HttpBaseChannel::ShouldRewriteRedirectToGET(uint32_t httpStatus, nsHttpRequestHead::ParsedMethodType method) @@ -2734,8 +2725,11 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI, // transfer any properties nsCOMPtr bag(do_QueryInterface(newChannel)); - if (bag) - mPropertyHash.EnumerateRead(CopyProperties, bag.get()); + if (bag) { + for (auto iter = mPropertyHash.Iter(); !iter.Done(); iter.Next()) { + bag->SetProperty(iter.Key(), iter.UserData()); + } + } // Transfer the timing data (if we are dealing with an nsITimedChannel). nsCOMPtr newTimedChannel(do_QueryInterface(newChannel));