зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1600254
- P8: Make nsIInputChannelThrottleQueue work with socket process r=dragana
The only information that devtools needs is the amount of how many bytes readed, so this patch introduces PInputChannelThrottleQueue ipdl for carrying on this information. Differential Revision: https://phabricator.services.mozilla.com/D56710 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
98739d4a39
Коммит
4bc096f818
|
@ -15,6 +15,7 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class PSHEntryOrSharedID;
|
||||
class SHistoryParent;
|
||||
class SHEntryParent;
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ThrottleQueue.h"
|
||||
#include "mozilla/net/InputChannelThrottleQueueParent.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsIAsyncInputStream.h"
|
||||
#include "nsIOService.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
|
@ -214,6 +216,20 @@ void ThrottleInputStream::AllowInput() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIInputChannelThrottleQueue> ThrottleQueue::Create() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
nsCOMPtr<nsIInputChannelThrottleQueue> tq;
|
||||
if (gIOService->UseSocketProcess()) {
|
||||
tq = new InputChannelThrottleQueueParent();
|
||||
} else {
|
||||
tq = new ThrottleQueue();
|
||||
}
|
||||
|
||||
return tq.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ThrottleQueue, nsIInputChannelThrottleQueue, nsITimerCallback,
|
||||
nsINamed)
|
||||
|
||||
|
@ -364,5 +380,21 @@ void ThrottleQueue::DequeueStream(ThrottleInputStream* aStream) {
|
|||
mAsyncEvents.RemoveElement(aStream);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ThrottleQueue::GetMeanBytesPerSecond(uint32_t* aMeanBytesPerSecond) {
|
||||
NS_ENSURE_ARG(aMeanBytesPerSecond);
|
||||
|
||||
*aMeanBytesPerSecond = mMeanBytesPerSecond;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ThrottleQueue::GetMaxBytesPerSecond(uint32_t* aMaxBytesPerSecond) {
|
||||
NS_ENSURE_ARG(aMaxBytesPerSecond);
|
||||
|
||||
*aMaxBytesPerSecond = mMaxBytesPerSecond;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -26,11 +26,11 @@ class ThrottleInputStream;
|
|||
* may be a bit choppy.
|
||||
*/
|
||||
|
||||
class ThrottleQueue final : public nsIInputChannelThrottleQueue,
|
||||
public nsITimerCallback,
|
||||
public nsINamed {
|
||||
class ThrottleQueue : public nsIInputChannelThrottleQueue,
|
||||
public nsITimerCallback,
|
||||
public nsINamed {
|
||||
public:
|
||||
ThrottleQueue();
|
||||
static already_AddRefed<nsIInputChannelThrottleQueue> Create();
|
||||
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIINPUTCHANNELTHROTTLEQUEUE
|
||||
|
@ -40,8 +40,9 @@ class ThrottleQueue final : public nsIInputChannelThrottleQueue,
|
|||
void QueueStream(ThrottleInputStream* aStream);
|
||||
void DequeueStream(ThrottleInputStream* aStream);
|
||||
|
||||
private:
|
||||
~ThrottleQueue();
|
||||
protected:
|
||||
ThrottleQueue();
|
||||
virtual ~ThrottleQueue();
|
||||
|
||||
struct ThrottleEntry {
|
||||
TimeStamp mTime;
|
||||
|
|
|
@ -179,6 +179,7 @@ EXPORTS.mozilla.net += [
|
|||
'SimpleChannelParent.h',
|
||||
'SSLTokensCache.h',
|
||||
'TCPFastOpen.h',
|
||||
'ThrottleQueue.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
|
|
|
@ -27,6 +27,13 @@ interface nsIInputChannelThrottleQueue : nsISupports
|
|||
*/
|
||||
void init(in unsigned long aMeanBytesPerSecond, in unsigned long aMaxBytesPerSecond);
|
||||
|
||||
/**
|
||||
* Internal use only. Get the values set by init method.
|
||||
*/
|
||||
[noscript] readonly attribute unsigned long meanBytesPerSecond;
|
||||
[noscript] readonly attribute unsigned long maxBytesPerSecond;
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of bytes that are available to the caller in
|
||||
* this time slice.
|
||||
|
|
|
@ -415,7 +415,8 @@ Classes = [
|
|||
{
|
||||
'cid': '{4c39159c-cd90-4dd3-97a7-06af5e6d84c4}',
|
||||
'contract_ids': ['@mozilla.org/network/throttlequeue;1'],
|
||||
'type': 'mozilla::net::ThrottleQueue',
|
||||
'type': 'nsIInputChannelThrottleQueue',
|
||||
'constructor': 'mozilla::net::ThrottleQueue::Create',
|
||||
'headers': ['/netwerk/base/ThrottleQueue.h'],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set ts=4 sw=4 sts=4 et cin: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "InputChannelThrottleQueueChild.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(InputChannelThrottleQueueChild, ThrottleQueue)
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueChild::RecordRead(uint32_t aBytesRead) {
|
||||
ThrottleQueue::RecordRead(aBytesRead);
|
||||
|
||||
RefPtr<InputChannelThrottleQueueChild> self = this;
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(
|
||||
"InputChannelThrottleQueueChild::RecordRead", [self, aBytesRead]() {
|
||||
if (self->CanSend()) {
|
||||
Unused << self->SendRecordRead(aBytesRead);
|
||||
}
|
||||
}));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,33 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef InputChannelThrottleQueueChild_h__
|
||||
#define InputChannelThrottleQueueChild_h__
|
||||
|
||||
#include "mozilla/net/PInputChannelThrottleQueueChild.h"
|
||||
#include "mozilla/net/ThrottleQueue.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
class InputChannelThrottleQueueChild final
|
||||
: public PInputChannelThrottleQueueChild,
|
||||
public ThrottleQueue {
|
||||
public:
|
||||
friend class PInputChannelThrottleQueueChild;
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
explicit InputChannelThrottleQueueChild() = default;
|
||||
NS_IMETHOD RecordRead(uint32_t aBytesRead) override;
|
||||
|
||||
private:
|
||||
virtual ~InputChannelThrottleQueueChild() = default;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // InputChannelThrottleQueueChild_h__
|
|
@ -0,0 +1,128 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set ts=4 sw=4 sts=4 et cin: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "InputChannelThrottleQueueParent.h"
|
||||
#include "mozilla/net/SocketProcessParent.h"
|
||||
#include "nsIOService.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
NS_IMPL_ADDREF(InputChannelThrottleQueueParent)
|
||||
NS_INTERFACE_MAP_BEGIN(InputChannelThrottleQueueParent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIInputChannelThrottleQueue)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY_CONCRETE(InputChannelThrottleQueueParent)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMETHODIMP_(MozExternalRefCountType)
|
||||
InputChannelThrottleQueueParent::Release(void) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release");
|
||||
|
||||
if (!mRefCnt.isThreadSafe) {
|
||||
NS_ASSERT_OWNINGTHREAD(InputChannelThrottleQueueParent);
|
||||
}
|
||||
|
||||
nsrefcnt count = --mRefCnt;
|
||||
NS_LOG_RELEASE(this, count, "InputChannelThrottleQueueParent");
|
||||
|
||||
if (count == 0) {
|
||||
if (!mRefCnt.isThreadSafe) {
|
||||
NS_ASSERT_OWNINGTHREAD(InputChannelThrottleQueueParent);
|
||||
}
|
||||
|
||||
mRefCnt = 1; /* stabilize */
|
||||
delete (this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// When ref count goes down to 1 (held internally by IPDL), it means that
|
||||
// we are done with this ThrottleQueue. We should send a delete message
|
||||
// to delete the InputChannelThrottleQueueChild in socket process.
|
||||
if (count == 1 && CanSend()) {
|
||||
mozilla::Unused << Send__delete__(this);
|
||||
return 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
InputChannelThrottleQueueParent::InputChannelThrottleQueueParent()
|
||||
: mBytesProcessed(0), mMeanBytesPerSecond(0), mMaxBytesPerSecond(0) {}
|
||||
|
||||
mozilla::ipc::IPCResult InputChannelThrottleQueueParent::RecvRecordRead(
|
||||
const uint32_t& aBytesRead) {
|
||||
mBytesProcessed += aBytesRead;
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueParent::RecordRead(uint32_t aBytesRead) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueParent::Available(uint32_t aRemaining,
|
||||
uint32_t* aAvailable) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueParent::Init(uint32_t aMeanBytesPerSecond,
|
||||
uint32_t aMaxBytesPerSecond) {
|
||||
// Can be called on any thread.
|
||||
if (aMeanBytesPerSecond == 0 || aMaxBytesPerSecond == 0 ||
|
||||
aMaxBytesPerSecond < aMeanBytesPerSecond) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
mMeanBytesPerSecond = aMeanBytesPerSecond;
|
||||
mMaxBytesPerSecond = aMaxBytesPerSecond;
|
||||
|
||||
RefPtr<InputChannelThrottleQueueParent> self = this;
|
||||
gIOService->CallOrWaitForSocketProcess(
|
||||
[self, meanBytesPerSecond(mMeanBytesPerSecond),
|
||||
maxBytesPerSecond(mMaxBytesPerSecond)] {
|
||||
Unused << SocketProcessParent::GetSingleton()
|
||||
->SendPInputChannelThrottleQueueConstructor(
|
||||
self, meanBytesPerSecond, maxBytesPerSecond);
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueParent::BytesProcessed(uint64_t* aResult) {
|
||||
*aResult = mBytesProcessed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueParent::WrapStream(nsIInputStream* aInputStream,
|
||||
nsIAsyncInputStream** aResult) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueParent::GetMeanBytesPerSecond(
|
||||
uint32_t* aMeanBytesPerSecond) {
|
||||
NS_ENSURE_ARG(aMeanBytesPerSecond);
|
||||
|
||||
*aMeanBytesPerSecond = mMeanBytesPerSecond;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
InputChannelThrottleQueueParent::GetMaxBytesPerSecond(
|
||||
uint32_t* aMaxBytesPerSecond) {
|
||||
NS_ENSURE_ARG(aMaxBytesPerSecond);
|
||||
|
||||
*aMaxBytesPerSecond = mMaxBytesPerSecond;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef InputChannelThrottleQueueParent_h__
|
||||
#define InputChannelThrottleQueueParent_h__
|
||||
|
||||
#include "nsISupportsImpl.h"
|
||||
#include "nsIThrottledInputChannel.h"
|
||||
#include "mozilla/net/PInputChannelThrottleQueueParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
#define INPUT_CHANNEL_THROTTLE_QUEUE_PARENT_IID \
|
||||
{ \
|
||||
0x4f151655, 0x70b3, 0x4350, { \
|
||||
0x9b, 0xd9, 0xe3, 0x2b, 0xe5, 0xeb, 0xb2, 0x9e \
|
||||
} \
|
||||
}
|
||||
|
||||
class InputChannelThrottleQueueParent final
|
||||
: public PInputChannelThrottleQueueParent,
|
||||
public nsIInputChannelThrottleQueue {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINPUTCHANNELTHROTTLEQUEUE
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(INPUT_CHANNEL_THROTTLE_QUEUE_PARENT_IID)
|
||||
|
||||
friend class PInputChannelThrottleQueueParent;
|
||||
|
||||
explicit InputChannelThrottleQueueParent();
|
||||
mozilla::ipc::IPCResult RecvRecordRead(const uint32_t& aBytesRead);
|
||||
void ActorDestroy(ActorDestroyReason aWhy) override {}
|
||||
|
||||
private:
|
||||
virtual ~InputChannelThrottleQueueParent() = default;
|
||||
|
||||
uint64_t mBytesProcessed;
|
||||
uint32_t mMeanBytesPerSecond;
|
||||
uint32_t mMaxBytesPerSecond;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(InputChannelThrottleQueueParent,
|
||||
INPUT_CHANNEL_THROTTLE_QUEUE_PARENT_IID)
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // InputChannelThrottleQueueParent_h__
|
|
@ -0,0 +1,25 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
include protocol PSocketProcess;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
refcounted protocol PInputChannelThrottleQueue
|
||||
{
|
||||
manager PSocketProcess;
|
||||
|
||||
parent:
|
||||
async RecordRead(uint32_t aBytesRead);
|
||||
|
||||
child:
|
||||
async __delete__();
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
|
@ -12,6 +12,7 @@ include protocol PHttpConnectionMgr;
|
|||
include protocol PFileDescriptorSet;
|
||||
include protocol PChildToParentStream;
|
||||
include protocol PParentToChildStream;
|
||||
include protocol PInputChannelThrottleQueue;
|
||||
|
||||
include MemoryReportTypes;
|
||||
include NeckoChannelParams;
|
||||
|
@ -41,6 +42,7 @@ protocol PSocketProcess
|
|||
manages PHttpConnectionMgr;
|
||||
manages PChildToParentStream;
|
||||
manages PParentToChildStream;
|
||||
manages PInputChannelThrottleQueue;
|
||||
|
||||
parent:
|
||||
async InitCrashReporter(Shmem shmem, NativeThreadId threadId);
|
||||
|
@ -77,11 +79,14 @@ child:
|
|||
async InitProfiler(Endpoint<PProfilerChild> aEndpoint);
|
||||
// test-only
|
||||
async SocketProcessTelemetryPing();
|
||||
|
||||
async PHttpTransaction();
|
||||
async PParentToChildStream();
|
||||
async PHttpConnectionMgr();
|
||||
|
||||
async OnHttpActivityDistributorActivated(bool aIsActivated);
|
||||
async PInputChannelThrottleQueue(uint32_t meanBytesPerSecond,
|
||||
uint32_t maxBytesPerSecond);
|
||||
|
||||
both:
|
||||
async PFileDescriptorSet(FileDescriptor fd);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "SocketProcessLogging.h"
|
||||
|
||||
#include "base/task.h"
|
||||
#include "InputChannelThrottleQueueChild.h"
|
||||
#include "HttpTransactionChild.h"
|
||||
#include "HttpConnectionMgrChild.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
|
@ -311,6 +312,14 @@ SocketProcessChild::RecvOnHttpActivityDistributorActivated(
|
|||
}
|
||||
return IPC_OK();
|
||||
}
|
||||
already_AddRefed<PInputChannelThrottleQueueChild>
|
||||
SocketProcessChild::AllocPInputChannelThrottleQueueChild(
|
||||
const uint32_t& aMeanBytesPerSecond, const uint32_t& aMaxBytesPerSecond) {
|
||||
RefPtr<InputChannelThrottleQueueChild> p =
|
||||
new InputChannelThrottleQueueChild();
|
||||
p->Init(aMeanBytesPerSecond, aMaxBytesPerSecond);
|
||||
return p.forget();
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -74,6 +74,10 @@ class SocketProcessChild final
|
|||
mozilla::ipc::IPCResult RecvOnHttpActivityDistributorActivated(
|
||||
const bool& aIsActivated);
|
||||
|
||||
already_AddRefed<PInputChannelThrottleQueueChild>
|
||||
AllocPInputChannelThrottleQueueChild(const uint32_t& aMeanBytesPerSecond,
|
||||
const uint32_t& aMaxBytesPerSecond);
|
||||
|
||||
private:
|
||||
// Mapping of content process id and the SocketProcessBridgeParent.
|
||||
// This table keeps SocketProcessBridgeParent alive in socket process.
|
||||
|
|
|
@ -11,6 +11,8 @@ EXPORTS.mozilla.net += [
|
|||
'DocumentChannelChild.h',
|
||||
'DocumentChannelParent.h',
|
||||
'DocumentLoadListener.h',
|
||||
'InputChannelThrottleQueueChild.h',
|
||||
'InputChannelThrottleQueueParent.h',
|
||||
'NeckoChild.h',
|
||||
'NeckoCommon.h',
|
||||
'NeckoMessageUtils.h',
|
||||
|
@ -30,6 +32,8 @@ UNIFIED_SOURCES += [
|
|||
'DocumentChannelChild.cpp',
|
||||
'DocumentChannelParent.cpp',
|
||||
'DocumentLoadListener.cpp',
|
||||
'InputChannelThrottleQueueChild.cpp',
|
||||
'InputChannelThrottleQueueParent.cpp',
|
||||
'NeckoChild.cpp',
|
||||
'NeckoCommon.cpp',
|
||||
'NeckoParent.cpp',
|
||||
|
@ -48,6 +52,7 @@ IPDL_SOURCES = [
|
|||
'PDataChannel.ipdl',
|
||||
'PDocumentChannel.ipdl',
|
||||
'PFileChannel.ipdl',
|
||||
'PInputChannelThrottleQueue.ipdl',
|
||||
'PNecko.ipdl',
|
||||
'PSimpleChannel.ipdl',
|
||||
'PSocketProcess.ipdl',
|
||||
|
|
|
@ -4201,7 +4201,9 @@ HttpBaseChannel::SetThrottleQueue(nsIInputChannelThrottleQueue* aQueue) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetThrottleQueue(nsIInputChannelThrottleQueue** aQueue) {
|
||||
*aQueue = mThrottleQueue;
|
||||
NS_ENSURE_ARG_POINTER(aQueue);
|
||||
nsCOMPtr<nsIInputChannelThrottleQueue> queue = mThrottleQueue;
|
||||
queue.forget(aQueue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "HttpTransactionChild.h"
|
||||
|
||||
#include "mozilla/ipc/IPCStreamUtils.h"
|
||||
#include "mozilla/net/InputChannelThrottleQueueChild.h"
|
||||
#include "mozilla/net/SocketProcessChild.h"
|
||||
#include "nsInputStreamPump.h"
|
||||
#include "nsHttpHandler.h"
|
||||
|
@ -20,7 +21,7 @@ namespace mozilla {
|
|||
namespace net {
|
||||
|
||||
NS_IMPL_ISUPPORTS(HttpTransactionChild, nsIRequestObserver, nsIStreamListener,
|
||||
nsITransportEventSink);
|
||||
nsITransportEventSink, nsIThrottledInputChannel);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpTransactionChild <public>
|
||||
|
@ -206,7 +207,8 @@ mozilla::ipc::IPCResult HttpTransactionChild::RecvInit(
|
|||
const uint32_t& aClassOfService, const uint32_t& aInitialRwin,
|
||||
const bool& aResponseTimeoutEnabled, const uint64_t& aChannelId,
|
||||
const bool& aHasTransactionObserver,
|
||||
const Maybe<H2PushedStreamArg>& aPushedStreamArg) {
|
||||
const Maybe<H2PushedStreamArg>& aPushedStreamArg,
|
||||
const mozilla::Maybe<PInputChannelThrottleQueueChild*>& aThrottleQueue) {
|
||||
mRequestHead = aReqHeaders;
|
||||
if (aRequestBody) {
|
||||
mUploadStream = mozilla::ipc::DeserializeIPCStream(aRequestBody);
|
||||
|
@ -228,6 +230,11 @@ mozilla::ipc::IPCResult HttpTransactionChild::RecvInit(
|
|||
};
|
||||
}
|
||||
|
||||
if (aThrottleQueue.isSome()) {
|
||||
mThrottleQueue =
|
||||
static_cast<InputChannelThrottleQueueChild*>(aThrottleQueue.ref());
|
||||
}
|
||||
|
||||
nsresult rv = InitInternal(
|
||||
aCaps, aArgs, &mRequestHead, mUploadStream, aReqContentLength,
|
||||
aReqBodyIncludesHeaders, aTopLevelOuterContentWindowId,
|
||||
|
@ -466,5 +473,22 @@ HttpTransactionChild::OnTransportStatus(nsITransport* aTransport,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpBaseChannel::nsIThrottledInputChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpTransactionChild::SetThrottleQueue(nsIInputChannelThrottleQueue* aQueue) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpTransactionChild::GetThrottleQueue(nsIInputChannelThrottleQueue** aQueue) {
|
||||
nsCOMPtr<nsIInputChannelThrottleQueue> queue =
|
||||
static_cast<nsIInputChannelThrottleQueue*>(mThrottleQueue.get());
|
||||
queue.forget(aQueue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsHttpRequestHead.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIThrottledInputChannel.h"
|
||||
#include "nsITransport.h"
|
||||
|
||||
class nsInputStreamPump;
|
||||
|
@ -18,6 +19,7 @@ class nsInputStreamPump;
|
|||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
class InputChannelThrottleQueueChild;
|
||||
class nsHttpConnectionInfo;
|
||||
class nsHttpTransaction;
|
||||
class nsProxyInfo;
|
||||
|
@ -28,12 +30,14 @@ class nsProxyInfo;
|
|||
//-----------------------------------------------------------------------------
|
||||
class HttpTransactionChild final : public PHttpTransactionChild,
|
||||
public nsIStreamListener,
|
||||
public nsITransportEventSink {
|
||||
public nsITransportEventSink,
|
||||
public nsIThrottledInputChannel {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIREQUESTOBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSITRANSPORTEVENTSINK
|
||||
NS_DECL_NSITHROTTLEDINPUTCHANNEL
|
||||
|
||||
explicit HttpTransactionChild();
|
||||
|
||||
|
@ -47,7 +51,8 @@ class HttpTransactionChild final : public PHttpTransactionChild,
|
|||
const uint32_t& aClassOfService, const uint32_t& aInitialRwin,
|
||||
const bool& aResponseTimeoutEnabled, const uint64_t& aChannelId,
|
||||
const bool& aHasTransactionObserver,
|
||||
const Maybe<H2PushedStreamArg>& aPushedStreamArg);
|
||||
const Maybe<H2PushedStreamArg>& aPushedStreamArg,
|
||||
const mozilla::Maybe<PInputChannelThrottleQueueChild*>& aThrottleQueue);
|
||||
mozilla::ipc::IPCResult RecvUpdateClassOfService(
|
||||
const uint32_t& classOfService);
|
||||
mozilla::ipc::IPCResult RecvCancelPump(const nsresult& aStatus);
|
||||
|
@ -89,6 +94,7 @@ class HttpTransactionChild final : public PHttpTransactionChild,
|
|||
nsCOMPtr<nsIRequest> mTransactionPump;
|
||||
std::function<void()> mTransactionObserver;
|
||||
Maybe<TransactionObserverResult> mTransactionObserverResult;
|
||||
RefPtr<InputChannelThrottleQueueChild> mThrottleQueue;
|
||||
};
|
||||
|
||||
} // namespace net
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "HttpTransactionParent.h"
|
||||
#include "mozilla/ipc/IPCStreamUtils.h"
|
||||
#include "mozilla/net/InputChannelThrottleQueueParent.h"
|
||||
#include "mozilla/net/ChannelEventQueue.h"
|
||||
#include "mozilla/net/SocketProcessParent.h"
|
||||
#include "nsHttpHandler.h"
|
||||
|
@ -190,6 +191,21 @@ nsresult HttpTransactionParent::Init(
|
|||
pushedStreamArg.ref().pushedStreamId() = aPushedStreamId;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIThrottledInputChannel> throttled = do_QueryInterface(mEventsink);
|
||||
Maybe<PInputChannelThrottleQueueParent*> throttleQueue;
|
||||
if (throttled) {
|
||||
nsCOMPtr<nsIInputChannelThrottleQueue> queue;
|
||||
nsresult rv = throttled->GetThrottleQueue(getter_AddRefs(queue));
|
||||
// In case of failure, just carry on without throttling.
|
||||
if (NS_SUCCEEDED(rv) && queue) {
|
||||
LOG1(("HttpTransactionParent::Init %p using throttle queue %p\n", this,
|
||||
queue.get()));
|
||||
RefPtr<InputChannelThrottleQueueParent> tqParent = do_QueryObject(queue);
|
||||
MOZ_ASSERT(tqParent);
|
||||
throttleQueue.emplace(tqParent.get());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Figure out if we have to implement nsIThreadRetargetableRequest in
|
||||
// bug 1544378.
|
||||
if (!SendInit(caps, infoArgs, *requestHead,
|
||||
|
@ -198,7 +214,7 @@ nsresult HttpTransactionParent::Init(
|
|||
topLevelOuterContentWindowId,
|
||||
static_cast<uint8_t>(trafficCategory), requestContextID,
|
||||
classOfService, initialRwin, responseTimeoutEnabled, mChannelId,
|
||||
!!mTransactionObserver, pushedStreamArg)) {
|
||||
!!mTransactionObserver, pushedStreamArg, throttleQueue)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
include protocol PSocketProcess;
|
||||
include protocol PFileDescriptorSet; // FIXME: bug #792908
|
||||
include protocol PInputChannelThrottleQueue;
|
||||
|
||||
include IPCStream;
|
||||
include NeckoChannelParams;
|
||||
|
@ -72,7 +73,8 @@ child:
|
|||
bool responseTimeoutEnabled,
|
||||
uint64_t channelId,
|
||||
bool hasTransactionObserver,
|
||||
H2PushedStreamArg? pushedStreamArg);
|
||||
H2PushedStreamArg? pushedStreamArg,
|
||||
PInputChannelThrottleQueue? throttleQueue);
|
||||
|
||||
async UpdateClassOfService(uint32_t classOfService);
|
||||
async CancelPump(nsresult status);
|
||||
|
|
|
@ -407,9 +407,9 @@ nsresult nsHttpTransaction::Init(
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIThrottledInputChannel> throttled = do_QueryInterface(mChannel);
|
||||
nsIInputChannelThrottleQueue* queue;
|
||||
if (throttled) {
|
||||
rv = throttled->GetThrottleQueue(&queue);
|
||||
nsCOMPtr<nsIInputChannelThrottleQueue> queue;
|
||||
rv = throttled->GetThrottleQueue(getter_AddRefs(queue));
|
||||
// In case of failure, just carry on without throttling.
|
||||
if (NS_SUCCEEDED(rv) && queue) {
|
||||
nsCOMPtr<nsIAsyncInputStream> wrappedStream;
|
||||
|
@ -421,7 +421,7 @@ nsresult nsHttpTransaction::Init(
|
|||
LOG(
|
||||
("nsHttpTransaction::Init %p wrapping input stream using throttle "
|
||||
"queue %p\n",
|
||||
this, queue));
|
||||
this, queue.get()));
|
||||
mRequestStream = wrappedStream;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче