Bug 1186783 (part 4) - Replace nsBaseHashtable::EnumerateRead() calls in netwerk/ with iterators. r=valentin.

This commit is contained in:
Nicholas Nethercote 2015-11-19 16:46:24 -08:00
parent 398f724dc0
commit a53f4ae316
2 changed files with 10 additions and 23 deletions

View File

@ -23,16 +23,6 @@
#include "nsContentSecurityManager.h"
#include "LoadInfo.h"
static PLDHashOperator
CopyProperties(const nsAString &key, nsIVariant *data, void *closure)
{
nsIWritablePropertyBag *bag =
static_cast<nsIWritablePropertyBag *>(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<nsIWritablePropertyBag> 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

View File

@ -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<nsIWritablePropertyBag*>
(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<nsIWritablePropertyBag> 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<nsITimedChannel> newTimedChannel(do_QueryInterface(newChannel));