mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1456608 - Add GeckoThread.crash() and GeckoProcessManager.crashChild() r=esawin,droeh
MozReview-Commit-ID: DYvoeNDKjY0
This commit is contained in:
parent
bae31b8761
commit
2d2a861611
@ -15,4 +15,6 @@ interface IChildProcess {
|
||||
in ParcelFileDescriptor prefsPfd, in ParcelFileDescriptor ipcPfd,
|
||||
in ParcelFileDescriptor crashReporterPfd,
|
||||
in ParcelFileDescriptor crashAnnotationPfd);
|
||||
|
||||
void crash();
|
||||
}
|
||||
|
@ -647,6 +647,9 @@ public class GeckoThread extends Thread {
|
||||
@WrapForJNI(dispatchTo = "gecko")
|
||||
public static native void forceQuit();
|
||||
|
||||
@WrapForJNI(dispatchTo = "gecko")
|
||||
public static native void crash();
|
||||
|
||||
@WrapForJNI
|
||||
private static void requestUiThreadCallback(long delay) {
|
||||
ThreadUtils.getUiHandler().postDelayed(UI_THREAD_CALLBACK, delay);
|
||||
|
@ -167,6 +167,13 @@ public final class GeckoProcessManager extends IProcessManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
public void crashChild() {
|
||||
try {
|
||||
mConnections.get("tab").bind().crash();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
private static int start(final String type, final String[] args,
|
||||
final int prefsFd, final int ipcFd,
|
||||
|
@ -91,6 +91,11 @@ public class GeckoServiceChildProcess extends Service {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void crash() {
|
||||
GeckoThread.crash();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -222,12 +222,16 @@ template<class Impl>
|
||||
class GeckoThread::Natives : public mozilla::jni::NativeImpl<GeckoThread, Impl>
|
||||
{
|
||||
public:
|
||||
static const JNINativeMethod methods[7];
|
||||
static const JNINativeMethod methods[8];
|
||||
};
|
||||
|
||||
template<class Impl>
|
||||
const JNINativeMethod GeckoThread::Natives<Impl>::methods[] = {
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoThread::Crash_t>(
|
||||
mozilla::jni::NativeStub<GeckoThread::Crash_t, Impl>
|
||||
::template Wrap<&Impl::Crash>),
|
||||
|
||||
mozilla::jni::MakeNativeMethod<GeckoThread::ForceQuit_t>(
|
||||
mozilla::jni::NativeStub<GeckoThread::ForceQuit_t, Impl>
|
||||
::template Wrap<&Impl::ForceQuit>),
|
||||
|
@ -755,6 +755,9 @@ auto GeckoThread::CheckAndSetState(mozilla::jni::Object::Param a0, mozilla::jni:
|
||||
return mozilla::jni::Method<CheckAndSetState_t>::Call(GeckoThread::Context(), nullptr, a0, a1);
|
||||
}
|
||||
|
||||
constexpr char GeckoThread::Crash_t::name[];
|
||||
constexpr char GeckoThread::Crash_t::signature[];
|
||||
|
||||
constexpr char GeckoThread::ForceQuit_t::name[];
|
||||
constexpr char GeckoThread::ForceQuit_t::signature[];
|
||||
|
||||
|
@ -2260,6 +2260,23 @@ public:
|
||||
|
||||
static auto CheckAndSetState(mozilla::jni::Object::Param, mozilla::jni::Object::Param) -> bool;
|
||||
|
||||
struct Crash_t {
|
||||
typedef GeckoThread Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "crash";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
static const mozilla::jni::CallingThread callingThread =
|
||||
mozilla::jni::CallingThread::ANY;
|
||||
static const mozilla::jni::DispatchTarget dispatchTarget =
|
||||
mozilla::jni::DispatchTarget::GECKO;
|
||||
};
|
||||
|
||||
struct ForceQuit_t {
|
||||
typedef GeckoThread Owner;
|
||||
typedef void ReturnType;
|
||||
|
@ -251,6 +251,12 @@ public:
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void Crash()
|
||||
{
|
||||
printf_stderr("Intentionally crashing...\n");
|
||||
MOZ_CRASH("intentional crash");
|
||||
}
|
||||
};
|
||||
|
||||
int32_t GeckoThreadSupport::sPauseCount;
|
||||
@ -401,6 +407,7 @@ nsAppShell::nsAppShell()
|
||||
if (!XRE_IsParentProcess()) {
|
||||
if (jni::IsAvailable()) {
|
||||
GeckoAppShellSupport::Init();
|
||||
GeckoThreadSupport::Init();
|
||||
|
||||
// Set the corresponding state in GeckoThread.
|
||||
java::GeckoThread::SetState(java::GeckoThread::State::RUNNING());
|
||||
|
Loading…
Reference in New Issue
Block a user