mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1492629 - de-COM mozJSComponentLoader. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D18388 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
43bf9e7c8a
commit
71bd47b5d0
@ -30,7 +30,6 @@
|
||||
#include "mozJSComponentLoader.h"
|
||||
#include "mozJSLoaderUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIJARURI.h"
|
||||
@ -66,9 +65,6 @@ using namespace mozilla::loader;
|
||||
using namespace xpc;
|
||||
using namespace JS;
|
||||
|
||||
static const char kObserverServiceContractID[] =
|
||||
"@mozilla.org/observer-service;1";
|
||||
|
||||
#define JS_CACHE_PREFIX(aType) "jsloader/" aType
|
||||
|
||||
/**
|
||||
@ -297,7 +293,7 @@ static nsresult ReportOnCallerUTF8(JSCLContextHelper& helper,
|
||||
mozJSComponentLoader::~mozJSComponentLoader() {
|
||||
if (mInitialized) {
|
||||
NS_ERROR(
|
||||
"'xpcom-shutdown-loaders' was not fired before cleaning up "
|
||||
"UnloadModules() was not explicitly called before cleaning up "
|
||||
"mozJSComponentLoader");
|
||||
UnloadModules();
|
||||
}
|
||||
@ -307,8 +303,6 @@ mozJSComponentLoader::~mozJSComponentLoader() {
|
||||
|
||||
StaticRefPtr<mozJSComponentLoader> mozJSComponentLoader::sSelf;
|
||||
|
||||
NS_IMPL_ISUPPORTS(mozJSComponentLoader, nsIObserver)
|
||||
|
||||
nsresult mozJSComponentLoader::ReallyInit() {
|
||||
MOZ_ASSERT(!mInitialized);
|
||||
|
||||
@ -323,14 +317,6 @@ nsresult mozJSComponentLoader::ReallyInit() {
|
||||
mShareLoaderGlobal = Preferences::GetBool("jsloader.shareGlobal");
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService(kObserverServiceContractID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = obsSvc->AddObserver(this, "xpcom-shutdown-loaders", false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mInitialized = true;
|
||||
|
||||
return NS_OK;
|
||||
@ -538,6 +524,12 @@ void mozJSComponentLoader::InitStatics() {
|
||||
sSelf = new mozJSComponentLoader();
|
||||
}
|
||||
|
||||
void mozJSComponentLoader::Unload() {
|
||||
if (sSelf) {
|
||||
sSelf->UnloadModules();
|
||||
}
|
||||
}
|
||||
|
||||
void mozJSComponentLoader::Shutdown() {
|
||||
MOZ_ASSERT(sSelf);
|
||||
sSelf = nullptr;
|
||||
@ -1406,18 +1398,6 @@ nsresult mozJSComponentLoader::Unload(const nsACString& aLocation) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozJSComponentLoader::Observe(nsISupports* subject, const char* topic,
|
||||
const char16_t* data) {
|
||||
if (!strcmp(topic, "xpcom-shutdown-loaders")) {
|
||||
UnloadModules();
|
||||
} else {
|
||||
NS_ERROR("Unexpected observer topic.");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
size_t mozJSComponentLoader::ModuleEntry::SizeOfIncludingThis(
|
||||
MallocSizeOf aMallocSizeOf) const {
|
||||
size_t n = aMallocSizeOf(this);
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
@ -34,12 +33,9 @@ class ScriptPreloader;
|
||||
# define STARTUP_RECORDER_ENABLED
|
||||
#endif
|
||||
|
||||
class mozJSComponentLoader final : public nsIObserver {
|
||||
class mozJSComponentLoader final {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
mozJSComponentLoader();
|
||||
NS_INLINE_DECL_REFCOUNTING(mozJSComponentLoader);
|
||||
|
||||
void GetLoadedModules(nsTArray<nsCString>& aLoadedModules);
|
||||
void GetLoadedComponents(nsTArray<nsCString>& aLoadedComponents);
|
||||
@ -53,6 +49,7 @@ class mozJSComponentLoader final : public nsIObserver {
|
||||
void FindTargetObject(JSContext* aCx, JS::MutableHandleObject aTargetObject);
|
||||
|
||||
static void InitStatics();
|
||||
static void Unload();
|
||||
static void Shutdown();
|
||||
|
||||
static mozJSComponentLoader* Get() {
|
||||
@ -84,7 +81,8 @@ class mozJSComponentLoader final : public nsIObserver {
|
||||
nsresult AnnotateCrashReport();
|
||||
|
||||
protected:
|
||||
virtual ~mozJSComponentLoader();
|
||||
mozJSComponentLoader();
|
||||
~mozJSComponentLoader();
|
||||
|
||||
friend class XPCJSRuntime;
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/SharedThreadPool.h"
|
||||
#include "mozilla/VideoDecoderManagerChild.h"
|
||||
#include "mozilla/XPCOM.h"
|
||||
#include "mozJSComponentLoader.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#ifndef ANDROID
|
||||
@ -591,7 +592,6 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsISimpleEnumerator> moduleLoaders;
|
||||
|
||||
// Notify observers of xpcom shutting down
|
||||
{
|
||||
@ -662,13 +662,8 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
|
||||
// xpcshell tests replacing the service) modules being unloaded.
|
||||
mozilla::InitLateWriteChecks();
|
||||
|
||||
// We save the "xpcom-shutdown-loaders" observers to notify after
|
||||
// the observerservice is gone.
|
||||
if (observerService) {
|
||||
mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownLoaders);
|
||||
observerService->EnumerateObservers(NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID,
|
||||
getter_AddRefs(moduleLoaders));
|
||||
|
||||
observerService->Shutdown();
|
||||
}
|
||||
}
|
||||
@ -698,28 +693,11 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
|
||||
free(gGREBinPath);
|
||||
gGREBinPath = nullptr;
|
||||
|
||||
if (moduleLoaders) {
|
||||
bool more;
|
||||
nsCOMPtr<nsISupports> el;
|
||||
while (NS_SUCCEEDED(moduleLoaders->HasMoreElements(&more)) && more) {
|
||||
moduleLoaders->GetNext(getter_AddRefs(el));
|
||||
|
||||
// Don't worry about weak-reference observers here: there is
|
||||
// no reason for weak-ref observers to register for
|
||||
// xpcom-shutdown-loaders
|
||||
|
||||
// FIXME: This can cause harmless writes from sqlite committing
|
||||
// log files. We have to ignore them before we can move
|
||||
// the mozilla::PoisonWrite call before this point. See bug
|
||||
// 834945 for the details.
|
||||
nsCOMPtr<nsIObserver> obs(do_QueryInterface(el));
|
||||
if (obs) {
|
||||
obs->Observe(nullptr, NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
moduleLoaders = nullptr;
|
||||
}
|
||||
// FIXME: This can cause harmless writes from sqlite committing
|
||||
// log files. We have to ignore them before we can move
|
||||
// the mozilla::PoisonWrite call before this point. See bug
|
||||
// 834945 for the details.
|
||||
mozJSComponentLoader::Unload();
|
||||
|
||||
// Clear the profiler's JS context before cycle collection. The profiler will
|
||||
// notify the JS engine that it can let go of any data it's holding on to for
|
||||
|
@ -100,6 +100,7 @@ LOCAL_INCLUDES += [
|
||||
'../threads',
|
||||
'/chrome',
|
||||
'/docshell/base',
|
||||
'/js/xpconnect/loader',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_VPX']:
|
||||
|
@ -16,12 +16,6 @@
|
||||
*/
|
||||
#define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID "xpcom-shutdown-threads"
|
||||
|
||||
/**
|
||||
* During this shutdown notification all module loaders must unload XPCOM
|
||||
* modules.
|
||||
*/
|
||||
#define NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID "xpcom-shutdown-loaders"
|
||||
|
||||
// PUBLIC
|
||||
namespace mozilla {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user