Bug 1168208 - Refactor the existing logic for syncing the security info between Response and channel objects into a new helper class; r=nsm,jdm,bkelly

This commit is contained in:
Ehsan Akhgari
2015-05-25 14:21:05 -04:00
parent 070caf25e5
commit f770eb78bf
22 changed files with 327 additions and 140 deletions

View File

@@ -10,7 +10,6 @@
#include "mozilla/dom/cache/CacheStorage.h"
#include "mozilla/dom/cache/Cache.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsSerializationHelper.h"
#include "nsIPrincipal.h"
#include "Workers.h"
@@ -446,9 +445,9 @@ public:
}
void
SetSecurityInfo(nsISerializable* aSecurityInfo)
InitChannelInfo(nsIChannel* aChannel)
{
NS_SerializeToString(aSecurityInfo, mSecurityInfo);
mChannelInfo.InitFromChannel(aChannel);
}
private:
@@ -545,7 +544,7 @@ private:
new InternalResponse(200, NS_LITERAL_CSTRING("OK"));
ir->SetBody(body);
ir->SetSecurityInfo(mSecurityInfo);
ir->InitChannelInfo(mChannelInfo);
nsRefPtr<Response> response = new Response(aCache->GetGlobalObject(), ir);
@@ -577,7 +576,7 @@ private:
// Only used if the network script has changed and needs to be cached.
nsString mNewCacheName;
nsCString mSecurityInfo;
ChannelInfo mChannelInfo;
nsCString mMaxScope;
@@ -606,16 +605,7 @@ CompareNetwork::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
MOZ_ASSERT(channel == mChannel);
#endif
nsCOMPtr<nsISupports> infoObj;
mChannel->GetSecurityInfo(getter_AddRefs(infoObj));
if (infoObj) {
nsCOMPtr<nsISerializable> serializable = do_QueryInterface(infoObj);
if (serializable) {
mManager->SetSecurityInfo(serializable);
} else {
NS_WARNING("A non-serializable object was obtained from nsIChannel::GetSecurityInfo()!");
}
}
mManager->InitChannelInfo(mChannel);
return NS_OK;
}