Backed out changeset cb84a3ed7bdd (bug 1504557) for nsErrorService leakcheck failures CLOSED TREE

This commit is contained in:
Ciure Andrei 2018-11-05 05:17:40 +02:00
Родитель dd816ca924
Коммит 46f758b8b5
9 изменённых файлов: 57 добавлений и 37 удалений

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

@ -26,7 +26,7 @@
#include "nsThreadUtils.h"
#include "jsapi.h"
#include "txExprParser.h"
#include "nsErrorService.h"
#include "nsIErrorService.h"
#include "nsIScriptSecurityManager.h"
#include "nsJSUtils.h"
#include "nsIXPConnect.h"
@ -1286,9 +1286,12 @@ txMozillaXSLTProcessor::Startup()
return NS_ERROR_OUT_OF_MEMORY;
}
nsCOMPtr<nsIErrorService> errorService = nsErrorService::GetOrCreate();
errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_XSLT,
XSLT_MSGS_URL);
nsCOMPtr<nsIErrorService> errorService =
do_GetService(NS_ERRORSERVICE_CONTRACTID);
if (errorService) {
errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_XSLT,
XSLT_MSGS_URL);
}
return NS_OK;
}
@ -1299,8 +1302,11 @@ txMozillaXSLTProcessor::Shutdown()
{
txXSLTProcessor::shutdown();
nsCOMPtr<nsIErrorService> errorService = nsErrorService::GetOrCreate();
errorService->UnregisterErrorStringBundle(NS_ERROR_MODULE_XSLT);
nsCOMPtr<nsIErrorService> errorService =
do_GetService(NS_ERRORSERVICE_CONTRACTID);
if (errorService) {
errorService->UnregisterErrorStringBundle(NS_ERROR_MODULE_XSLT);
}
}
/* static*/

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

@ -21,7 +21,7 @@
#include "nsIObserverService.h"
#include "nsCOMArray.h"
#include "nsTextFormatter.h"
#include "nsErrorService.h"
#include "nsIErrorService.h"
#include "nsICategoryManager.h"
#include "nsContentUtils.h"
#include "nsPersistentProperties.h"
@ -49,6 +49,8 @@ using mozilla::dom::ipc::SharedStringMap;
using mozilla::dom::ipc::SharedStringMapBuilder;
using mozilla::ipc::FileDescriptor;
static NS_DEFINE_CID(kErrorServiceCID, NS_ERRORSERVICE_CID);
/**
* A set of string bundle URLs which are loaded by content processes, and
* should be allocated in a shared memory region, and then sent to content
@ -761,8 +763,8 @@ struct bundleCacheEntry_t final : public LinkedListElement<bundleCacheEntry_t> {
nsStringBundleService::nsStringBundleService() :
mBundleMap(MAX_CACHED_BUNDLES)
{
mErrorService = nsErrorService::GetOrCreate();
MOZ_ALWAYS_TRUE(mErrorService);
mErrorService = do_GetService(kErrorServiceCID);
NS_ASSERTION(mErrorService, "Couldn't get error service");
}
NS_IMPL_ISUPPORTS(nsStringBundleService,

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

@ -12,7 +12,7 @@
#include "nscore.h"
#include "nsIURI.h"
#include "prprf.h"
#include "nsErrorService.h"
#include "nsIErrorService.h"
#include "netCore.h"
#include "nsIObserverService.h"
#include "nsIPrefService.h"
@ -216,9 +216,12 @@ nsresult
nsIOService::Init()
{
// XXX hack until xpidl supports error info directly (bug 13423)
nsCOMPtr<nsIErrorService> errorService = nsErrorService::GetOrCreate();
MOZ_ALWAYS_TRUE(errorService);
errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_NETWORK, NECKO_MSGS_URL);
nsCOMPtr<nsIErrorService> errorService = do_GetService(NS_ERRORSERVICE_CONTRACTID);
if (errorService) {
errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_NETWORK, NECKO_MSGS_URL);
}
else
NS_WARNING("failed to get error service");
InitializeCaptivePortalService();

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

@ -67,7 +67,6 @@ EXPORTS += [
'nsDebugImpl.h',
'nsDumpUtils.h',
'nsError.h',
'nsErrorService.h',
'nsGZFileWriter.h',
'nsIClassInfoImpl.h',
'nsID.h',

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

@ -7,31 +7,18 @@
#include "nsErrorService.h"
#include "nsCRTGlue.h"
#include "nsAutoPtr.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/ClearOnShutdown.h"
namespace {
mozilla::StaticRefPtr<nsErrorService> gSingleton;
}
NS_IMPL_ISUPPORTS(nsErrorService, nsIErrorService)
// static
already_AddRefed<nsIErrorService>
nsErrorService::GetOrCreate()
nsresult
nsErrorService::Create(nsISupports* aOuter, const nsIID& aIID,
void** aInstancePtr)
{
RefPtr<nsErrorService> svc;
if (gSingleton) {
svc = gSingleton;
} else {
gSingleton = new nsErrorService();
mozilla::ClearOnShutdown(&gSingleton);
svc = gSingleton;
if (NS_WARN_IF(aOuter)) {
return NS_ERROR_NO_AGGREGATION;
}
return svc.forget();
RefPtr<nsErrorService> serv = new nsErrorService();
return serv->QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP

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

@ -19,11 +19,17 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIERRORSERVICE
static already_AddRefed<nsIErrorService> GetOrCreate();
nsErrorService()
{
}
static nsresult
Create(nsISupports* aOuter, const nsIID& aIID, void** aInstancePtr);
private:
nsErrorService() = default;
~nsErrorService() = default;
~nsErrorService()
{
}
nsClassHashtable<nsUint32HashKey, nsCString> mErrorStringBundleURLMap;
};

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

@ -32,3 +32,18 @@ interface nsIErrorService : nsISupports
*/
string getErrorStringBundle(in short errorModule);
};
%{C++
// The global nsIErrorService:
#define NS_ERRORSERVICE_NAME "Error Service"
#define NS_ERRORSERVICE_CONTRACTID "@mozilla.org/xpcom/error-service;1"
#define NS_ERRORSERVICE_CID \
{ /* 744afd5e-5f8c-11d4-9877-00c04fa0cf4a */ \
0x744afd5e, \
0x5f8c, \
0x11d4, \
{0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a} \
}
%}

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

@ -37,6 +37,7 @@
#include "nsMemoryImpl.h"
#include "nsDebugImpl.h"
#include "nsTraceRefcnt.h"
#include "nsErrorService.h"
#include "nsArray.h"
#include "nsINIParserImpl.h"

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

@ -1,5 +1,6 @@
COMPONENT_M(MEMORY, nsMemoryImpl::Create, Module::ALLOW_IN_GPU_PROCESS)
COMPONENT_M(DEBUG, nsDebugImpl::Create, Module::ALLOW_IN_GPU_PROCESS)
COMPONENT(ERRORSERVICE, nsErrorService::Create)
COMPONENT_M(CATEGORYMANAGER, nsCategoryManager::Create, Module::ALLOW_IN_GPU_PROCESS)