зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1487113 - nsICacheInfoChannel.alternativeDataInputStream as attribute, r=valentin
Depends on D25518 Differential Revision: https://phabricator.services.mozilla.com/D25519 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
99002c21c7
Коммит
a040cdb236
|
@ -131,11 +131,10 @@ interface nsICacheInfoChannel : nsISupports
|
|||
|
||||
/**
|
||||
* If preferAlternativeDataType() has been called passing deliverAltData
|
||||
* equal to false, this method will expose the alt-data inputStream if
|
||||
* aviable.
|
||||
* equal to false, this attribute will expose the alt-data inputStream if
|
||||
* avaiable.
|
||||
*/
|
||||
void getAltDataInputStream(in ACString type,
|
||||
in nsIInputStreamReceiver aReceiver);
|
||||
readonly attribute nsIInputStream alternativeDataInputStream;
|
||||
|
||||
/**
|
||||
* Sometimes when the channel is delivering alt-data, we may want to somehow
|
||||
|
|
|
@ -407,6 +407,7 @@ class StartRequestEvent : public NeckoTargetChannelEvent<HttpChannelChild> {
|
|||
const nsCString& altDataType, const int64_t& altDataLen,
|
||||
const bool& deliveringAltData,
|
||||
already_AddRefed<nsIInputStream> originalCacheInputStream,
|
||||
already_AddRefed<nsIInputStream> altDataInputStream,
|
||||
const bool& aApplyConversion, const ResourceTimingStruct& aTiming)
|
||||
: NeckoTargetChannelEvent<HttpChannelChild>(aChild),
|
||||
mChannelStatus(aChannelStatus),
|
||||
|
@ -428,6 +429,7 @@ class StartRequestEvent : public NeckoTargetChannelEvent<HttpChannelChild> {
|
|||
mAltDataLen(altDataLen),
|
||||
mDeliveringAltData(deliveringAltData),
|
||||
mOriginalCacheInputStream(originalCacheInputStream),
|
||||
mAltDataInputStream(altDataInputStream),
|
||||
mLoadInfoForwarder(loadInfoForwarder),
|
||||
mTiming(aTiming) {}
|
||||
|
||||
|
@ -439,7 +441,8 @@ class StartRequestEvent : public NeckoTargetChannelEvent<HttpChannelChild> {
|
|||
mCacheFetchCount, mCacheExpirationTime, mCachedCharset,
|
||||
mSecurityInfoSerialization, mSelfAddr, mPeerAddr, mCacheKey,
|
||||
mAltDataType, mAltDataLen, mDeliveringAltData,
|
||||
mOriginalCacheInputStream.forget(), mApplyConversion, mTiming);
|
||||
mOriginalCacheInputStream.forget(), mAltDataInputStream.forget(),
|
||||
mApplyConversion, mTiming);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -462,6 +465,7 @@ class StartRequestEvent : public NeckoTargetChannelEvent<HttpChannelChild> {
|
|||
int64_t mAltDataLen;
|
||||
bool mDeliveringAltData;
|
||||
nsCOMPtr<nsIInputStream> mOriginalCacheInputStream;
|
||||
nsCOMPtr<nsIInputStream> mAltDataInputStream;
|
||||
ParentLoadInfoForwarderArgs mLoadInfoForwarder;
|
||||
ResourceTimingStruct mTiming;
|
||||
};
|
||||
|
@ -478,7 +482,8 @@ mozilla::ipc::IPCResult HttpChannelChild::RecvOnStartRequest(
|
|||
const uint32_t& cacheKey, const nsCString& altDataType,
|
||||
const int64_t& altDataLen, const bool& deliveringAltData,
|
||||
const Maybe<IPCStream>& aOriginalCacheInputStream,
|
||||
const bool& aApplyConversion, const ResourceTimingStruct& aTiming) {
|
||||
const Maybe<IPCStream>& aAltDataInputStream, const bool& aApplyConversion,
|
||||
const ResourceTimingStruct& aTiming) {
|
||||
AUTO_PROFILER_LABEL("HttpChannelChild::RecvOnStartRequest", NETWORK);
|
||||
LOG(("HttpChannelChild::RecvOnStartRequest [this=%p]\n", this));
|
||||
// mFlushedForDiversion and mDivertingToParent should NEVER be set at this
|
||||
|
@ -495,13 +500,16 @@ mozilla::ipc::IPCResult HttpChannelChild::RecvOnStartRequest(
|
|||
nsCOMPtr<nsIInputStream> originalCacheInputStream =
|
||||
DeserializeIPCStream(aOriginalCacheInputStream);
|
||||
|
||||
nsCOMPtr<nsIInputStream> altDataInputStream =
|
||||
DeserializeIPCStream(aAltDataInputStream);
|
||||
|
||||
mEventQ->RunOrEnqueue(new StartRequestEvent(
|
||||
this, channelStatus, responseHead, useResponseHead, requestHeaders,
|
||||
loadInfoForwarder, isFromCache, cacheEntryAvailable, cacheEntryId,
|
||||
cacheFetchCount, cacheExpirationTime, cachedCharset,
|
||||
securityInfoSerialization, selfAddr, peerAddr, cacheKey, altDataType,
|
||||
altDataLen, deliveringAltData, originalCacheInputStream.forget(),
|
||||
aApplyConversion, aTiming));
|
||||
altDataInputStream.forget(), aApplyConversion, aTiming));
|
||||
|
||||
{
|
||||
// Child's mEventQ is to control the execution order of the IPC messages
|
||||
|
@ -536,6 +544,7 @@ void HttpChannelChild::OnStartRequest(
|
|||
const nsCString& altDataType, const int64_t& altDataLen,
|
||||
const bool& deliveringAltData,
|
||||
already_AddRefed<nsIInputStream> originalCacheInputStream,
|
||||
already_AddRefed<nsIInputStream> altDataInputStream,
|
||||
const bool& aApplyConversion, const ResourceTimingStruct& aTiming) {
|
||||
LOG(("HttpChannelChild::OnStartRequest [this=%p]\n", this));
|
||||
|
||||
|
@ -549,6 +558,7 @@ void HttpChannelChild::OnStartRequest(
|
|||
"mDivertingToParent should be unset before OnStartRequest!");
|
||||
|
||||
mOriginalCacheInputStream = originalCacheInputStream;
|
||||
mAltDataInputStream = altDataInputStream;
|
||||
|
||||
// If this channel was aborted by ActorDestroy, then there may be other
|
||||
// OnStartRequest/OnStopRequest/OnDataAvailable IPC messages that need to
|
||||
|
@ -3146,34 +3156,15 @@ HttpChannelChild::GetOriginalInputStream(nsIInputStream** aInputStream) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetAltDataInputStream(const nsACString& aType,
|
||||
nsIInputStreamReceiver* aReceiver) {
|
||||
if (aReceiver == nullptr) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
HttpChannelChild::GetAlternativeDataInputStream(nsIInputStream** aInputStream) {
|
||||
NS_ENSURE_ARG_POINTER(aInputStream);
|
||||
|
||||
if (!mIPCOpen) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
mAltDataInputStreamReceiver = aReceiver;
|
||||
Unused << SendOpenAltDataCacheInputStream(nsCString(aType));
|
||||
nsCOMPtr<nsIInputStream> is = mAltDataInputStream;
|
||||
is.forget(aInputStream);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult HttpChannelChild::RecvAltDataCacheInputStreamAvailable(
|
||||
const Maybe<IPCStream>& aStream) {
|
||||
nsCOMPtr<nsIInputStream> stream = DeserializeIPCStream(aStream);
|
||||
nsCOMPtr<nsIInputStreamReceiver> receiver;
|
||||
receiver.swap(mAltDataInputStreamReceiver);
|
||||
if (receiver) {
|
||||
receiver->OnInputStreamReady(stream);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpChannelChild::nsIResumableChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -146,7 +146,7 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||
const uint32_t& cacheKey, const nsCString& altDataType,
|
||||
const int64_t& altDataLen, const bool& deliveringAltData,
|
||||
const Maybe<IPCStream>& originalCacheInputStream,
|
||||
const bool& aApplyConversion,
|
||||
const Maybe<IPCStream>& altDataInputStream, const bool& aApplyConversion,
|
||||
const ResourceTimingStruct& aTiming) override;
|
||||
mozilla::ipc::IPCResult RecvFailedAsyncOpen(const nsresult& status) override;
|
||||
mozilla::ipc::IPCResult RecvRedirect1Begin(
|
||||
|
@ -177,9 +177,6 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||
|
||||
mozilla::ipc::IPCResult RecvCancelRedirected() override;
|
||||
|
||||
mozilla::ipc::IPCResult RecvAltDataCacheInputStreamAvailable(
|
||||
const Maybe<IPCStream>& aStream) override;
|
||||
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
||||
|
||||
virtual void DoNotifyListenerCleanup() override;
|
||||
|
@ -342,7 +339,7 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||
RefPtr<ChannelEventQueue> mEventQ;
|
||||
|
||||
nsCOMPtr<nsIInputStream> mOriginalCacheInputStream;
|
||||
nsCOMPtr<nsIInputStreamReceiver> mAltDataInputStreamReceiver;
|
||||
nsCOMPtr<nsIInputStream> mAltDataInputStream;
|
||||
|
||||
// Used to ensure atomicity of mBgChild and mBgInitFailCallback
|
||||
Mutex mBgChildMutex;
|
||||
|
@ -469,6 +466,7 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||
const nsCString& altDataType, const int64_t& altDataLen,
|
||||
const bool& deliveringAltData,
|
||||
already_AddRefed<nsIInputStream> originalCacheInputStream,
|
||||
already_AddRefed<nsIInputStream> altDataInputStream,
|
||||
const bool& aApplyConversion, const ResourceTimingStruct& aTiming);
|
||||
void MaybeDivertOnData(const nsCString& data, const uint64_t& offset,
|
||||
const uint32_t& count);
|
||||
|
|
|
@ -1449,13 +1449,29 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
|
|||
GetTimingAttributes(mChannel, timing);
|
||||
|
||||
AutoIPCStream originalCacheInputStream(true /* delay start */);
|
||||
AutoIPCStream altDataInputStream(true /* delay start */);
|
||||
|
||||
if (mCacheEntry) {
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsresult rv = mCacheEntry->OpenInputStream(0, getter_AddRefs(inputStream));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PContentParent* pcp = Manager()->Manager();
|
||||
Unused << originalCacheInputStream.Serialize(
|
||||
inputStream, static_cast<ContentParent*>(pcp));
|
||||
PContentParent* pcp = Manager()->Manager();
|
||||
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsresult rv =
|
||||
mCacheEntry->OpenInputStream(0, getter_AddRefs(inputStream));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
Unused << originalCacheInputStream.Serialize(
|
||||
inputStream, static_cast<ContentParent*>(pcp));
|
||||
}
|
||||
}
|
||||
|
||||
if (!altDataType.IsEmpty()) {
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsresult rv = mCacheEntry->OpenAlternativeInputStream(
|
||||
altDataType, getter_AddRefs(inputStream));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
Unused << altDataInputStream.Serialize(
|
||||
inputStream, static_cast<ContentParent*>(pcp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1468,8 +1484,8 @@ HttpChannelParent::OnStartRequest(nsIRequest* aRequest) {
|
|||
cacheEntryId, fetchCount, expirationTime, cachedCharset,
|
||||
secInfoSerialization, chan->GetSelfAddr(), chan->GetPeerAddr(),
|
||||
redirectCount, cacheKey, altDataType, altDataLen, deliveringAltData,
|
||||
originalCacheInputStream.TakeOptionalValue(), applyConversion,
|
||||
timing)) {
|
||||
originalCacheInputStream.TakeOptionalValue(),
|
||||
altDataInputStream.TakeOptionalValue(), applyConversion, timing)) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
requestHead->Exit();
|
||||
|
@ -1689,28 +1705,6 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvBytesRead(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult HttpChannelParent::RecvOpenAltDataCacheInputStream(
|
||||
const nsCString& aType) {
|
||||
if (mIPCClosed) {
|
||||
return IPC_OK();
|
||||
}
|
||||
AutoIPCStream autoStream;
|
||||
if (mCacheEntry) {
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsresult rv = mCacheEntry->OpenAlternativeInputStream(
|
||||
aType, getter_AddRefs(inputStream));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PContentParent* pcp = Manager()->Manager();
|
||||
Unused << autoStream.Serialize(inputStream,
|
||||
static_cast<ContentParent*>(pcp));
|
||||
}
|
||||
}
|
||||
|
||||
Unused << SendAltDataCacheInputStreamAvailable(
|
||||
autoStream.TakeOptionalValue());
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpChannelParent::nsIProgressEventSink
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -208,8 +208,6 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
|
|||
const URIParams& uri,
|
||||
const mozilla::ipc::PrincipalInfo& requestingPrincipal) override;
|
||||
virtual mozilla::ipc::IPCResult RecvBytesRead(const int32_t& aCount) override;
|
||||
virtual mozilla::ipc::IPCResult RecvOpenAltDataCacheInputStream(
|
||||
const nsCString& aType) override;
|
||||
virtual void ActorDestroy(ActorDestroyReason why) override;
|
||||
|
||||
// Supporting function for ADivertableParentChannel.
|
||||
|
|
|
@ -1282,10 +1282,10 @@ InterceptedHttpChannel::GetOriginalInputStream(nsIInputStream** aStream) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InterceptedHttpChannel::GetAltDataInputStream(
|
||||
const nsACString& aType, nsIInputStreamReceiver* aReceiver) {
|
||||
InterceptedHttpChannel::GetAlternativeDataInputStream(
|
||||
nsIInputStream** aInputStream) {
|
||||
if (mSynthesizedCacheInfo) {
|
||||
return mSynthesizedCacheInfo->GetAltDataInputStream(aType, aReceiver);
|
||||
return mSynthesizedCacheInfo->GetAlternativeDataInputStream(aInputStream);
|
||||
}
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
|
|
@ -93,9 +93,6 @@ parent:
|
|||
// sure not to send any more messages after that.
|
||||
async DeletingChannel();
|
||||
|
||||
// Called to get the input stream when altData is available.
|
||||
async OpenAltDataCacheInputStream(nsCString aType);
|
||||
|
||||
// Tell the parent the amount bytes read by child for the e10s back pressure
|
||||
// flow control
|
||||
async BytesRead(int32_t count);
|
||||
|
@ -123,6 +120,7 @@ child:
|
|||
int64_t altDataLength,
|
||||
bool deliveringAltData,
|
||||
IPCStream? originalCacheInputStream,
|
||||
IPCStream? altDataInputStream,
|
||||
bool applyConversion,
|
||||
ResourceTimingStruct timing);
|
||||
|
||||
|
@ -180,8 +178,6 @@ child:
|
|||
// See ADivertableParentChannel::CancelDiversion
|
||||
async CancelDiversion();
|
||||
|
||||
async AltDataCacheInputStreamAvailable(IPCStream? stream);
|
||||
|
||||
both:
|
||||
// After receiving this message, the parent also calls
|
||||
// SendFinishInterceptedRedirect, and makes sure not to send any more messages
|
||||
|
|
|
@ -8568,22 +8568,22 @@ nsHttpChannel::GetOriginalInputStream(nsIInputStream **aInputStream) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetAltDataInputStream(const nsACString &aType,
|
||||
nsIInputStreamReceiver *aReceiver) {
|
||||
if (aReceiver == nullptr) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
nsHttpChannel::GetAlternativeDataInputStream(nsIInputStream **aInputStream) {
|
||||
NS_ENSURE_ARG_POINTER(aInputStream);
|
||||
|
||||
*aInputStream = nullptr;
|
||||
|
||||
if (!mAfterOnStartRequestBegun) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
|
||||
nsCOMPtr<nsICacheEntry> cacheEntry =
|
||||
mCacheEntry ? mCacheEntry : mAltDataCacheEntry;
|
||||
if (cacheEntry) {
|
||||
nsresult rv = cacheEntry->OpenAlternativeInputStream(
|
||||
aType, getter_AddRefs(inputStream));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!mAvailableCachedAltDataType.IsEmpty() && cacheEntry) {
|
||||
Unused << cacheEntry->OpenAlternativeInputStream(
|
||||
mAvailableCachedAltDataType, aInputStream);
|
||||
}
|
||||
|
||||
aReceiver->OnInputStreamReady(inputStream);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -148,10 +148,6 @@ var originalListener = {
|
|||
|
||||
function testAltDataStream(cc)
|
||||
{
|
||||
cc.getAltDataInputStream(altContentType, {
|
||||
onInputStreamReady: function(aInputStream) {
|
||||
Assert.ok(!!aInputStream);
|
||||
httpServer.stop(do_test_finished);
|
||||
}
|
||||
});
|
||||
Assert.ok(!!cc.alternativeDataInputStream);
|
||||
httpServer.stop(do_test_finished);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче