зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1610387 - Remove nsAutoPtr usage from js/xpconnect/. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D60638 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
98e40ec294
Коммит
1eef62fbd1
|
@ -19,7 +19,6 @@
|
|||
#include "mozilla/Casting.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
using namespace js;
|
||||
using namespace JS;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "js/PropertySpec.h"
|
||||
#include "js/SourceText.h" // JS::SourceText
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsExceptionHandler.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "mozilla/Module.h"
|
||||
|
@ -416,7 +415,7 @@ const mozilla::Module* mozJSComponentLoader::LoadModule(FileLocation& aFile) {
|
|||
bool isCriticalModule =
|
||||
StringEndsWith(spec, NS_LITERAL_CSTRING("/nsAsyncShutdown.js"));
|
||||
|
||||
nsAutoPtr<ModuleEntry> entry(new ModuleEntry(RootingContext::get(cx)));
|
||||
auto entry = MakeUnique<ModuleEntry>(RootingContext::get(cx));
|
||||
RootedValue exn(cx);
|
||||
rv = ObjectForLocation(info, file, &entry->obj, &entry->thisObjectKey,
|
||||
&entry->location, isCriticalModule, &exn);
|
||||
|
@ -497,10 +496,10 @@ const mozilla::Module* mozJSComponentLoader::LoadModule(FileLocation& aFile) {
|
|||
#endif
|
||||
|
||||
// Cache this module for later
|
||||
mModules.Put(spec, entry);
|
||||
mModules.Put(spec, entry.get());
|
||||
|
||||
// The hash owns the ModuleEntry now, forget about it
|
||||
return entry.forget();
|
||||
return entry.release();
|
||||
}
|
||||
|
||||
void mozJSComponentLoader::FindTargetObject(JSContext* aCx,
|
||||
|
@ -1302,13 +1301,10 @@ nsresult mozJSComponentLoader::Import(JSContext* aCx,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
ModuleEntry* mod;
|
||||
nsAutoPtr<ModuleEntry> newEntry;
|
||||
UniquePtr<ModuleEntry> newEntry;
|
||||
if (!mImports.Get(info.Key(), &mod) &&
|
||||
!mInProgressImports.Get(info.Key(), &mod)) {
|
||||
newEntry = new ModuleEntry(RootingContext::get(aCx));
|
||||
if (!newEntry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
newEntry = MakeUnique<ModuleEntry>(RootingContext::get(aCx));
|
||||
|
||||
// Note: This implies EnsureURI().
|
||||
MOZ_TRY(info.EnsureResolvedURI());
|
||||
|
@ -1347,7 +1343,7 @@ nsresult mozJSComponentLoader::Import(JSContext* aCx,
|
|||
|
||||
RootedValue exception(aCx);
|
||||
{
|
||||
mInProgressImports.Put(info.Key(), newEntry);
|
||||
mInProgressImports.Put(info.Key(), newEntry.get());
|
||||
auto cleanup =
|
||||
MakeScopeExit([&]() { mInProgressImports.Remove(info.Key()); });
|
||||
|
||||
|
@ -1377,7 +1373,7 @@ nsresult mozJSComponentLoader::Import(JSContext* aCx,
|
|||
}
|
||||
#endif
|
||||
|
||||
mod = newEntry;
|
||||
mod = newEntry.get();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mod->obj, "Import table contains entry with no object");
|
||||
|
@ -1395,8 +1391,7 @@ nsresult mozJSComponentLoader::Import(JSContext* aCx,
|
|||
|
||||
// Cache this module for later
|
||||
if (newEntry) {
|
||||
mImports.Put(info.Key(), newEntry);
|
||||
newEntry.forget();
|
||||
mImports.Put(info.Key(), newEntry.release());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Module.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsClassHashtable.h"
|
||||
|
@ -187,13 +187,6 @@ class mozJSComponentLoader final {
|
|||
nsresult ExtractExports(JSContext* aCx, ComponentLoaderInfo& aInfo,
|
||||
ModuleEntry* aMod, JS::MutableHandleObject aExports);
|
||||
|
||||
static size_t DataEntrySizeOfExcludingThis(
|
||||
const nsACString& aKey, ModuleEntry* const& aData,
|
||||
mozilla::MallocSizeOf aMallocSizeOf, void* arg);
|
||||
static size_t ClassEntrySizeOfExcludingThis(
|
||||
const nsACString& aKey, const nsAutoPtr<ModuleEntry>& aData,
|
||||
mozilla::MallocSizeOf aMallocSizeOf, void* arg);
|
||||
|
||||
// Modules are intentionally leaked, but still cleared.
|
||||
nsDataHashtable<nsCStringHashKey, ModuleEntry*> mModules;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "XPCJSMemoryReporter.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "mozJSComponentLoader.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
|
@ -281,7 +280,7 @@ class WatchdogManager {
|
|||
|
||||
void RegisterContext(XPCJSContext* aContext) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AutoLockWatchdog lock(mWatchdog);
|
||||
AutoLockWatchdog lock(mWatchdog.get());
|
||||
|
||||
if (aContext->mActive == XPCJSContext::CONTEXT_ACTIVE) {
|
||||
mActiveContexts.insertBack(aContext);
|
||||
|
@ -295,7 +294,7 @@ class WatchdogManager {
|
|||
|
||||
void UnregisterContext(XPCJSContext* aContext) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AutoLockWatchdog lock(mWatchdog);
|
||||
AutoLockWatchdog lock(mWatchdog.get());
|
||||
|
||||
// aContext must be in one of our two lists, simply remove it.
|
||||
aContext->LinkedListElement<XPCJSContext>::remove();
|
||||
|
@ -315,7 +314,7 @@ class WatchdogManager {
|
|||
void RecordContextActivity(XPCJSContext* aContext, bool active) {
|
||||
// The watchdog reads this state, so acquire the lock before writing it.
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
AutoLockWatchdog lock(mWatchdog);
|
||||
AutoLockWatchdog lock(mWatchdog.get());
|
||||
|
||||
// Write state.
|
||||
aContext->mLastStateChange = PR_Now();
|
||||
|
@ -365,7 +364,7 @@ class WatchdogManager {
|
|||
return mTimestamps[aCategory];
|
||||
}
|
||||
|
||||
Watchdog* GetWatchdog() { return mWatchdog; }
|
||||
Watchdog* GetWatchdog() { return mWatchdog.get(); }
|
||||
|
||||
void RefreshWatchdog() {
|
||||
bool wantWatchdog = Preferences::GetBool("dom.use_watchdog", true);
|
||||
|
@ -400,7 +399,7 @@ class WatchdogManager {
|
|||
|
||||
void StartWatchdog() {
|
||||
MOZ_ASSERT(!mWatchdog);
|
||||
mWatchdog = new Watchdog(this);
|
||||
mWatchdog = mozilla::MakeUnique<Watchdog>(this);
|
||||
mWatchdog->Init();
|
||||
}
|
||||
|
||||
|
@ -442,7 +441,7 @@ class WatchdogManager {
|
|||
|
||||
LinkedList<XPCJSContext> mActiveContexts;
|
||||
LinkedList<XPCJSContext> mInactiveContexts;
|
||||
nsAutoPtr<Watchdog> mWatchdog;
|
||||
mozilla::UniquePtr<Watchdog> mWatchdog;
|
||||
|
||||
// We store ContextStateChange on the contexts themselves.
|
||||
PRTime mTimestamps[kWatchdogTimestampCategoryCount - 1];
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include "XrayWrapper.h"
|
||||
#include "WrapperFactory.h"
|
||||
#include "mozJSComponentLoader.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsContentSecurityUtils.h"
|
||||
|
||||
|
@ -630,9 +629,10 @@ static void CompartmentDestroyedCallback(JSFreeOp* fop,
|
|||
// NB - This callback may be called in JS_DestroyContext, which happens
|
||||
// after the XPCJSRuntime has been torn down.
|
||||
|
||||
// Get the current compartment private into an AutoPtr (which will do the
|
||||
// Get the current compartment private into a UniquePtr (which will do the
|
||||
// cleanup for us), and null out the private (which may already be null).
|
||||
nsAutoPtr<CompartmentPrivate> priv(CompartmentPrivate::Get(compartment));
|
||||
mozilla::UniquePtr<CompartmentPrivate> priv(
|
||||
CompartmentPrivate::Get(compartment));
|
||||
JS_SetCompartmentPrivate(compartment, nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* well as providing refcounting support.
|
||||
*/
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringBuffer.h"
|
||||
|
|
|
@ -100,7 +100,6 @@
|
|||
#include "PLDHashTable.h"
|
||||
#include "nscore.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsISupports.h"
|
||||
|
@ -886,7 +885,7 @@ class XPCWrappedNativeScope final
|
|||
JS::HandleObject aFirstGlobal);
|
||||
virtual ~XPCWrappedNativeScope();
|
||||
|
||||
nsAutoPtr<JSObject2JSObjectMap> mWaiverWrapperMap;
|
||||
mozilla::UniquePtr<JSObject2JSObjectMap> mWaiverWrapperMap;
|
||||
|
||||
JS::Compartment* Compartment() const { return mCompartment; }
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ JSObject* WrapperFactory::CreateXrayWaiver(JSContext* cx, HandleObject obj,
|
|||
// one waiver for the lifetime of the target object.
|
||||
if (!scope->mWaiverWrapperMap) {
|
||||
scope->mWaiverWrapperMap =
|
||||
JSObject2JSObjectMap::newMap(XPC_WRAPPER_MAP_LENGTH);
|
||||
WrapUnique(JSObject2JSObjectMap::newMap(XPC_WRAPPER_MAP_LENGTH));
|
||||
}
|
||||
if (!scope->mWaiverWrapperMap->Add(cx, obj, waiver)) {
|
||||
return nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче