summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/http/Http2Push.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-07-21 21:30:26 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-07-21 21:31:04 +0200
commit91de3341df7e08094e17a34053b8e21c89ab02a7 (patch)
treefafc6b9475618a2055e627d0f5a68593ee11eb4f /netwerk/protocol/http/Http2Push.cpp
parent1dbed95e4c43fdbcc2d959ddb06ebe6331afb9d8 (diff)
downloadUXP-91de3341df7e08094e17a34053b8e21c89ab02a7.tar
UXP-91de3341df7e08094e17a34053b8e21c89ab02a7.tar.gz
UXP-91de3341df7e08094e17a34053b8e21c89ab02a7.tar.lz
UXP-91de3341df7e08094e17a34053b8e21c89ab02a7.tar.xz
UXP-91de3341df7e08094e17a34053b8e21c89ab02a7.zip
Revert "Implement a threadsafe & revised version of http2PushedStream."
Backed out because of gcc build failures. This reverts commit 66fae1d81013a2321e7d607a426f834a01b847ce.
Diffstat (limited to 'netwerk/protocol/http/Http2Push.cpp')
-rw-r--r--netwerk/protocol/http/Http2Push.cpp81
1 files changed, 4 insertions, 77 deletions
diff --git a/netwerk/protocol/http/Http2Push.cpp b/netwerk/protocol/http/Http2Push.cpp
index 34fc425d2..b6fc485e2 100644
--- a/netwerk/protocol/http/Http2Push.cpp
+++ b/netwerk/protocol/http/Http2Push.cpp
@@ -30,8 +30,8 @@ class CallChannelOnPush final : public Runnable {
Http2PushedStream *pushStream)
: mAssociatedChannel(associatedChannel)
, mPushedURI(pushedURI)
+ , mPushedStream(pushStream)
{
- mPushedStreamWrapper = new Http2PushedStreamWrapper(pushStream);
}
NS_IMETHOD Run() override
@@ -40,94 +40,21 @@ class CallChannelOnPush final : public Runnable {
RefPtr<nsHttpChannel> channel;
CallQueryInterface(mAssociatedChannel, channel.StartAssignment());
MOZ_ASSERT(channel);
- if (channel && NS_SUCCEEDED(channel->OnPush(mPushedURI, mPushedStreamWrapper))) {
+ if (channel && NS_SUCCEEDED(channel->OnPush(mPushedURI, mPushedStream))) {
return NS_OK;
}
LOG3(("Http2PushedStream Orphan %p failed OnPush\n", this));
- mPushedStreamWrapper->OnPushFailed();
+ mPushedStream->OnPushFailed();
return NS_OK;
}
private:
nsCOMPtr<nsIHttpChannelInternal> mAssociatedChannel;
const nsCString mPushedURI;
- RefPtr<Http2PushedStreamWrapper> mPushedStreamWrapper;
+ Http2PushedStream *mPushedStream;
};
-// Because WeakPtr isn't thread-safe we must ensure that the object is destroyed
-// on the socket thread, so any Release() called on a different thread is
-// dispatched to the socket thread.
-bool Http2PushedStreamWrapper::DispatchRelease() {
- if (PR_GetCurrentThread() == gSocketThread) {
- return false;
- }
-
- gSocketTransportService->Dispatch(
- NewNonOwningRunnableMethod(this, &Http2PushedStreamWrapper::Release),
- NS_DISPATCH_NORMAL);
-
- return true;
-}
-
-NS_IMPL_ADDREF(Http2PushedStreamWrapper)
-NS_IMETHODIMP_(MozExternalRefCountType)
-Http2PushedStreamWrapper::Release() {
- nsrefcnt count = mRefCnt - 1;
- if (DispatchRelease()) {
- // Redispatched to the socket thread.
- return count;
- }
-
- MOZ_ASSERT(0 != mRefCnt, "dup release");
- count = --mRefCnt;
- NS_LOG_RELEASE(this, count, "Http2PushedStreamWrapper");
-
- if (0 == count) {
- mRefCnt = 1;
- delete (this);
- return 0;
- }
-
- return count;
-}
-
-NS_INTERFACE_MAP_BEGIN(Http2PushedStreamWrapper)
-NS_INTERFACE_MAP_END
-
-Http2PushedStreamWrapper::Http2PushedStreamWrapper(
- Http2PushedStream* aPushStream) {
- MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not on socket thread");
- mStream = aPushStream;
- mRequestString = aPushStream->GetRequestString();
-}
-
-Http2PushedStreamWrapper::~Http2PushedStreamWrapper() {
- MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not on socket thread");
-}
-
-Http2PushedStream* Http2PushedStreamWrapper::GetStream() {
- MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "not on socket thread");
- if (mStream) {
- Http2Stream* stream = mStream;
- return static_cast<Http2PushedStream*>(stream);
- }
- return nullptr;
-}
-
-void Http2PushedStreamWrapper::OnPushFailed() {
- if (PR_GetCurrentThread() == gSocketThread) {
- if (mStream) {
- Http2Stream* stream = mStream;
- static_cast<Http2PushedStream*>(stream)->OnPushFailed();
- }
- } else {
- gSocketTransportService->Dispatch(
- NewRunnableMethod(this, &Http2PushedStreamWrapper::OnPushFailed),
- NS_DISPATCH_NORMAL);
- }
-}
-
//////////////////////////////////////////
// Http2PushedStream
//////////////////////////////////////////