bug 897503 - part 3 several nsHttpHandler nsCOMPtrs need to be nsMainThreadPtrHandle r=sworkman

This commit is contained in:
Patrick McManus 2013-08-13 15:36:59 -04:00
parent 5c56bcd614
commit fc56698acc
2 changed files with 22 additions and 13 deletions

View File

@ -257,11 +257,12 @@ nsHttpHandler::Init()
if (NS_FAILED(rv))
return rv;
mIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIIOService> service = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
NS_WARNING("unable to continue without io service");
return rv;
}
mIOService = new nsMainThreadPtrHolder<nsIIOService>(service);
if (IsNeckoChild())
NeckoChild::InitNeckoChild();
@ -341,7 +342,8 @@ nsHttpHandler::Init()
static_cast<nsISupports*>(static_cast<void*>(this)),
NS_HTTP_STARTUP_TOPIC);
mObserverService = services::GetObserverService();
nsCOMPtr<nsIObserverService> obsService = services::GetObserverService();
mObserverService = new nsMainThreadPtrHolder<nsIObserverService>(obsService);
if (mObserverService) {
mObserverService->AddObserver(this, "profile-change-net-teardown", true);
mObserverService->AddObserver(this, "profile-change-net-restore", true);
@ -475,8 +477,11 @@ nsHttpHandler::GetStreamConverterService(nsIStreamConverterService **result)
{
if (!mStreamConvSvc) {
nsresult rv;
mStreamConvSvc = do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStreamConverterService> service =
do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
mStreamConvSvc = new nsMainThreadPtrHolder<nsIStreamConverterService>(service);
}
*result = mStreamConvSvc;
NS_ADDREF(*result);
@ -486,16 +491,20 @@ nsHttpHandler::GetStreamConverterService(nsIStreamConverterService **result)
nsISiteSecurityService*
nsHttpHandler::GetSSService()
{
if (!mSSService)
mSSService = do_GetService(NS_SSSERVICE_CONTRACTID);
if (!mSSService) {
nsCOMPtr<nsISiteSecurityService> service = do_GetService(NS_SSSERVICE_CONTRACTID);
mSSService = new nsMainThreadPtrHolder<nsISiteSecurityService>(service);
}
return mSSService;
}
nsICookieService *
nsHttpHandler::GetCookieService()
{
if (!mCookieService)
mCookieService = do_GetService(NS_COOKIESERVICE_CONTRACTID);
if (!mCookieService) {
nsCOMPtr<nsICookieService> service = do_GetService(NS_COOKIESERVICE_CONTRACTID);
mCookieService = new nsMainThreadPtrHolder<nsICookieService>(service);
}
return mCookieService;
}

View File

@ -304,11 +304,11 @@ private:
private:
// cached services
nsCOMPtr<nsIIOService> mIOService;
nsCOMPtr<nsIStreamConverterService> mStreamConvSvc;
nsCOMPtr<nsIObserverService> mObserverService;
nsCOMPtr<nsICookieService> mCookieService;
nsCOMPtr<nsISiteSecurityService> mSSService;
nsMainThreadPtrHandle<nsIIOService> mIOService;
nsMainThreadPtrHandle<nsIStreamConverterService> mStreamConvSvc;
nsMainThreadPtrHandle<nsIObserverService> mObserverService;
nsMainThreadPtrHandle<nsICookieService> mCookieService;
nsMainThreadPtrHandle<nsISiteSecurityService> mSSService;
// the authentication credentials cache
nsHttpAuthCache mAuthCache;