/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
if (!gWorkerDebuggerManager) { // The observer service now owns us until shutdown.
gWorkerDebuggerManager = new WorkerDebuggerManager(); if (NS_SUCCEEDED(gWorkerDebuggerManager->Init())) {
ClearOnShutdown(&gWorkerDebuggerManager);
} else {
NS_WARNING("Failed to initialize worker debugger manager!");
gWorkerDebuggerManager = nullptr;
}
}
if (NS_IsMainThread()) { // When the parent thread is the main thread, it will always block until all // register liseners have been called, since it cannot continue until the // call to RegisterDebuggerMainThread returns. // // In this case, it is always safe to notify all listeners on the main // thread, even if there were no listeners at the time this method was // called, so we can always pass true for the value of aNotifyListeners. // This avoids having to lock mMutex to check whether mListeners is empty.
RegisterDebuggerMainThread(aWorkerPrivate, true);
} else { // We guarantee that if any register listeners are called, the worker does // not start running until all register listeners have been called. To // guarantee this, the parent thread should block until all register // listeners have been called. // // However, to avoid overhead when the debugger is not being used, the // parent thread will only block if there were any listeners at the time // this method was called. As a result, we should not notify any listeners // on the main thread if there were no listeners at the time this method was // called, because the parent will not be blocking in that case. bool hasListeners = false;
{
MutexAutoLock lock(mMutex);
hasListeners = !mListeners.IsEmpty();
}
nsCOMPtr<nsIRunnable> runnable = new RegisterDebuggerMainThreadRunnable(aWorkerPrivate, hasListeners);
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL));
if (hasListeners) {
aWorkerPrivate->WaitForIsDebuggerRegistered(true);
}
}
}
// There is nothing to do here if the debugger was never succesfully // registered. We need to check this on the main thread because the worker // does not wait for the registration to complete if there were no listeners // installed when it started. if (!aWorkerPrivate->IsDebuggerRegistered()) { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.