Backed out 27 changesets (bug 1323100) for clipboard leaktest failures a=backout

Backed out changeset 84fb749698ab (bug 1323100)
Backed out changeset d6d25e8bd001 (bug 1323100)
Backed out changeset 1b0855bb0c38 (bug 1323100)
Backed out changeset b6953e3f5739 (bug 1323100)
Backed out changeset 5572f3b63215 (bug 1323100)
Backed out changeset 12fb4c533659 (bug 1323100)
Backed out changeset c36524e4e919 (bug 1323100)
Backed out changeset 1e3b3eddbe26 (bug 1323100)
Backed out changeset 061110f1ae12 (bug 1323100)
Backed out changeset 413dbd31725b (bug 1323100)
Backed out changeset 06550f7eca62 (bug 1323100)
Backed out changeset 940933b13b36 (bug 1323100)
Backed out changeset a6d75c1cd724 (bug 1323100)
Backed out changeset 681cacbbaa3b (bug 1323100)
Backed out changeset 3d53787293f6 (bug 1323100)
Backed out changeset c0340dfe4766 (bug 1323100)
Backed out changeset 9f554991549d (bug 1323100)
Backed out changeset 757539e7039a (bug 1323100)
Backed out changeset a3c9b45aa917 (bug 1323100)
Backed out changeset 23d69df98a66 (bug 1323100)
Backed out changeset 1297ded6a01d (bug 1323100)
Backed out changeset f4235b97257f (bug 1323100)
Backed out changeset 93419cb4f29f (bug 1323100)
Backed out changeset 865d1b81c804 (bug 1323100)
Backed out changeset 54acf4ef8e84 (bug 1323100)
Backed out changeset 88d17bcd8205 (bug 1323100)
Backed out changeset 0c466e5e8933 (bug 1323100)
This commit is contained in:
Wes Kocher 2016-12-29 16:28:36 -08:00
Родитель 2319d2881d
Коммит 26a1ba5c14
65 изменённых файлов: 314 добавлений и 278 удалений

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

@ -541,9 +541,8 @@ DarwinGamepadService::StartupInternal()
void DarwinGamepadService::Startup()
{
Unused << NS_NewNamedThread("Gamepad",
getter_AddRefs(mMonitorThread),
new DarwinGamepadServiceStartupRunnable(this));
Unused << NS_NewThread(getter_AddRefs(mMonitorThread),
new DarwinGamepadServiceStartupRunnable(this));
}
void DarwinGamepadService::Shutdown()

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

@ -1065,7 +1065,7 @@ StartGamepadMonitoring()
return;
}
sIsShutdown = false;
NS_NewNamedThread("Gamepad", getter_AddRefs(gMonitorThread));
NS_NewThread(getter_AddRefs(gMonitorThread));
gMonitorThread->Dispatch(new StartWindowsGamepadServiceRunnable(),
NS_DISPATCH_NORMAL);
}

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

@ -5720,11 +5720,6 @@ public:
return mSerialNumber;
}
nsCString GetThreadName() const
{
return nsPrintfCString("IndexedDB #%lu", mSerialNumber);
}
private:
~ThreadRunnable() override;
@ -12576,10 +12571,7 @@ ConnectionPool::ScheduleTransaction(TransactionInfo* aTransactionInfo,
RefPtr<ThreadRunnable> runnable = new ThreadRunnable();
nsCOMPtr<nsIThread> newThread;
nsresult rv =
NS_NewNamedThread(runnable->GetThreadName(),
getter_AddRefs(newThread), runnable);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(NS_NewThread(getter_AddRefs(newThread), runnable))) {
MOZ_ASSERT(newThread);
IDB_DEBUG_LOG(("ConnectionPool created thread %lu",
@ -13292,6 +13284,10 @@ nsresult
ConnectionPool::
ThreadRunnable::Run()
{
#ifdef MOZ_ENABLE_PROFILER_SPS
char stackTopGuess;
#endif // MOZ_ENABLE_PROFILER_SPS
MOZ_ASSERT(!IsOnBackgroundThread());
MOZ_ASSERT(mContinueRunning);
@ -13302,6 +13298,18 @@ ThreadRunnable::Run()
mFirstRun = false;
{
// Scope for the thread name. Both PR_SetCurrentThreadName() and
// profiler_register_thread() copy the string so we don't need to keep it.
const nsPrintfCString threadName("IndexedDB #%lu", mSerialNumber);
PR_SetCurrentThreadName(threadName.get());
#ifdef MOZ_ENABLE_PROFILER_SPS
profiler_register_thread(threadName.get(), &stackTopGuess);
#endif // MOZ_ENABLE_PROFILER_SPS
}
{
// Scope for the profiler label.
PROFILER_LABEL("IndexedDB",
@ -13343,6 +13351,10 @@ ThreadRunnable::Run()
}
}
#ifdef MOZ_ENABLE_PROFILER_SPS
profiler_unregister_thread();
#endif // MOZ_ENABLE_PROFILER_SPS
return NS_OK;
}

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

@ -22,10 +22,9 @@ nsresult FileBlockCache::Open(PRFileDesc* aFD)
}
{
MonitorAutoLock mon(mDataMonitor);
nsresult res = NS_NewNamedThread("FileBlockCache",
getter_AddRefs(mThread),
nullptr,
SharedThreadPool::kStackSize);
nsresult res = NS_NewThread(getter_AddRefs(mThread),
nullptr,
SharedThreadPool::kStackSize);
mIsOpen = NS_SUCCEEDED(res);
return res;
}

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

@ -39,6 +39,19 @@ namespace mozilla {
StaticRefPtr<nsIThreadPool> AsyncCubebTask::sThreadPool;
struct AutoProfilerUnregisterThread
{
// The empty ctor is used to silence a pre-4.8.0 GCC unused variable warning.
AutoProfilerUnregisterThread()
{
}
~AutoProfilerUnregisterThread()
{
profiler_unregister_thread();
}
};
GraphDriver::GraphDriver(MediaStreamGraphImpl* aGraphImpl)
: mIterationStart(0),
mIterationEnd(0),
@ -183,7 +196,9 @@ public:
}
NS_IMETHOD Run() override
{
char aLocal;
STREAM_LOG(LogLevel::Debug, ("Starting system thread"));
profiler_register_thread("MediaStreamGraph", &aLocal);
LIFECYCLE_LOG("Starting a new system driver for graph %p\n",
mDriver->mGraphImpl);
@ -301,6 +316,8 @@ SystemClockDriver::IsFallback()
void
ThreadedDriver::RunThread()
{
AutoProfilerUnregisterThread autoUnregister;
bool stillProcessing = true;
while (stillProcessing) {
mIterationStart = IterationEnd();

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

@ -283,6 +283,8 @@ class MediaRecorder::Session: public nsIObserver,
} else {
// Flush out remaining encoded data.
mSession->Extract(true);
if (mSession->mIsRegisterProfiler)
profiler_unregister_thread();
if (NS_FAILED(NS_DispatchToMainThread(
new DestroyRunnable(mSession)))) {
MOZ_ASSERT(false, "NS_DispatchToMainThread DestroyRunnable failed");
@ -417,6 +419,7 @@ public:
, mTimeSlice(aTimeSlice)
, mStopIssued(false)
, mIsStartEventFired(false)
, mIsRegisterProfiler(false)
, mNeedSessionEndTask(true)
, mSelectedVideoTrackID(TRACK_NONE)
{
@ -604,6 +607,12 @@ private:
MOZ_ASSERT(NS_GetCurrentThread() == mReadThread);
LOG(LogLevel::Debug, ("Session.Extract %p", this));
if (!mIsRegisterProfiler) {
char aLocal;
profiler_register_thread("Media_Encoder", &aLocal);
mIsRegisterProfiler = true;
}
PROFILER_LABEL("MediaRecorder", "Session Extract",
js::ProfileEntry::Category::OTHER);
@ -913,6 +922,8 @@ private:
bool mStopIssued;
// Indicate the session had fire start event. Encoding thread only.
bool mIsStartEventFired;
// The register flag for "Media_Encoder" thread to profiler
bool mIsRegisterProfiler;
// False if the InitEncoder called successfully, ensure the
// ExtractRunnable/DestroyRunnable will end the session.
// Main thread only.

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

@ -375,7 +375,7 @@ ResourceSocketListener::OnSocketAccepted(nsIServerSocket* aServ,
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIThread> thread;
rv = NS_NewNamedThread("ServeResource", getter_AddRefs(thread));
rv = NS_NewThread(getter_AddRefs(thread));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRunnable> event = new ServeResourceEvent(input.get(), output.get(), mServer);

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

@ -44,7 +44,7 @@ public:
void Init() {
nsCOMPtr<nsIThread> thread;
nsCOMPtr<nsIRunnable> r = NewRunnableMethod(this, &TestBinding::ReadMetadata);
nsresult rv = NS_NewNamedThread("ReadMetadata", getter_AddRefs(thread), r);
nsresult rv = NS_NewThread(getter_AddRefs(thread), r);
EXPECT_EQ(NS_OK, rv);
thread->Shutdown();
}

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

@ -28,7 +28,6 @@
#include "HRTFDatabaseLoader.h"
#include "HRTFDatabase.h"
#include "GeckoProfiler.h"
using namespace mozilla;
@ -152,7 +151,6 @@ void HRTFDatabaseLoader::MainThreadRelease()
// Asynchronously load the database in this thread.
static void databaseLoaderEntry(void* threadData)
{
AutoProfilerRegister registerThread("HRTFDatabaseLdr");
PR_SetCurrentThreadName("HRTFDatabaseLdr");
HRTFDatabaseLoader* loader = reinterpret_cast<HRTFDatabaseLoader*>(threadData);

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

@ -122,6 +122,8 @@ public:
NS_IMETHODIMP
AudioRunnable::Run()
{
PR_SetCurrentThreadName("Android Audio");
JNIEnv* const jenv = mozilla::jni::GetEnvForThread();
mozilla::AutoLocalJNIFrame autoFrame(jenv, 2);
@ -319,7 +321,7 @@ anp_audio_start(ANPAudioTrack* s)
RefPtr<AudioRunnable> runnable = new AudioRunnable(s);
nsCOMPtr<nsIThread> thread;
NS_NewNamedThread("Android Audio", getter_AddRefs(thread), runnable);
NS_NewThread(getter_AddRefs(thread), runnable);
}
void

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

@ -27,7 +27,6 @@
#include "mozilla/IOInterposer.h"
#include "mozilla/Services.h"
#include "mozilla/Tokenizer.h"
#include "GeckoProfiler.h"
// How long we collect write oprerations
// before they are flushed to the database
@ -338,7 +337,6 @@ DOMStorageDBThread::SetDefaultPriority()
void
DOMStorageDBThread::ThreadFunc(void* aArg)
{
AutoProfilerRegister registerThread("localStorage DB");
PR_SetCurrentThreadName("localStorage DB");
mozilla::IOInterposer::RegisterCurrentThread();

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

@ -556,7 +556,7 @@ GonkGPSGeolocationProvider::Startup()
}
if (!mInitThread) {
nsresult rv = NS_NewNamedThread("Gonk GPS", getter_AddRefs(mInitThread));
nsresult rv = NS_NewThread(getter_AddRefs(mInitThread));
NS_ENSURE_SUCCESS(rv, rv);
}

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

@ -1569,7 +1569,7 @@ LayerScopeWebSocketManager::SocketHandler::CloseConnection()
LayerScopeWebSocketManager::LayerScopeWebSocketManager()
: mHandlerMutex("LayerScopeWebSocketManager::mHandlerMutex")
{
NS_NewNamedThread("LayerScope", getter_AddRefs(mDebugSenderThread));
NS_NewThread(getter_AddRefs(mDebugSenderThread));
mServerSocket = do_CreateInstance(NS_SERVERSOCKET_CONTRACTID);
int port = gfxPrefs::LayerScopePort();

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

@ -395,7 +395,7 @@ EnsureVibratorThreadInitialized()
sVibratorRunnable = new VibratorRunnable();
nsCOMPtr<nsIThread> thread;
NS_NewNamedThread("Gonk Vibrator", getter_AddRefs(thread), sVibratorRunnable);
NS_NewThread(getter_AddRefs(thread), sVibratorRunnable);
}
} // namespace

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

@ -60,6 +60,14 @@ public:
, mShuttingDown(false)
{ }
/// Initialize the current thread for use by the decode pool.
void InitCurrentThread()
{
MOZ_ASSERT(!NS_IsMainThread());
mThreadNaming.SetThreadPoolName(NS_LITERAL_CSTRING("ImgDecoder"));
}
/// Shut down the provided decode pool thread.
static void ShutdownThread(nsIThread* aThisThread)
{
@ -127,12 +135,6 @@ public:
} while (true);
}
nsresult CreateThread(nsIThread** aThread, nsIRunnable* aInitialEvent)
{
return NS_NewNamedThread(mThreadNaming.GetNextThreadName("ImgDecoder"),
aThread, aInitialEvent);
}
private:
~DecodePoolImpl() { }
@ -164,11 +166,22 @@ public:
NS_IMETHOD Run() override
{
#ifdef MOZ_ENABLE_PROFILER_SPS
char stackBaseGuess; // Need to be the first variable of main loop function.
#endif // MOZ_ENABLE_PROFILER_SPS
MOZ_ASSERT(!NS_IsMainThread());
mImpl->InitCurrentThread();
nsCOMPtr<nsIThread> thisThread;
nsThreadManager::get().GetCurrentThread(getter_AddRefs(thisThread));
#ifdef MOZ_ENABLE_PROFILER_SPS
// InitCurrentThread() has assigned the thread name.
profiler_register_thread(PR_GetThreadName(PR_GetCurrentThread()), &stackBaseGuess);
#endif // MOZ_ENABLE_PROFILER_SPS
do {
Work work = mImpl->PopWork();
switch (work.mType) {
@ -259,7 +272,7 @@ DecodePool::DecodePool()
for (uint32_t i = 0 ; i < limit ; ++i) {
nsCOMPtr<nsIRunnable> worker = new DecodePoolWorker(mImpl);
nsCOMPtr<nsIThread> thread;
nsresult rv = mImpl->CreateThread(getter_AddRefs(thread), worker);
nsresult rv = NS_NewThread(getter_AddRefs(thread), worker);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv) && thread,
"Should successfully create image decoding threads");
mThreads.AppendElement(Move(thread));

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

@ -69,8 +69,7 @@ RunDecodeToSurface(const ImageTestCase& aTestCase)
ASSERT_TRUE(inputStream != nullptr);
nsCOMPtr<nsIThread> thread;
nsresult rv =
NS_NewNamedThread("DecodeToSurface", getter_AddRefs(thread), nullptr);
nsresult rv = NS_NewThread(getter_AddRefs(thread), nullptr);
ASSERT_TRUE(NS_SUCCEEDED(rv));
// We run the DecodeToSurface tests off-main-thread to ensure that

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

@ -153,7 +153,8 @@ void Thread::StopSoon() {
}
void Thread::ThreadMain() {
mozilla::AutoProfilerRegister registerThread(name_.c_str());
char aLocal;
profiler_register_thread(name_.c_str(), &aLocal);
mozilla::IOInterposer::RegisterCurrentThread();
// The message loop for this thread.
@ -185,6 +186,7 @@ void Thread::ThreadMain() {
DCHECK(GetThreadWasQuitProperly());
mozilla::IOInterposer::UnregisterCurrentThread();
profiler_unregister_thread();
#ifdef MOZ_TASK_TRACER
mozilla::tasktracer::FreeTraceInfo();

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

@ -1344,6 +1344,8 @@ ParentImpl::RequestMessageLoopRunnable::Run()
AssertIsInMainProcess();
MOZ_ASSERT(mTargetThread);
char stackBaseGuess;
if (NS_IsMainThread()) {
MOZ_ASSERT(mMessageLoop);
@ -1373,6 +1375,8 @@ ParentImpl::RequestMessageLoopRunnable::Run()
return NS_OK;
}
profiler_register_thread("IPDL Background", &stackBaseGuess);
#ifdef DEBUG
{
bool correctThread;
@ -1410,6 +1414,8 @@ ParentImpl::ShutdownBackgroundThreadRunnable::Run()
// sBackgroundPRThread and we should not modify it here.
sBackgroundPRThread.compareExchange(PR_GetCurrentThread(), nullptr);
profiler_unregister_thread();
return NS_OK;
}

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

@ -1166,7 +1166,6 @@ AutoLockWatchdog::~AutoLockWatchdog()
static void
WatchdogMain(void* arg)
{
mozilla::AutoProfilerRegister registerThread("JS Watchdog");
PR_SetCurrentThreadName("JS Watchdog");
Watchdog* self = static_cast<Watchdog*>(arg);

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

@ -212,9 +212,10 @@ public:
nsrefcnt count = ++mUseCount;
if (count == 1) {
// idle -> in-use
nsresult rv = NS_NewNamedThread(mName, getter_AddRefs(mThread));
nsresult rv = NS_NewThread(getter_AddRefs(mThread));
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv) && mThread,
"Should successfully create mtransport I/O thread");
NS_SetThreadName(mThread, mName);
r_log(LOG_GENERIC,LOG_DEBUG,"Created wrapped SingletonThread %p",
mThread.get());
}

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

@ -152,7 +152,7 @@ BackgroundFileSaver::Init()
rv = NS_GetCurrentThread(getter_AddRefs(mControlThread));
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewNamedThread("BgFileSaver", getter_AddRefs(mWorkerThread));
rv = NS_NewThread(getter_AddRefs(mWorkerThread));
NS_ENSURE_SUCCESS(rv, rv);
sThreadCount++;

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

@ -742,15 +742,27 @@ nsPACMan::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsIChannel *newChannel,
return NS_OK;
}
void
nsPACMan::NamePACThread()
{
MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
PR_SetCurrentThreadName("Proxy Resolution");
}
nsresult
nsPACMan::Init(nsISystemProxySettings *systemProxySettings)
{
mSystemProxySettings = systemProxySettings;
nsresult rv =
NS_NewNamedThread("ProxyResolution", getter_AddRefs(mPACThread));
nsresult rv = NS_NewThread(getter_AddRefs(mPACThread), nullptr);
if (NS_FAILED(rv))
return rv;
return rv;
// don't check return value as it is not a big deal for this to fail.
mPACThread->Dispatch(NewRunnableMethod(this, &nsPACMan::NamePACThread),
nsIEventTarget::DISPATCH_NORMAL);
return NS_OK;
}
} // namespace net

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

@ -214,6 +214,7 @@ private:
void PostProcessPendingQ();
void PostCancelPendingQ(nsresult);
bool ProcessPending();
void NamePACThread();
private:
ProxyAutoConfig mPAC;

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

@ -833,6 +833,11 @@ nsSocketTransportService::MarkTheLastElementOfPendingQueue()
NS_IMETHODIMP
nsSocketTransportService::Run()
{
#ifdef MOZ_ENABLE_PROFILER_SPS
char stackBaseGuess; // Need to be the first variable of main loop function.
profiler_register_thread(PR_GetThreadName(PR_GetCurrentThread()), &stackBaseGuess);
#endif // MOZ_ENABLE_PROFILER_SPS
SOCKET_LOG(("STS thread init %d sockets\n", gMaxCount));
psm::InitializeSSLServerCertVerificationThreads();
@ -1014,6 +1019,10 @@ nsSocketTransportService::Run()
SOCKET_LOG(("STS thread exit\n"));
#ifdef MOZ_ENABLE_PROFILER_SPS
profiler_unregister_thread();
#endif // MOZ_ENABLE_PROFILER_SPS
return NS_OK;
}

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

@ -10,7 +10,6 @@
#include "nsPrintfCString.h"
#include "nsThreadUtils.h"
#include "mozilla/IOInterposer.h"
#include "GeckoProfiler.h"
#ifdef XP_WIN
#include <windows.h>
@ -438,7 +437,6 @@ already_AddRefed<nsIEventTarget> CacheIOThread::Target()
// static
void CacheIOThread::ThreadFunc(void* aClosure)
{
AutoProfilerRegister registerThread("Cache2 I/O");
PR_SetCurrentThreadName("Cache2 I/O");
mozilla::IOInterposer::RegisterCurrentThread();
CacheIOThread* thread = static_cast<CacheIOThread*>(aClosure);

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

@ -29,7 +29,6 @@
#include "nsURLHelper.h"
#include "nsThreadUtils.h"
#include "GetAddrInfo.h"
#include "GeckoProfiler.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/TimeStamp.h"
@ -1436,15 +1435,10 @@ nsHostResolver::SizeOfIncludingThis(MallocSizeOf mallocSizeOf) const
void
nsHostResolver::ThreadFunc(void *arg)
{
char stackTop;
LOG(("DNS lookup thread - starting execution.\n"));
static nsThreadPoolNaming naming;
nsCString name = naming.GetNextThreadName("DNS Resolver");
PR_SetCurrentThreadName(name.BeginReading());
profiler_register_thread(name.BeginReading(), &stackTop);
naming.SetThreadPoolName(NS_LITERAL_CSTRING("DNS Resolver"));
#if defined(RES_RETRY_ON_FAILURE)
nsResState rs;
@ -1515,8 +1509,6 @@ nsHostResolver::ThreadFunc(void *arg)
resolver->mThreadCount--;
NS_RELEASE(resolver);
LOG(("DNS lookup thread - queue empty, thread finished.\n"));
profiler_unregister_thread();
}
nsresult

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

@ -2326,9 +2326,8 @@ DataChannelConnection::SendBlob(uint16_t stream, nsIInputStream *aBlob)
NS_ENSURE_TRUE(channel, 0);
// Spawn a thread to send the data
if (!mInternalIOThread) {
nsresult rv = NS_NewNamedThread("DataChannel IO",
getter_AddRefs(mInternalIOThread));
if (NS_FAILED(rv)) {
nsresult res = NS_NewThread(getter_AddRefs(mInternalIOThread));
if (NS_FAILED(res)) {
return -1;
}
}

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

@ -323,6 +323,8 @@ nsNotifyAddrListener::nextCoalesceWaitTime()
NS_IMETHODIMP
nsNotifyAddrListener::Run()
{
PR_SetCurrentThreadName("Link Monitor");
mStartTime = TimeStamp::Now();
calculateNetworkId();
@ -419,7 +421,7 @@ nsNotifyAddrListener::Init(void)
mCheckEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
NS_ENSURE_TRUE(mCheckEvent, NS_ERROR_OUT_OF_MEMORY);
rv = NS_NewNamedThread("Link Monitor", getter_AddRefs(mThread), this);
rv = NS_NewThread(getter_AddRefs(mThread), this);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;

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

@ -315,7 +315,7 @@ NS_IMPL_ISUPPORTS(FileChannelWorker, nsIRunnable)
////////////////////////////////////////////////////////////////////////////////
void
Test(CreateFun create, const char* name, uint32_t count,
Test(CreateFun create, uint32_t count,
nsIFile* inDirSpec, nsIFile* outDirSpec, uint32_t bufSize)
{
nsresult rv;
@ -375,8 +375,7 @@ Test(CreateFun create, const char* name, uint32_t count,
bufSize);
if (NS_FAILED(rv)) goto done;
rv = NS_NewNamedThread(name, getter_AddRefs(thread),
worker, 0, PR_JOINABLE_THREAD);
rv = NS_NewThread(getter_AddRefs(thread), worker, 0, PR_JOINABLE_THREAD);
if (NS_FAILED(rv)) goto done;
bool inserted = threads.InsertObjectAt(thread, i);
@ -434,44 +433,42 @@ main(int argc, char* argv[])
if (NS_FAILED(rv)) return rv;
CreateFun create = FileChannelWorker::Create;
const char* name = "FileChannelWorker";
Test(create, 1, inDirFile, outDirFile, 16 * 1024);
#if 1
printf("FileChannelWorker *****************************\n");
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
#endif
create = FileSpecWorker::Create;
name = "FileSpecWorker";
printf("FileSpecWorker ********************************\n");
#if 1
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
Test(create, 20, inDirFile, outDirFile, 16 * 1024);
#endif
#if 1
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, name, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
Test(create, 20, inDirFile, outDirFile, 4 * 1024);
#endif
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM

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

@ -84,7 +84,7 @@ NS_IMETHODIMP nsWifiMonitor::StartWatching(nsIWifiListener *aListener)
}
if (!mThread) {
rv = NS_NewNamedThread("Wifi Monitor", getter_AddRefs(mThread), this);
rv = NS_NewThread(getter_AddRefs(mThread), this);
if (NS_FAILED(rv))
return rv;
}
@ -155,6 +155,8 @@ NS_IMETHODIMP nsWifiMonitor::Run()
{
LOG(("@@@@@ wifi monitor run called\n"));
PR_SetCurrentThreadName("Wifi Monitor");
nsresult rv = DoScan();
LOG(("@@@@@ wifi monitor run::doscan complete %x\n", rv));

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

@ -31,13 +31,13 @@ CryptoTask::Dispatch(const nsACString& taskThreadName)
}
// Can't add 'this' as the event to run, since mThread may not be set yet
nsresult rv = NS_NewNamedThread(taskThreadName, getter_AddRefs(mThread),
nullptr,
nsIThreadManager::DEFAULT_STACK_SIZE);
nsresult rv = NS_NewThread(getter_AddRefs(mThread), nullptr,
nsIThreadManager::DEFAULT_STACK_SIZE);
if (NS_FAILED(rv)) {
return rv;
}
NS_SetThreadName(mThread, taskThreadName);
// Note: event must not null out mThread!
return mThread->Dispatch(this, NS_DISPATCH_NORMAL);
}

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

@ -12,7 +12,6 @@
#include "nsNSSShutDown.h"
#include "PSMRunnable.h"
#include "mozilla/DebugOnly.h"
#include "GeckoProfiler.h"
using namespace mozilla;
using namespace mozilla::psm;
@ -115,7 +114,6 @@ nsresult nsKeygenThread::ConsumeResult(
static void nsKeygenThreadRunner(void *arg)
{
AutoProfilerRegister registerThread("Keygen");
PR_SetCurrentThreadName("Keygen");
nsKeygenThread *self = static_cast<nsKeygenThread *>(arg);
self->Run();

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

@ -11,7 +11,6 @@
#include "nsReadableUtils.h"
#include "nsPKCS11Slot.h"
#include "nsProtectedAuthThread.h"
#include "GeckoProfiler.h"
using namespace mozilla;
using namespace mozilla::psm;
@ -20,7 +19,6 @@ NS_IMPL_ISUPPORTS(nsProtectedAuthThread, nsIProtectedAuthThread)
static void nsProtectedAuthThreadRunner(void *arg)
{
AutoProfilerRegister registerThread("Protected Auth");
PR_SetCurrentThreadName("Protected Auth");
nsProtectedAuthThread *self = static_cast<nsProtectedAuthThread *>(arg);

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

@ -10,7 +10,6 @@
#include "nsIObserverService.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "GeckoProfiler.h"
#include "nspr.h"
#include "pk11func.h"
@ -391,7 +390,6 @@ const SECMODModule* SmartCardMonitoringThread::GetModule()
// C-like calling sequence to glue into PR_CreateThread.
void SmartCardMonitoringThread::LaunchExecute(void* arg)
{
AutoProfilerRegister registerThread("SmartCard");
PR_SetCurrentThreadName("SmartCard");
((SmartCardMonitoringThread*)arg)->Execute();

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

@ -36,7 +36,6 @@
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
#include "nsIProtocolHandler.h"
#include "GeckoProfiler.h"
#ifdef IS_BIG_ENDIAN
#define SC_ENDIAN "big"
@ -504,7 +503,6 @@ StartupCache::WaitOnWriteThread()
void
StartupCache::ThreadedWrite(void *aClosure)
{
AutoProfilerRegister registerThread("StartupCache");
PR_SetCurrentThreadName("StartupCache");
mozilla::IOInterposer::RegisterCurrentThread();
/*

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

@ -589,13 +589,14 @@ Connection::getAsyncExecutionTarget()
return nullptr;
if (!mAsyncExecutionThread) {
static nsThreadPoolNaming naming;
nsresult rv = NS_NewNamedThread(naming.GetNextThreadName("mozStorage"),
getter_AddRefs(mAsyncExecutionThread));
nsresult rv = ::NS_NewThread(getter_AddRefs(mAsyncExecutionThread));
if (NS_FAILED(rv)) {
NS_WARNING("Failed to create async thread.");
return nullptr;
}
static nsThreadPoolNaming naming;
naming.SetThreadPoolName(NS_LITERAL_CSTRING("mozStorage"),
mAsyncExecutionThread);
}
#ifdef DEBUG

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

@ -46,7 +46,7 @@ TEST(storage_service_init_background_thread_DeathTest, Test)
do_check_true(event);
nsCOMPtr<nsIThread> thread;
do_check_success(NS_NewNamedThread("StorageService", getter_AddRefs(thread)));
do_check_success(NS_NewThread(getter_AddRefs(thread)));
do_check_success(thread->Dispatch(event, NS_DISPATCH_NORMAL));

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

@ -1253,8 +1253,7 @@ NativeFileWatcherService::Init()
// Start the IO worker thread.
mWorkerIORunnable = new NativeFileWatcherIOTask(completionPort);
nsresult rv = NS_NewNamedThread("FileWatcher IO", getter_AddRefs(mIOThread),
mWorkerIORunnable);
nsresult rv = NS_NewThread(getter_AddRefs(mIOThread), mWorkerIORunnable);
if (NS_FAILED(rv)) {
FILEWATCHERLOG(
"NativeFileWatcherIOTask::Init - Unable to create and dispatch the worker thread (%x).",
@ -1262,6 +1261,9 @@ NativeFileWatcherService::Init()
return rv;
}
// Set the name for the worker thread.
NS_SetThreadName(mIOThread, "FileWatcher IO");
mIOCompletionPort = completionPort.forget();
return NS_OK;

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

@ -32,7 +32,6 @@
#if defined(MOZ_CRASHREPORTER)
#include "nsExceptionHandler.h"
#endif
#include "GeckoProfiler.h"
#if defined(XP_WIN)
#include <windows.h>
@ -125,7 +124,6 @@ struct Options {
void
RunWatchdog(void* arg)
{
AutoProfilerRegister registerThread("Shutdown Hang Terminator");
PR_SetCurrentThreadName("Shutdown Hang Terminator");
// Let's copy and deallocate options, that's one less leak to worry
@ -216,7 +214,6 @@ PRMonitor* gWriteReady = nullptr;
void RunWriter(void* arg)
{
AutoProfilerRegister registerThread("Shutdown Statistics Writer");
PR_SetCurrentThreadName("Shutdown Statistics Writer");
MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(arg);

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

@ -14,8 +14,7 @@ template<typename Function>
void RunTestInNewThread(Function&& aFunction) {
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(mozilla::Forward<Function>(aFunction));
nsCOMPtr<nsIThread> testingThread;
nsresult rv =
NS_NewNamedThread("Testing Thread", getter_AddRefs(testingThread), r);
nsresult rv = NS_NewThread(getter_AddRefs(testingThread), r);
ASSERT_EQ(rv, NS_OK);
testingThread->Shutdown();
}

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

@ -3609,7 +3609,7 @@ InjectCrashReporterIntoProcess(DWORD processID, InjectorCrashCallback* cb)
OOPInit();
if (!sInjectorThread) {
if (NS_FAILED(NS_NewNamedThread("CrashRep Inject", &sInjectorThread)))
if (NS_FAILED(NS_NewThread(&sInjectorThread)))
return;
}

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

@ -205,8 +205,7 @@ IdentityCryptoService::GenerateKeyPair(
nsCOMPtr<nsIRunnable> r = new KeyGenRunnable(keyType, callback);
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewNamedThread("GenerateKeyPair", getter_AddRefs(thread),
r);
nsresult rv = NS_NewThread(getter_AddRefs(thread), r);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -310,7 +309,7 @@ KeyPair::Sign(const nsACString & textToSign,
callback);
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewNamedThread("KeyPair Sign", getter_AddRefs(thread), r);
nsresult rv = NS_NewThread(getter_AddRefs(thread), r);
return rv;
}

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

@ -122,7 +122,6 @@ class EventLoopLagDispatcher : public Runnable
*/
void TracerThread(void *arg)
{
AutoProfilerRegister registerThread("Event Tracer");
PR_SetCurrentThreadName("Event Tracer");
TracerStartClosure* threadArgs = static_cast<TracerStartClosure*>(arg);

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

@ -1246,8 +1246,7 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate)
MOZ_ASSERT(NS_IsMainThread(), "not main thread");
nsCOMPtr<nsIRunnable> r = NewRunnableMethod(this, &nsUpdateProcessor::StartStagedUpdate);
return NS_NewNamedThread("Update Watcher", getter_AddRefs(mProcessWatcher),
r);
return NS_NewThread(getter_AddRefs(mProcessWatcher), r);
}

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

@ -248,14 +248,6 @@ static inline bool profiler_in_privacy_mode() { return false; }
static inline void profiler_log(const char *str) {}
static inline void profiler_log(const char *fmt, va_list args) {}
class AutoProfilerRegister final MOZ_STACK_CLASS
{
AutoProfilerRegister(const char* aName) {}
private:
AutoProfilerRegister(const AutoProfilerRegister&) = delete;
AutoProfilerRegister& operator=(const AutoProfilerRegister&) = delete;
};
#else
#include "GeckoProfilerImpl.h"

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

@ -461,26 +461,6 @@ private:
void* mHandle;
};
/**
* Convenience class to register and unregister a thread with the profiler.
* Needs to be the first object on the stack of the thread.
*/
class MOZ_STACK_CLASS AutoProfilerRegister final
{
public:
explicit AutoProfilerRegister(const char* aName)
{
profiler_register_thread(aName, this);
}
~AutoProfilerRegister()
{
profiler_unregister_thread();
}
private:
AutoProfilerRegister(const AutoProfilerRegister&) = delete;
AutoProfilerRegister& operator=(const AutoProfilerRegister&) = delete;
};
} // namespace mozilla
inline PseudoStack* mozilla_get_pseudo_stack(void)

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

@ -151,7 +151,7 @@ void LSPAnnotate()
nsCOMPtr<nsIThread> thread;
nsCOMPtr<nsIRunnable> runnable =
do_QueryObject(new LSPAnnotationGatherer());
NS_NewNamedThread("LSP Annotate", getter_AddRefs(thread), runnable);
NS_NewThread(getter_AddRefs(thread), runnable);
}
} // namespace crashreporter

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

@ -241,9 +241,7 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
return NS_OK;
nsCOMPtr<nsIRunnable> player = new nsSoundPlayer(this, aSoundAlias);
NS_ENSURE_TRUE(player, NS_ERROR_OUT_OF_MEMORY);
nsresult rv =
NS_NewNamedThread("PlaySystemSound", getter_AddRefs(mPlayerThread),
player);
nsresult rv = NS_NewThread(getter_AddRefs(mPlayerThread), player);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -301,8 +299,7 @@ NS_IMETHODIMP nsSound::PlayEventSound(uint32_t aEventId)
nsCOMPtr<nsIRunnable> player = new nsSoundPlayer(this, sound);
NS_ENSURE_TRUE(player, NS_ERROR_OUT_OF_MEMORY);
nsresult rv =
NS_NewNamedThread("PlayEventSound", getter_AddRefs(mPlayerThread), player);
nsresult rv = NS_NewThread(getter_AddRefs(mPlayerThread), player);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}

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

@ -114,7 +114,6 @@ MainThreadIOLoggerImpl::Init()
/* static */ void
MainThreadIOLoggerImpl::sIOThreadFunc(void* aArg)
{
AutoProfilerRegister registerThread("MainThreadIOLogger");
PR_SetCurrentThreadName("MainThreadIOLogger");
MainThreadIOLoggerImpl* obj = static_cast<MainThreadIOLoggerImpl*>(aArg);
obj->IOThreadFunc();

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

@ -95,16 +95,13 @@ IncrementalRunnable::SetDeadline(TimeStamp aDeadline)
//-----------------------------------------------------------------------------
nsresult
NS_NewNamedThread(const nsACString& aName,
nsIThread** aResult,
nsIRunnable* aEvent,
uint32_t aStackSize)
NS_NewThread(nsIThread** aResult, nsIRunnable* aEvent, uint32_t aStackSize)
{
nsCOMPtr<nsIThread> thread;
#ifdef MOZILLA_INTERNAL_API
nsresult rv =
nsThreadManager::get().nsThreadManager::NewNamedThread(aName, aStackSize,
getter_AddRefs(thread));
nsThreadManager::get().nsThreadManager::NewThread(0, aStackSize,
getter_AddRefs(thread));
#else
nsresult rv;
nsCOMPtr<nsIThreadManager> mgr =
@ -113,7 +110,7 @@ NS_NewNamedThread(const nsACString& aName,
return rv;
}
rv = mgr->NewNamedThread(aName, aStackSize, getter_AddRefs(thread));
rv = mgr->NewThread(0, aStackSize, getter_AddRefs(thread));
#endif
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -131,12 +128,6 @@ NS_NewNamedThread(const nsACString& aName,
return NS_OK;
}
nsresult
NS_NewThread(nsIThread** aResult, nsIRunnable* aEvent, uint32_t aStackSize)
{
return NS_NewNamedThread(NS_LITERAL_CSTRING(""), aResult, aEvent, aStackSize);
}
nsresult
NS_GetCurrentThread(nsIThread** aResult)
{
@ -390,6 +381,56 @@ NS_ProcessNextEvent(nsIThread* aThread, bool aMayWait)
return NS_SUCCEEDED(aThread->ProcessNextEvent(aMayWait, &val)) && val;
}
#ifndef XPCOM_GLUE_AVOID_NSPR
namespace {
class nsNameThreadRunnable final : public nsIRunnable
{
~nsNameThreadRunnable() {}
public:
explicit nsNameThreadRunnable(const nsACString& aName) : mName(aName) {}
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIRUNNABLE
protected:
const nsCString mName;
};
NS_IMPL_ISUPPORTS(nsNameThreadRunnable, nsIRunnable)
NS_IMETHODIMP
nsNameThreadRunnable::Run()
{
PR_SetCurrentThreadName(mName.BeginReading());
return NS_OK;
}
} // namespace
void
NS_SetThreadName(nsIThread* aThread, const nsACString& aName)
{
if (!aThread) {
return;
}
aThread->Dispatch(new nsNameThreadRunnable(aName),
nsIEventTarget::DISPATCH_NORMAL);
}
#else // !XPCOM_GLUE_AVOID_NSPR
void
NS_SetThreadName(nsIThread* aThread, const nsACString& aName)
{
// No NSPR, no love.
}
#endif
#ifdef MOZILLA_INTERNAL_API
nsIThread*
NS_GetCurrentThread()
@ -399,13 +440,23 @@ NS_GetCurrentThread()
#endif
// nsThreadPoolNaming
nsCString
nsThreadPoolNaming::GetNextThreadName(const nsACString& aPoolName)
void
nsThreadPoolNaming::SetThreadPoolName(const nsACString& aPoolName,
nsIThread* aThread)
{
nsCString name(aPoolName);
name.AppendLiteral(" #");
name.AppendInt(++mCounter, 10); // The counter is declared as atomic
return name;
name.AppendInt(++mCounter, 10); // The counter is declared as volatile
if (aThread) {
// Set on the target thread
NS_SetThreadName(aThread, name);
} else {
// Set on the current thread
#ifndef XPCOM_GLUE_AVOID_NSPR
PR_SetCurrentThreadName(name.BeginReading());
#endif
}
}
// nsAutoLowPriorityIO

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

@ -32,6 +32,24 @@
// These methods are alternatives to the methods on nsIThreadManager, provided
// for convenience.
/**
* Set name of the target thread. This operation is asynchronous.
*/
extern void NS_SetThreadName(nsIThread* aThread, const nsACString& aName);
/**
* Static length version of the above function checking length of the
* name at compile time.
*/
template<size_t LEN>
inline void
NS_SetThreadName(nsIThread* aThread, const char (&aName)[LEN])
{
static_assert(LEN <= 16,
"Thread name must be no more than 16 characters");
NS_SetThreadName(aThread, nsDependentCString(aName));
}
/**
* Create a new thread, and optionally provide an initial event for the thread.
*
@ -53,12 +71,6 @@ NS_NewThread(nsIThread** aResult,
/**
* Creates a named thread, otherwise the same as NS_NewThread
*/
extern nsresult
NS_NewNamedThread(const nsACString& aName,
nsIThread** aResult,
nsIRunnable* aInitialEvent = nullptr,
uint32_t aStackSize = nsIThreadManager::DEFAULT_STACK_SIZE);
template<size_t LEN>
inline nsresult
NS_NewNamedThread(const char (&aName)[LEN],
@ -66,10 +78,21 @@ NS_NewNamedThread(const char (&aName)[LEN],
nsIRunnable* aInitialEvent = nullptr,
uint32_t aStackSize = nsIThreadManager::DEFAULT_STACK_SIZE)
{
static_assert(LEN <= 16,
"Thread name must be no more than 16 characters");
return NS_NewNamedThread(nsDependentCString(aName, LEN - 1),
aResult, aInitialEvent, aStackSize);
// Hold a ref while dispatching the initial event to match NS_NewThread()
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewThread(getter_AddRefs(thread), nullptr, aStackSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
NS_SetThreadName<LEN>(thread, aName);
if (aInitialEvent) {
rv = thread->Dispatch(aInitialEvent, NS_DISPATCH_NORMAL);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Initial event dispatch failed");
}
*aResult = nullptr;
thread.swap(*aResult);
return rv;
}
/**
@ -1003,15 +1026,12 @@ public:
nsThreadPoolNaming() : mCounter(0) {}
/**
* Returns a thread name as "<aPoolName> #<n>" and increments the counter.
* Creates and sets next thread name as "<aPoolName> #<n>"
* on the specified thread. If no thread is specified (aThread
* is null) then the name is synchronously set on the current thread.
*/
nsCString GetNextThreadName(const nsACString& aPoolName);
template<size_t LEN>
nsCString GetNextThreadName(const char (&aPoolName)[LEN])
{
return GetNextThreadName(nsDependentCString(aPoolName, LEN - 1));
}
void SetThreadPoolName(const nsACString& aPoolName,
nsIThread* aThread = nullptr);
private:
mozilla::Atomic<uint32_t> mCounter;

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

@ -107,7 +107,7 @@ TestPipe(nsIInputStream* in, nsIOutputStream* out)
nsresult rv;
nsCOMPtr<nsIThread> thread;
rv = NS_NewNamedThread("TestPipe", getter_AddRefs(thread), receiver);
rv = NS_NewThread(getter_AddRefs(thread), receiver);
if (NS_FAILED(rv)) return rv;
uint32_t total = 0;
@ -225,8 +225,7 @@ TestShortWrites(nsIInputStream* in, nsIOutputStream* out)
nsresult rv;
nsCOMPtr<nsIThread> thread;
rv = NS_NewNamedThread("TestShortWrites", getter_AddRefs(thread),
receiver);
rv = NS_NewThread(getter_AddRefs(thread), receiver);
if (NS_FAILED(rv)) return rv;
uint32_t total = 0;
@ -331,15 +330,14 @@ TEST(Pipes, ChainedPipes)
if (pump == nullptr) return;
nsCOMPtr<nsIThread> thread;
rv = NS_NewNamedThread("ChainedPipePump", getter_AddRefs(thread), pump);
rv = NS_NewThread(getter_AddRefs(thread), pump);
if (NS_FAILED(rv)) return;
RefPtr<nsReceiver> receiver = new nsReceiver(in2);
if (receiver == nullptr) return;
nsCOMPtr<nsIThread> receiverThread;
rv = NS_NewNamedThread("ChainedPipeRecv", getter_AddRefs(receiverThread),
receiver);
rv = NS_NewThread(getter_AddRefs(receiverThread), receiver);
if (NS_FAILED(rv)) return;
uint32_t total = 0;

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

@ -255,7 +255,7 @@ TEST(RacingServiceManager, Test)
// Run the classID test
nsCOMPtr<nsIThread> newThread;
rv = NS_NewNamedThread("RacingServMan", getter_AddRefs(newThread), runnable);
rv = NS_NewThread(getter_AddRefs(newThread), runnable);
ASSERT_TRUE(NS_SUCCEEDED(rv));
{

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

@ -49,7 +49,7 @@ TEST(Threads, Main)
EXPECT_TRUE(event);
nsCOMPtr<nsIThread> runner;
rv = NS_NewNamedThread("TestThreadsMain", getter_AddRefs(runner), event);
rv = NS_NewThread(getter_AddRefs(runner), event);
EXPECT_TRUE(NS_SUCCEEDED(rv));
nsCOMPtr<nsIThread> thread;
@ -112,8 +112,7 @@ TEST(Threads, Stress)
for (k = 0; k < threads; k++) {
nsCOMPtr<nsIThread> t;
nsresult rv = NS_NewNamedThread("StressRunner", getter_AddRefs(t),
new nsStressRunner(k));
nsresult rv = NS_NewThread(getter_AddRefs(t), new nsStressRunner(k));
EXPECT_TRUE(NS_SUCCEEDED(rv));
NS_ADDREF(array[k] = t);
}
@ -170,8 +169,7 @@ public:
{
mozilla::MonitorAutoLock lock(*gBeginAsyncShutdownMonitor);
rv = NS_NewNamedThread("AsyncShutdownPr", getter_AddRefs(t),
new AsyncShutdownPreparer());
rv = NS_NewThread(getter_AddRefs(t), new AsyncShutdownPreparer());
EXPECT_TRUE(NS_SUCCEEDED(rv));
lock.Wait();
@ -223,8 +221,7 @@ TEST(Threads, AsyncShutdown)
{
mozilla::MonitorAutoLock lock(*gAsyncShutdownReadyMonitor);
rv = NS_NewNamedThread("AsyncShutdownWt", getter_AddRefs(t),
new AsyncShutdownWaiter());
rv = NS_NewThread(getter_AddRefs(t), new AsyncShutdownWaiter());
EXPECT_TRUE(NS_SUCCEEDED(rv));
lock.Wait();

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

@ -31,7 +31,7 @@ class AutoTestThread
public:
AutoTestThread() {
nsCOMPtr<nsIThread> newThread;
nsresult rv = NS_NewNamedThread("AutoTestThread", getter_AddRefs(newThread));
nsresult rv = NS_NewThread(getter_AddRefs(newThread));
if (NS_FAILED(rv))
return;

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

@ -22,7 +22,6 @@
#include "nsIObserver.h"
#include "mozilla/Services.h"
#include "nsXULAppAPI.h"
#include "GeckoProfiler.h"
#include <algorithm>
@ -55,7 +54,6 @@ private:
// Background hang monitor thread function
static void MonitorThread(void* aData)
{
AutoProfilerRegister registerThread("BgHangMonitor");
PR_SetCurrentThreadName("BgHangManager");
/* We do not hold a reference to BackgroundHangManager here

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

@ -21,7 +21,6 @@
#endif
#include "nsThreadUtils.h"
#include "nsXULAppAPI.h"
#include "GeckoProfiler.h"
#ifdef MOZ_CRASHREPORTER
#include "nsExceptionHandler.h"
@ -210,7 +209,6 @@ GetChromeHangReport(Telemetry::ProcessedStack& aStack,
void
ThreadMain(void*)
{
AutoProfilerRegister registerThread("Hang Monitor");
PR_SetCurrentThreadName("Hang Monitor");
MonitorAutoLock lock(*gMonitor);

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

@ -169,7 +169,7 @@ LazyIdleThread::EnsureThread()
return NS_ERROR_UNEXPECTED;
}
rv = NS_NewNamedThread("Lazy Idle", getter_AddRefs(mThread), runnable);
rv = NS_NewThread(getter_AddRefs(mThread), runnable);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -180,6 +180,11 @@ LazyIdleThread::EnsureThread()
void
LazyIdleThread::InitThread()
{
char aLocal;
profiler_register_thread(mName.get(), &aLocal);
PR_SetCurrentThreadName(mName.get());
// Happens on mThread but mThread may not be set yet...
nsCOMPtr<nsIThreadInternal> thread(do_QueryInterface(NS_GetCurrentThread()));
@ -206,6 +211,8 @@ LazyIdleThread::CleanupThread()
MOZ_ASSERT(!mThreadIsShuttingDown, "Shouldn't be true ever!");
mThreadIsShuttingDown = true;
}
profiler_unregister_thread();
}
void

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

@ -323,8 +323,7 @@ TimerThread::Init()
if (mInitInProgress.exchange(true) == false) {
// We hold on to mThread to keep the thread alive.
nsresult rv =
NS_NewNamedThread("Timer Thread", getter_AddRefs(mThread), this);
nsresult rv = NS_NewThread(getter_AddRefs(mThread), this);
if (NS_FAILED(rv)) {
mThread = nullptr;
} else {

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

@ -35,20 +35,6 @@ interface nsIThreadManager : nsISupports
*/
nsIThread newThread(in unsigned long creationFlags, [optional] in unsigned long stackSize);
/**
* Create a new thread (a global, user PRThread) with the specified name.
*
* @param name
* The name of the thread. Passing an empty name is equivalent to
* calling newThread(0, stackSize), i.e. the thread will not be named.
* @param stackSize
* Number of bytes to reserve for the thread's stack.
*
* @returns
* The newly created nsIThread object.
*/
[noscript] nsIThread newNamedThread(in ACString name, [optional] in unsigned long stackSize);
/**
* Get the nsIThread object (if any) corresponding to the given PRThread.
* This method returns null if there is no corresponding nsIThread.

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

@ -25,7 +25,6 @@
#include "nsIObserverService.h"
#include "nsXULAppAPI.h"
#include "mozilla/Services.h"
#include "GeckoProfiler.h"
#include <stdlib.h>
@ -236,13 +235,10 @@ assembleCmdLine(char* const* aArgv, wchar_t** aWideCmdLine, UINT aCodePage)
void
nsProcess::Monitor(void* aArg)
{
char stackBaseGuess;
RefPtr<nsProcess> process = dont_AddRef(static_cast<nsProcess*>(aArg));
if (!process->mBlocking) {
PR_SetCurrentThreadName("RunProcess");
profiler_register_thread("RunProcess", &stackBaseGuess);
}
#if defined(PROCESSMODEL_WINAPI)
@ -308,10 +304,6 @@ nsProcess::Monitor(void* aArg)
} else {
NS_DispatchToMainThread(NewRunnableMethod(process, &nsProcess::ProcessComplete));
}
if (!process->mBlocking) {
profiler_unregister_thread();
}
}
void

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

@ -38,7 +38,6 @@
#include "nsIIncrementalRunnable.h"
#include "nsThreadSyncDispatch.h"
#include "LeakRefPtr.h"
#include "GeckoProfiler.h"
#ifdef MOZ_CRASHREPORTER
#include "nsServiceManagerUtils.h"
@ -433,34 +432,15 @@ SetupCurrentThreadForChaosMode()
}
}
namespace {
struct ThreadInitData {
nsThread* thread;
const nsACString& name;
};
}
/*static*/ void
nsThread::ThreadFunc(void* aArg)
{
using mozilla::ipc::BackgroundChild;
char stackTop;
ThreadInitData* initData = static_cast<ThreadInitData*>(aArg);
nsThread* self = initData->thread; // strong reference
nsThread* self = static_cast<nsThread*>(aArg); // strong reference
self->mThread = PR_GetCurrentThread();
SetupCurrentThreadForChaosMode();
if (initData->name.Length() > 0) {
PR_SetCurrentThreadName(initData->name.BeginReading());
profiler_register_thread(initData->name.BeginReading(), &stackTop);
}
// Inform the ThreadManager
nsThreadManager::get().RegisterCurrentThread(*self);
@ -475,9 +455,6 @@ nsThread::ThreadFunc(void* aArg)
return;
}
}
initData = nullptr; // clear before unblocking nsThread::Init
event->Run(); // unblocks nsThread::Init
event = nullptr;
@ -524,8 +501,6 @@ nsThread::ThreadFunc(void* aArg)
// Inform the threadmanager that this thread is going away
nsThreadManager::get().UnregisterCurrentThread(*self);
profiler_unregister_thread();
// Dispatch shutdown ACK
NotNull<nsThreadShutdownContext*> context =
WrapNotNull(self->mShutdownContext);
@ -653,7 +628,7 @@ nsThread::~nsThread()
}
nsresult
nsThread::Init(const nsACString& aName)
nsThread::Init()
{
// spawn thread and wait until it is fully setup
RefPtr<nsThreadStartupEvent> startup = new nsThreadStartupEvent();
@ -664,10 +639,8 @@ nsThread::Init(const nsACString& aName)
mShutdownRequired = true;
ThreadInitData initData = { this, aName };
// ThreadFunc is responsible for setting mThread
if (!PR_CreateThread(PR_USER_THREAD, ThreadFunc, &initData,
if (!PR_CreateThread(PR_USER_THREAD, ThreadFunc, this,
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
PR_JOINABLE_THREAD, mStackSize)) {
NS_RELEASE_THIS();

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

@ -48,8 +48,8 @@ public:
nsThread(MainThreadFlag aMainThread, uint32_t aStackSize);
// Initialize this as a wrapper for a new PRThread, and optionally give it a name.
nsresult Init(const nsACString& aName = NS_LITERAL_CSTRING(""));
// Initialize this as a wrapper for a new PRThread.
nsresult Init();
// Initialize this as a wrapper for the current PRThread.
nsresult InitCurrentThread();

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

@ -248,14 +248,6 @@ NS_IMETHODIMP
nsThreadManager::NewThread(uint32_t aCreationFlags,
uint32_t aStackSize,
nsIThread** aResult)
{
return NewNamedThread(NS_LITERAL_CSTRING(""), aStackSize, aResult);
}
NS_IMETHODIMP
nsThreadManager::NewNamedThread(const nsACString& aName,
uint32_t aStackSize,
nsIThread** aResult)
{
// Note: can be called from arbitrary threads
@ -265,7 +257,7 @@ nsThreadManager::NewNamedThread(const nsACString& aName,
}
RefPtr<nsThread> thr = new nsThread(nsThread::NOT_MAIN_THREAD, aStackSize);
nsresult rv = thr->Init(aName); // Note: blocks until the new thread has been set up
nsresult rv = thr->Init(); // Note: blocks until the new thread has been set up
if (NS_FAILED(rv)) {
return rv;
}

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

@ -104,9 +104,8 @@ nsThreadPool::PutEvent(already_AddRefed<nsIRunnable> aEvent, uint32_t aFlags)
}
nsCOMPtr<nsIThread> thread;
nsresult rv = NS_NewNamedThread(mThreadNaming.GetNextThreadName(mName),
getter_AddRefs(thread), nullptr, stackSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
nsThreadManager::get().NewThread(0, stackSize, getter_AddRefs(thread));
if (NS_WARN_IF(!thread)) {
return NS_ERROR_UNEXPECTED;
}
@ -153,6 +152,8 @@ nsThreadPool::ShutdownThread(nsIThread* aThread)
NS_IMETHODIMP
nsThreadPool::Run()
{
mThreadNaming.SetThreadPoolName(mName);
LOG(("THRD-P(%p) enter %s\n", this, mName.BeginReading()));
nsCOMPtr<nsIThread> current;