Bug 1932613 - temporarily disable browser_ml_end_to_end.js for permanent failures...
[gecko.git] / xpcom / base / DebuggerOnGCRunnable.cpp
blobf8415dc3d82bf592f03aa89baec903ddcc73ba63
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"
9 #include <utility>
11 #include "js/Debug.h"
12 #include "mozilla/CycleCollectedJSContext.h"
13 #include "mozilla/dom/ScriptSettings.h"
14 #include "mozilla/SchedulerGroup.h"
16 namespace mozilla {
18 /* static */
19 nsresult DebuggerOnGCRunnable::Enqueue(JSContext* aCx,
20 const JS::GCDescription& aDesc) {
21 auto gcEvent = aDesc.toGCEvent(aCx);
22 if (!gcEvent) {
23 return NS_ERROR_OUT_OF_MEMORY;
26 RefPtr<DebuggerOnGCRunnable> runOnGC =
27 new DebuggerOnGCRunnable(std::move(gcEvent));
28 return NS_DispatchToCurrentThread(runOnGC);
31 NS_IMETHODIMP
32 DebuggerOnGCRunnable::Run() {
33 dom::AutoJSAPI jsapi;
34 jsapi.Init();
35 if (!JS::dbg::FireOnGarbageCollectionHook(jsapi.cx(), std::move(mGCData))) {
36 return NS_ERROR_OUT_OF_MEMORY;
38 return NS_OK;
41 nsresult DebuggerOnGCRunnable::Cancel() {
42 mGCData = nullptr;
43 return NS_OK;
46 } // namespace mozilla