1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/DebuggerOnGCRunnable.h"
12 #include "mozilla/CycleCollectedJSContext.h"
13 #include "mozilla/dom/ScriptSettings.h"
14 #include "mozilla/SchedulerGroup.h"
19 nsresult
DebuggerOnGCRunnable::Enqueue(JSContext
* aCx
,
20 const JS::GCDescription
& aDesc
) {
21 auto gcEvent
= aDesc
.toGCEvent(aCx
);
23 return NS_ERROR_OUT_OF_MEMORY
;
26 RefPtr
<DebuggerOnGCRunnable
> runOnGC
=
27 new DebuggerOnGCRunnable(std::move(gcEvent
));
28 if (NS_IsMainThread()) {
29 return SchedulerGroup::Dispatch(TaskCategory::GarbageCollection
,
32 return NS_DispatchToCurrentThread(runOnGC
);
37 DebuggerOnGCRunnable::Run() {
40 if (!JS::dbg::FireOnGarbageCollectionHook(jsapi
.cx(), std::move(mGCData
))) {
41 return NS_ERROR_OUT_OF_MEMORY
;
46 nsresult
DebuggerOnGCRunnable::Cancel() {
51 } // namespace mozilla