mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 541174 - e10s HTTP: Improve how URIs are serialized (part3). r=dwitte
This commit is contained in:
parent
a0cc531b07
commit
f432757fa9
@ -78,35 +78,6 @@ CookieServiceChild::~CookieServiceChild()
|
||||
gCookieService = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
CookieServiceChild::SerializeURIs(nsIURI *aHostURI,
|
||||
nsIChannel *aChannel,
|
||||
nsCString &aHostSpec,
|
||||
nsCString &aHostCharset,
|
||||
nsCString &aOriginatingSpec,
|
||||
nsCString &aOriginatingCharset)
|
||||
{
|
||||
// Serialize the host URI.
|
||||
// TODO: The cookieservice deals exclusively with ASCII hosts, but not paths.
|
||||
// We should fix that, and then we can just serialize the spec as ASCII here.
|
||||
aHostURI->GetSpec(aHostSpec);
|
||||
aHostURI->GetOriginCharset(aHostCharset);
|
||||
|
||||
// Determine and serialize the originating URI. Failure is acceptable.
|
||||
if (!mPermissionService) {
|
||||
NS_WARNING("nsICookiePermission unavailable! Cookie may be rejected");
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> originatingURI;
|
||||
mPermissionService->GetOriginatingURI(aChannel,
|
||||
getter_AddRefs(originatingURI));
|
||||
if (originatingURI) {
|
||||
originatingURI->GetSpec(aOriginatingSpec);
|
||||
originatingURI->GetOriginCharset(aOriginatingSpec);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
||||
nsIChannel *aChannel,
|
||||
@ -118,14 +89,17 @@ CookieServiceChild::GetCookieStringInternal(nsIURI *aHostURI,
|
||||
|
||||
*aCookieString = NULL;
|
||||
|
||||
nsCAutoString hostSpec, hostCharset, originatingSpec, originatingCharset;
|
||||
SerializeURIs(aHostURI, aChannel, hostSpec, hostCharset,
|
||||
originatingSpec, originatingCharset);
|
||||
// Determine the originating URI. Failure is acceptable.
|
||||
nsCOMPtr<nsIURI> originatingURI;
|
||||
if (!mPermissionService) {
|
||||
NS_WARNING("nsICookiePermission unavailable! Cookie may be rejected");
|
||||
mPermissionService->GetOriginatingURI(aChannel,
|
||||
getter_AddRefs(originatingURI));
|
||||
}
|
||||
|
||||
// Synchronously call the parent.
|
||||
nsCAutoString result;
|
||||
SendGetCookieString(hostSpec, hostCharset,
|
||||
originatingSpec, originatingCharset,
|
||||
SendGetCookieString(IPC::URI(aHostURI), IPC::URI(originatingURI),
|
||||
aFromHttp, &result);
|
||||
if (!result.IsEmpty())
|
||||
*aCookieString = ToNewCString(result);
|
||||
@ -143,9 +117,13 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
NS_ENSURE_ARG(aHostURI);
|
||||
NS_ENSURE_ARG_POINTER(aCookieString);
|
||||
|
||||
nsCAutoString hostSpec, hostCharset, originatingSpec, originatingCharset;
|
||||
SerializeURIs(aHostURI, aChannel, hostSpec, hostCharset,
|
||||
originatingSpec, originatingCharset);
|
||||
// Determine the originating URI. Failure is acceptable.
|
||||
nsCOMPtr<nsIURI> originatingURI;
|
||||
if (!mPermissionService) {
|
||||
NS_WARNING("nsICookiePermission unavailable! Cookie may be rejected");
|
||||
mPermissionService->GetOriginatingURI(aChannel,
|
||||
getter_AddRefs(originatingURI));
|
||||
}
|
||||
|
||||
nsDependentCString cookieString(aCookieString);
|
||||
nsDependentCString serverTime;
|
||||
@ -153,8 +131,7 @@ CookieServiceChild::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
serverTime.Rebind(aServerTime);
|
||||
|
||||
// Synchronously call the parent.
|
||||
SendSetCookieString(hostSpec, hostCharset,
|
||||
originatingSpec, originatingCharset,
|
||||
SendSetCookieString(IPC::URI(aHostURI), IPC::URI(originatingURI),
|
||||
cookieString, serverTime, aFromHttp);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -53,9 +53,6 @@ CookieServiceParent::CookieServiceParent()
|
||||
mCookieService =
|
||||
already_AddRefed<nsCookieService>(nsCookieService::GetSingleton());
|
||||
NS_ASSERTION(mCookieService, "couldn't get nsICookieService");
|
||||
|
||||
mIOService = do_GetService(NS_IOSERVICE_CONTRACTID);
|
||||
NS_ASSERTION(mIOService, "couldn't get nsIIOService");
|
||||
}
|
||||
|
||||
CookieServiceParent::~CookieServiceParent()
|
||||
@ -63,10 +60,8 @@ CookieServiceParent::~CookieServiceParent()
|
||||
}
|
||||
|
||||
bool
|
||||
CookieServiceParent::RecvGetCookieString(const nsCString& aHostSpec,
|
||||
const nsCString& aHostCharset,
|
||||
const nsCString& aOriginatingSpec,
|
||||
const nsCString& aOriginatingCharset,
|
||||
CookieServiceParent::RecvGetCookieString(const IPC::URI& aHost,
|
||||
const IPC::URI& aOriginating,
|
||||
const bool& aFromHttp,
|
||||
nsCString* aResult)
|
||||
{
|
||||
@ -75,13 +70,8 @@ CookieServiceParent::RecvGetCookieString(const nsCString& aHostSpec,
|
||||
|
||||
// Deserialize URIs. Having a host URI is mandatory and should always be
|
||||
// provided by the child; thus we consider failure fatal.
|
||||
nsCOMPtr<nsIURI> hostURI, originatingURI;
|
||||
NS_NewURI(getter_AddRefs(hostURI),
|
||||
aHostSpec, aHostCharset.get(),
|
||||
nsnull, mIOService);
|
||||
NS_NewURI(getter_AddRefs(originatingURI),
|
||||
aOriginatingSpec, aOriginatingCharset.get(),
|
||||
nsnull, mIOService);
|
||||
nsCOMPtr<nsIURI> hostURI = aHost;
|
||||
nsCOMPtr<nsIURI> originatingURI = aOriginating;
|
||||
if (!hostURI)
|
||||
return false;
|
||||
|
||||
@ -91,10 +81,8 @@ CookieServiceParent::RecvGetCookieString(const nsCString& aHostSpec,
|
||||
}
|
||||
|
||||
bool
|
||||
CookieServiceParent::RecvSetCookieString(const nsCString& aHostSpec,
|
||||
const nsCString& aHostCharset,
|
||||
const nsCString& aOriginatingSpec,
|
||||
const nsCString& aOriginatingCharset,
|
||||
CookieServiceParent::RecvSetCookieString(const IPC::URI& aHost,
|
||||
const IPC::URI& aOriginating,
|
||||
const nsCString& aCookieString,
|
||||
const nsCString& aServerTime,
|
||||
const bool& aFromHttp)
|
||||
@ -104,13 +92,8 @@ CookieServiceParent::RecvSetCookieString(const nsCString& aHostSpec,
|
||||
|
||||
// Deserialize URIs. Having a host URI is mandatory and should always be
|
||||
// provided by the child; thus we consider failure fatal.
|
||||
nsCOMPtr<nsIURI> hostURI, originatingURI;
|
||||
NS_NewURI(getter_AddRefs(hostURI),
|
||||
aHostSpec, aHostCharset.get(),
|
||||
nsnull, mIOService);
|
||||
NS_NewURI(getter_AddRefs(originatingURI),
|
||||
aOriginatingSpec, aOriginatingCharset.get(),
|
||||
nsnull, mIOService);
|
||||
nsCOMPtr<nsIURI> hostURI = aHost;
|
||||
nsCOMPtr<nsIURI> originatingURI = aOriginating;
|
||||
if (!hostURI)
|
||||
return false;
|
||||
|
||||
|
@ -54,23 +54,18 @@ public:
|
||||
virtual ~CookieServiceParent();
|
||||
|
||||
protected:
|
||||
virtual bool RecvGetCookieString(const nsCString& aHostSpec,
|
||||
const nsCString& aHostCharset,
|
||||
const nsCString& aOriginatingSpec,
|
||||
const nsCString& aOriginatingCharset,
|
||||
virtual bool RecvGetCookieString(const IPC::URI& aHost,
|
||||
const IPC::URI& aOriginating,
|
||||
const bool& aFromHttp,
|
||||
nsCString* aResult);
|
||||
|
||||
virtual bool RecvSetCookieString(const nsCString& aHostSpec,
|
||||
const nsCString& aHostCharset,
|
||||
const nsCString& aOriginatingSpec,
|
||||
const nsCString& aOriginatingCharset,
|
||||
virtual bool RecvSetCookieString(const IPC::URI& aHost,
|
||||
const IPC::URI& aOriginating,
|
||||
const nsCString& aCookieString,
|
||||
const nsCString& aServerTime,
|
||||
const bool& aFromHttp);
|
||||
|
||||
nsRefPtr<nsCookieService> mCookieService;
|
||||
nsCOMPtr<nsIIOService> mIOService;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -40,6 +40,10 @@
|
||||
|
||||
include protocol "PNecko.ipdl";
|
||||
|
||||
include "mozilla/net/NeckoMessageUtils.h";
|
||||
|
||||
using IPC::URI;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
@ -48,17 +52,13 @@ sync protocol PCookieService
|
||||
manager PNecko;
|
||||
|
||||
parent:
|
||||
sync GetCookieString(nsCString hostSpec,
|
||||
nsCString hostCharset,
|
||||
nsCString originatingSpec,
|
||||
nsCString originatingCharset,
|
||||
sync GetCookieString(URI host,
|
||||
URI originating,
|
||||
bool fromHttp)
|
||||
returns (nsCString result);
|
||||
|
||||
SetCookieString(nsCString hostSpec,
|
||||
nsCString hostCharset,
|
||||
nsCString originatingSpec,
|
||||
nsCString originatingCharset,
|
||||
SetCookieString(URI host,
|
||||
URI originating,
|
||||
nsCString cookieString,
|
||||
nsCString serverTime,
|
||||
bool fromHttp);
|
||||
|
Loading…
Reference in New Issue
Block a user