зеркало из https://github.com/mozilla/gecko-dev.git
bug 897503 - part 2 use smart pointers for nsHttpHandler references r=sworkman
This commit is contained in:
Родитель
cb979bfe46
Коммит
0bde7d8d87
|
@ -59,12 +59,10 @@ HttpBaseChannel::HttpBaseChannel()
|
|||
, mSuspendCount(0)
|
||||
, mProxyResolveFlags(0)
|
||||
, mContentDispositionHint(UINT32_MAX)
|
||||
, mHttpHandler(gHttpHandler)
|
||||
{
|
||||
LOG(("Creating HttpBaseChannel @%x\n", this));
|
||||
|
||||
// grab a reference to the handler to ensure that it doesn't go away.
|
||||
NS_ADDREF(gHttpHandler);
|
||||
|
||||
// Subfields of unions cannot be targeted in an initializer list
|
||||
mSelfAddr.raw.family = PR_AF_UNSPEC;
|
||||
mPeerAddr.raw.family = PR_AF_UNSPEC;
|
||||
|
@ -76,8 +74,6 @@ HttpBaseChannel::~HttpBaseChannel()
|
|||
|
||||
// Make sure we don't leak
|
||||
CleanRedirectCacheChainIfNecessary();
|
||||
|
||||
gHttpHandler->Release();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -307,6 +307,8 @@ protected:
|
|||
|
||||
uint32_t mContentDispositionHint;
|
||||
nsAutoPtr<nsString> mContentDispositionFilename;
|
||||
|
||||
nsRefPtr<nsHttpHandler> mHttpHandler; // keep gHttpHandler alive
|
||||
};
|
||||
|
||||
// Share some code while working around C++'s absurd inability to handle casting
|
||||
|
|
|
@ -46,19 +46,13 @@ nsHttpChannelAuthProvider::nsHttpChannelAuthProvider()
|
|||
, mTriedProxyAuth(false)
|
||||
, mTriedHostAuth(false)
|
||||
, mSuppressDefensiveAuth(false)
|
||||
, mHttpHandler(gHttpHandler)
|
||||
{
|
||||
// grab a reference to the handler to ensure that it doesn't go away.
|
||||
nsHttpHandler *handler = gHttpHandler;
|
||||
NS_ADDREF(handler);
|
||||
}
|
||||
|
||||
nsHttpChannelAuthProvider::~nsHttpChannelAuthProvider()
|
||||
{
|
||||
MOZ_ASSERT(!mAuthChannel, "Disconnect wasn't called");
|
||||
|
||||
// release our reference to the handler
|
||||
nsHttpHandler *handler = gHttpHandler;
|
||||
NS_RELEASE(handler);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsIHttpAuthenticator;
|
||||
class nsHttpHandler;
|
||||
|
||||
class nsHttpChannelAuthProvider : public nsIHttpChannelAuthProvider
|
||||
, public nsIAuthPromptCallback
|
||||
|
@ -143,6 +144,8 @@ private:
|
|||
uint32_t mTriedProxyAuth : 1;
|
||||
uint32_t mTriedHostAuth : 1;
|
||||
uint32_t mSuppressDefensiveAuth : 1;
|
||||
|
||||
nsRefPtr<nsHttpHandler> mHttpHandler; // keep gHttpHandler alive
|
||||
};
|
||||
|
||||
#endif // nsHttpChannelAuthProvider_h__
|
||||
|
|
|
@ -44,6 +44,7 @@ using namespace mozilla::net;
|
|||
|
||||
nsHttpConnection::nsHttpConnection()
|
||||
: mTransaction(nullptr)
|
||||
, mHttpHandler(gHttpHandler)
|
||||
, mCallbacksLock("nsHttpConnection::mCallbacksLock")
|
||||
, mIdleTimeout(0)
|
||||
, mConsiderReusedAfterInterval(0)
|
||||
|
@ -75,20 +76,12 @@ nsHttpConnection::nsHttpConnection()
|
|||
, mTransactionCaps(0)
|
||||
{
|
||||
LOG(("Creating nsHttpConnection @%x\n", this));
|
||||
|
||||
// grab a reference to the handler to ensure that it doesn't go away.
|
||||
nsHttpHandler *handler = gHttpHandler;
|
||||
NS_ADDREF(handler);
|
||||
}
|
||||
|
||||
nsHttpConnection::~nsHttpConnection()
|
||||
{
|
||||
LOG(("Destroying nsHttpConnection @%x\n", this));
|
||||
|
||||
// release our reference to the handler
|
||||
nsHttpHandler *handler = gHttpHandler;
|
||||
NS_RELEASE(handler);
|
||||
|
||||
if (!mEverUsedSpdy) {
|
||||
LOG(("nsHttpConnection %p performed %d HTTP/1.x transactions\n",
|
||||
this, mHttp1xTransactionCount));
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
class nsHttpRequestHead;
|
||||
class nsHttpResponseHead;
|
||||
class nsHttpHandler;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsHttpConnection - represents a connection to a HTTP server (or proxy)
|
||||
|
@ -206,6 +207,8 @@ private:
|
|||
// transaction is open, otherwise it is null.
|
||||
nsRefPtr<nsAHttpTransaction> mTransaction;
|
||||
|
||||
nsRefPtr<nsHttpHandler> mHttpHandler; // keep gHttpHandler alive
|
||||
|
||||
mozilla::Mutex mCallbacksLock;
|
||||
nsMainThreadPtrHandle<nsIInterfaceRequestor> mCallbacks;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче