Bug 1053650 - Part 1: Add attribute 'networkInterfaceId' to XMLHttpRequest. r=bz

This commit is contained in:
Henry Chang 2015-03-03 09:09:07 +08:00
parent 34eadc3b32
commit de2b2e4d23
3 changed files with 39 additions and 0 deletions

View File

@ -1795,6 +1795,19 @@ nsXMLHttpRequest::Open(const nsACString& inMethod, const nsACString& url,
return rv;
}
void
nsXMLHttpRequest::PopulateNetworkInterfaceId()
{
if (mNetworkInterfaceId.IsEmpty()) {
return;
}
nsCOMPtr<nsIHttpChannelInternal> channel(do_QueryInterface(mChannel));
if (!channel) {
return;
}
channel->SetNetworkInterfaceId(mNetworkInterfaceId);
}
/*
* "Copy" from a stream.
*/
@ -2612,6 +2625,8 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
{
NS_ENSURE_TRUE(mPrincipal, NS_ERROR_NOT_INITIALIZED);
PopulateNetworkInterfaceId();
nsresult rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -428,6 +428,11 @@ private:
bool IsDeniedCrossSiteRequest();
// Tell our channel what network interface ID we were told to use.
// If it's an HTTP channel and we were told to use a non-default
// interface ID.
void PopulateNetworkInterfaceId();
public:
void Send(JSContext* /*aCx*/, ErrorResult& aRv)
{
@ -538,6 +543,16 @@ public:
return mChannel;
}
void GetNetworkInterfaceId(nsACString& aId) const
{
aId = mNetworkInterfaceId;
}
void SetNetworkInterfaceId(const nsACString& aId)
{
mNetworkInterfaceId = aId;
}
// We need a GetInterface callable from JS for chrome JS
void GetInterface(JSContext* aCx, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv);
@ -762,6 +777,10 @@ protected:
bool mIsSystem;
bool mIsAnon;
// A platform-specific identifer to represent the network interface
// that this request is associated with.
nsCString mNetworkInterfaceId;
/**
* Close the XMLHttpRequest's channels and dispatch appropriate progress
* events.

View File

@ -140,6 +140,11 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
[ChromeOnly, Exposed=Window]
readonly attribute MozChannel? channel;
// A platform-specific identifer to represent the network interface
// which the HTTP request would occur on.
[ChromeOnly, Exposed=Window]
attribute ByteString? networkInterfaceId;
[Throws, ChromeOnly, Exposed=Window]
any getInterface(IID iid);