bug 897503 - part 2 use smart pointers for nsHttpHandler references r=sworkman

This commit is contained in:
Patrick McManus 2013-08-13 15:36:58 -04:00
Родитель cb979bfe46
Коммит 0bde7d8d87
6 изменённых файлов: 11 добавлений и 20 удалений

Просмотреть файл

@ -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;