Bug 1199049 - Part 6: Transfer the preflight parameters to the parent process in e10s mode; r=jduell

This commit is contained in:
Ehsan Akhgari 2015-08-31 16:36:22 -04:00
parent 661f3173cd
commit d1029ccc78
4 changed files with 47 additions and 3 deletions

View File

@ -58,6 +58,19 @@ union OptionalHttpResponseHead
nsHttpResponseHead;
};
struct CorsPreflightArgs
{
bool withCredentials;
PrincipalInfo preflightPrincipal;
nsCString[] unsafeHeaders;
};
union OptionalCorsPreflightArgs
{
void_t;
CorsPreflightArgs;
};
struct HttpChannelOpenArgs
{
URIParams uri;
@ -94,6 +107,7 @@ struct HttpChannelOpenArgs
nsCString synthesizedSecurityInfoSerialization;
uint32_t cacheKey;
nsCString schedulingContextID;
OptionalCorsPreflightArgs preflightArgs;
};
struct HttpChannelConnectArgs

View File

@ -1668,6 +1668,20 @@ HttpChannelChild::ContinueAsyncOpen()
optionalFDs = fdSet;
}
OptionalCorsPreflightArgs optionalCorsPreflightArgs;
if (mRequireCORSPreflight) {
CorsPreflightArgs args;
args.withCredentials() = mWithCredentials;
args.unsafeHeaders() = mUnsafeHeaders;
nsresult rv = PrincipalToPrincipalInfo(mPreflightPrincipal, &args.preflightPrincipal());
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
optionalCorsPreflightArgs = args;
} else {
optionalCorsPreflightArgs = mozilla::void_t();
}
nsCOMPtr<mozIThirdPartyUtil> util(do_GetService(THIRDPARTYUTIL_CONTRACTID));
if (util) {
bool thirdParty;
@ -1689,6 +1703,8 @@ HttpChannelChild::ContinueAsyncOpen()
openArgs.fds() = optionalFDs;
openArgs.preflightArgs() = optionalCorsPreflightArgs;
openArgs.uploadStreamHasHeaders() = mUploadStreamHasHeaders;
openArgs.priority() = mPriority;
openArgs.classOfService() = mClassOfService;

View File

@ -126,7 +126,7 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
a.appCacheClientID(), a.allowSpdy(), a.allowAltSvc(), a.fds(),
a.loadInfo(), a.synthesizedResponseHead(),
a.synthesizedSecurityInfoSerialization(),
a.cacheKey(), a.schedulingContextID());
a.cacheKey(), a.schedulingContextID(), a.preflightArgs());
}
case HttpChannelCreationArgs::THttpChannelConnectArgs:
{
@ -284,7 +284,8 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
const OptionalHttpResponseHead& aSynthesizedResponseHead,
const nsCString& aSecurityInfoSerialization,
const uint32_t& aCacheKey,
const nsCString& aSchedulingContextID)
const nsCString& aSchedulingContextID,
const OptionalCorsPreflightArgs& aCorsPreflightArgs)
{
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
if (!uri) {
@ -391,6 +392,18 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
get_ArrayOfFileDescriptor().SwapElements(fds);
}
if (aCorsPreflightArgs.type() == OptionalCorsPreflightArgs::TCorsPreflightArgs) {
const CorsPreflightArgs& args = aCorsPreflightArgs.get_CorsPreflightArgs();
nsCOMPtr<nsIPrincipal> preflightPrincipal =
PrincipalInfoToPrincipal(args.preflightPrincipal());
rv = mChannel->SetCorsPreflightParameters(args.unsafeHeaders(),
args.withCredentials(),
preflightPrincipal);
if (NS_FAILED(rv)) {
return SendFailedAsyncOpen(rv);
}
}
nsCOMPtr<nsIInputStream> stream = DeserializeInputStream(uploadStream, fds);
if (stream) {
mChannel->InternalSetUploadStream(stream);

View File

@ -120,7 +120,8 @@ protected:
const OptionalHttpResponseHead& aSynthesizedResponseHead,
const nsCString& aSecurityInfoSerialization,
const uint32_t& aCacheKey,
const nsCString& aSchedulingContextID);
const nsCString& aSchedulingContextID,
const OptionalCorsPreflightArgs& aCorsPreflightArgs);
virtual bool RecvSetPriority(const uint16_t& priority) override;
virtual bool RecvSetClassOfService(const uint32_t& cos) override;