mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 17:24:29 +00:00
Bug 1350359 - Part 1: Set alternative data type from InterceptedChannel to InternalRequest. r=bkelly
This commit is contained in:
parent
2a280abe08
commit
7211e8c25c
@ -52,6 +52,8 @@ InternalRequest::GetRequestConstructorCopy(nsIGlobalObject* aGlobal, ErrorResult
|
||||
copy->mRedirectMode = mRedirectMode;
|
||||
copy->mCreatedByFetchEvent = mCreatedByFetchEvent;
|
||||
copy->mContentPolicyTypeOverridden = mContentPolicyTypeOverridden;
|
||||
|
||||
copy->mPreferredAlternativeDataType = mPreferredAlternativeDataType;
|
||||
return copy.forget();
|
||||
}
|
||||
|
||||
|
@ -552,6 +552,18 @@ public:
|
||||
return mPrincipalInfo;
|
||||
}
|
||||
|
||||
const nsCString&
|
||||
GetPreferredAlternativeDataType() const
|
||||
{
|
||||
return mPreferredAlternativeDataType;
|
||||
}
|
||||
|
||||
void
|
||||
SetPreferredAlternativeDataType(const nsACString& aDataType)
|
||||
{
|
||||
mPreferredAlternativeDataType = aDataType;
|
||||
}
|
||||
|
||||
private:
|
||||
// Does not copy mBodyStream. Use fallible Clone() for complete copy.
|
||||
explicit InternalRequest(const InternalRequest& aOther);
|
||||
@ -574,6 +586,8 @@ private:
|
||||
nsCOMPtr<nsIInputStream> mBodyStream;
|
||||
int64_t mBodyLength;
|
||||
|
||||
nsCString mPreferredAlternativeDataType;
|
||||
|
||||
nsContentPolicyType mContentPolicyType;
|
||||
|
||||
// Empty string: no-referrer
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "ServiceWorkerManager.h"
|
||||
#include "ServiceWorkerWindowClient.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsICacheInfoChannel.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsINamed.h"
|
||||
@ -1608,6 +1609,18 @@ private:
|
||||
// For Telemetry, note that this Request object was created by a Fetch event.
|
||||
internalReq->SetCreatedByFetchEvent();
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
nsresult rv = mInterceptedChannel->GetChannel(getter_AddRefs(channel));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
nsAutoCString alternativeDataType;
|
||||
nsCOMPtr<nsICacheInfoChannel> cic = do_QueryInterface(channel);
|
||||
if (cic &&
|
||||
NS_SUCCEEDED(cic->GetPreferredAlternativeDataType(alternativeDataType)) &&
|
||||
!alternativeDataType.IsEmpty()) {
|
||||
internalReq->SetPreferredAlternativeDataType(alternativeDataType);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(globalObj.GetAsSupports());
|
||||
if (NS_WARN_IF(!global)) {
|
||||
return false;
|
||||
|
@ -84,6 +84,13 @@ interface nsICacheInfoChannel : nsISupports
|
||||
*/
|
||||
void preferAlternativeDataType(in ACString type);
|
||||
|
||||
/**
|
||||
* Get the preferred alternative data type set by preferAlternativeDataType().
|
||||
* This attribute stands for the desired data type instead of the type of the
|
||||
* information retrieved from the network stack.
|
||||
*/
|
||||
readonly attribute ACString preferredAlternativeDataType;
|
||||
|
||||
/**
|
||||
* Holds the type of the alternative data representation that the channel
|
||||
* is returning.
|
||||
|
@ -2957,6 +2957,13 @@ HttpChannelChild::PreferAlternativeDataType(const nsACString & aType)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetPreferredAlternativeDataType(nsACString & aType)
|
||||
{
|
||||
aType = mPreferredCachedAltDataType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetAlternativeDataType(nsACString & aType)
|
||||
{
|
||||
|
@ -7885,6 +7885,13 @@ nsHttpChannel::PreferAlternativeDataType(const nsACString & aType)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetPreferredAlternativeDataType(nsACString & aType)
|
||||
{
|
||||
aType = mPreferredCachedAltDataType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetAlternativeDataType(nsACString & aType)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user