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 e386433d51
commit e5e453b354
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; 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. * "Copy" from a stream.
*/ */
@ -2612,6 +2625,8 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
{ {
NS_ENSURE_TRUE(mPrincipal, NS_ERROR_NOT_INITIALIZED); NS_ENSURE_TRUE(mPrincipal, NS_ERROR_NOT_INITIALIZED);
PopulateNetworkInterfaceId();
nsresult rv = CheckInnerWindowCorrectness(); nsresult rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

View File

@ -428,6 +428,11 @@ private:
bool IsDeniedCrossSiteRequest(); 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: public:
void Send(JSContext* /*aCx*/, ErrorResult& aRv) void Send(JSContext* /*aCx*/, ErrorResult& aRv)
{ {
@ -538,6 +543,16 @@ public:
return mChannel; 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 // We need a GetInterface callable from JS for chrome JS
void GetInterface(JSContext* aCx, nsIJSID* aIID, void GetInterface(JSContext* aCx, nsIJSID* aIID,
JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv); JS::MutableHandle<JS::Value> aRetval, ErrorResult& aRv);
@ -762,6 +777,10 @@ protected:
bool mIsSystem; bool mIsSystem;
bool mIsAnon; 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 * Close the XMLHttpRequest's channels and dispatch appropriate progress
* events. * events.

View File

@ -140,6 +140,11 @@ interface XMLHttpRequest : XMLHttpRequestEventTarget {
[ChromeOnly, Exposed=Window] [ChromeOnly, Exposed=Window]
readonly attribute MozChannel? channel; 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] [Throws, ChromeOnly, Exposed=Window]
any getInterface(IID iid); any getInterface(IID iid);