Bug 1744025: Use CheckedUnsafePtr<WorkerPrivate> in WorkerDebugger. r=dom-worker-reviewers,asuth

Depends on D132710

Differential Revision: https://phabricator.services.mozilla.com/D132711
This commit is contained in:
Jens Stutte 2022-01-25 08:53:01 +00:00
parent d444f5a050
commit bd254a0698
2 changed files with 8 additions and 7 deletions

View File

@ -4,8 +4,6 @@
* 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/. */
#include "WorkerDebugger.h"
#include "mozilla/dom/BrowsingContext.h"
#include "mozilla/dom/MessageEvent.h"
#include "mozilla/dom/MessageEventBinding.h"
@ -18,9 +16,9 @@
#include "ScriptLoader.h"
#include "WorkerCommon.h"
#include "WorkerError.h"
#include "WorkerPrivate.h"
#include "WorkerRunnable.h"
#include "WorkerScope.h"
#include "WorkerDebugger.h"
#if defined(XP_WIN)
# include <processthreadsapi.h> // for GetCurrentProcessId()
#else
@ -548,8 +546,10 @@ RefPtr<PerformanceInfoPromise> WorkerDebugger::ReportPerformanceInfo() {
}
// We need to keep a ref on workerPrivate, passed to the promise,
// to make sure it's still aloive when collecting the info.
RefPtr<WorkerPrivate> workerRef = mWorkerPrivate;
// to make sure it's still aloive when collecting the info
// (and CheckedUnsafePtr does not convert directly to RefPtr).
WorkerPrivate* workerPtr = mWorkerPrivate;
RefPtr<WorkerPrivate> workerRef = workerPtr;
RefPtr<AbstractThread> mainThread = AbstractThread::MainThread();
return CollectMemoryInfo(top, mainThread)

View File

@ -8,6 +8,7 @@
#define mozilla_dom_workers_WorkerDebugger_h
#include "mozilla/PerformanceTypes.h"
#include "mozilla/dom/WorkerScope.h"
#include "nsCOMPtr.h"
#include "nsIWorkerDebugger.h"
@ -24,7 +25,7 @@ class WorkerDebugger : public nsIWorkerDebugger {
class ReportDebuggerErrorRunnable;
class PostDebuggerMessageRunnable;
WorkerPrivate* mWorkerPrivate;
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
bool mIsInitialized;
nsTArray<nsCOMPtr<nsIWorkerDebuggerListener>> mListeners;