Bug 541174 - e10s HTTP: Improve how URIs are serialized (part2). r=dwitte

This commit is contained in:
Josh Matthews 2010-04-26 11:24:21 -04:00
parent 340fad54df
commit 2989db727c
4 changed files with 34 additions and 83 deletions

View File

@ -238,33 +238,10 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
// TODO: add self to loadgroup?
// TODO: smartest way to pass nsURI == (spec, charset)?
nsCAutoString charset;
mURI->GetOriginCharset(charset);
nsCAutoString originalSpec;
mOriginalURI->GetSpec(originalSpec);
nsCAutoString originalCharset;
mOriginalURI->GetOriginCharset(originalCharset);
nsCAutoString docSpec;
nsCAutoString docCharset;
if (mDocumentURI) {
mDocumentURI->GetSpec(docSpec);
mDocumentURI->GetOriginCharset(docCharset);
}
nsCAutoString referrerSpec;
nsCAutoString referrerCharset;
if (mReferrer) {
mReferrer->GetSpec(referrerSpec);
mReferrer->GetOriginCharset(referrerCharset);
}
SendAsyncOpen(mSpec, charset, originalSpec, originalCharset, docSpec,
docCharset, referrerSpec, referrerCharset, mLoadFlags,
mRequestHeaders, mRequestHead.Method(), mPriority,
mRedirectionLimit, mAllowPipelining,
mForceAllowThirdPartyCookie);
SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI), IPC::URI(mDocumentURI),
IPC::URI(mReferrer), mLoadFlags, mRequestHeaders,
mRequestHead.Method(), mPriority, mRedirectionLimit,
mAllowPipelining, mForceAllowThirdPartyCookie);
mIsPending = PR_TRUE;
mWasOpened = PR_TRUE;

View File

@ -75,14 +75,10 @@ NS_IMPL_ISUPPORTS3(HttpChannelParent,
//-----------------------------------------------------------------------------
bool
HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
const nsCString& charset,
const nsCString& originalUriSpec,
const nsCString& originalCharset,
const nsCString& docUriSpec,
const nsCString& docCharset,
const nsCString& referrerSpec,
const nsCString& referrerCharset,
HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
const IPC::URI& aOriginalURI,
const IPC::URI& aDocURI,
const IPC::URI& aReferrerURI,
const PRUint32& loadFlags,
const RequestHeaderTuples& requestHeaders,
const nsHttpAtom& requestMethod,
@ -91,8 +87,15 @@ HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
const PRBool& allowPipelining,
const PRBool& forceAllowThirdPartyCookie)
{
LOG(("HttpChannelParent RecvAsyncOpen [this=%x uri=%s (%s)]\n",
this, uriSpec.get(), charset.get()));
nsCOMPtr<nsIURI> uri = aURI;
nsCOMPtr<nsIURI> originalUri = aOriginalURI;
nsCOMPtr<nsIURI> docUri = aDocURI;
nsCOMPtr<nsIURI> referrerUri = aReferrerURI;
nsCString uriSpec;
uri->GetSpec(uriSpec);
LOG(("HttpChannelParent RecvAsyncOpen [this=%x uri=%s]\n",
this, uriSpec.get()));
nsresult rv;
@ -100,11 +103,6 @@ HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
if (NS_FAILED(rv))
return false; // TODO: send fail msg to child, return true
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), uriSpec, charset.get(), nsnull, ios);
if (NS_FAILED(rv))
return false; // TODO: send fail msg to child, return true
nsCOMPtr<nsIChannel> chan;
rv = NS_NewChannel(getter_AddRefs(chan), uri, ios, nsnull, nsnull, loadFlags);
if (NS_FAILED(rv))
@ -112,29 +110,12 @@ HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(chan.get());
if (!originalUriSpec.IsEmpty()) {
nsCOMPtr<nsIURI> originalUri;
rv = NS_NewURI(getter_AddRefs(originalUri), originalUriSpec,
originalCharset.get(), nsnull, ios);
if (!NS_FAILED(rv))
httpChan->SetOriginalURI(originalUri);
}
if (!docUriSpec.IsEmpty()) {
nsCOMPtr<nsIURI> docUri;
rv = NS_NewURI(getter_AddRefs(docUri), docUriSpec,
docCharset.get(), nsnull, ios);
if (!NS_FAILED(rv)) {
httpChan->SetDocumentURI(docUri);
}
}
if (!referrerSpec.IsEmpty()) {
nsCOMPtr<nsIURI> referrerUri;
rv = NS_NewURI(getter_AddRefs(referrerUri), referrerSpec,
referrerCharset.get(), nsnull, ios);
if (!NS_FAILED(rv)) {
httpChan->SetReferrerInternal(referrerUri);
}
}
if (originalUri)
httpChan->SetOriginalURI(originalUri);
if (docUri)
httpChan->SetDocumentURI(docUri);
if (referrerUri)
httpChan->SetReferrerInternal(referrerUri);
if (loadFlags != nsIRequest::LOAD_NORMAL)
httpChan->SetLoadFlags(loadFlags);

View File

@ -65,14 +65,10 @@ public:
virtual ~HttpChannelParent();
protected:
virtual bool RecvAsyncOpen(const nsCString& uriSpec,
const nsCString& charset,
const nsCString& originalUriSpec,
const nsCString& originalCharset,
const nsCString& docUriSpec,
const nsCString& docCharset,
const nsCString& referrerSpec,
const nsCString& referrerCharset,
virtual bool RecvAsyncOpen(const IPC::URI& uri,
const IPC::URI& originalUri,
const IPC::URI& docUri,
const IPC::URI& referrerUri,
const PRUint32& loadFlags,
const RequestHeaderTuples& requestHeaders,
const nsHttpAtom& requestMethod,

View File

@ -41,10 +41,12 @@
include protocol "PNecko.ipdl";
include "mozilla/net/PHttpChannelParams.h";
include "mozilla/net/NeckoMessageUtils.h";
using RequestHeaderTuples;
using nsHttpResponseHead;
using nsHttpAtom;
using IPC::URI;
namespace mozilla {
namespace net {
@ -57,18 +59,13 @@ protocol PHttpChannel
parent:
__delete__();
AsyncOpen(nsCString uriSpec,
nsCString charset,
AsyncOpen(URI uri,
// - TODO: unclear if any HTTP channel clients ever set
// originalURI != uri (about:credits?); also not clear if chrome
// channel would ever need to know. Can we get rid of next two
// args?
nsCString originalUriSpec,
nsCString originalCharset,
nsCString docUriSpec,
nsCString docCharset,
nsCString referrerSpec,
nsCString referrerCharset,
// channel would ever need to know. Can we get rid of next arg?
URI original,
URI doc,
URI referrer,
PRUint32 loadFlags,
RequestHeaderTuples requestHeaders,
nsHttpAtom requestMethod,