2020-11-17 19:13:58 +00:00
|
|
|
// Copyright (c) 2020 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_BASE_CONVERTER_H_
|
|
|
|
#define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_BASE_CONVERTER_H_
|
2020-11-17 19:13:58 +00:00
|
|
|
|
|
|
|
#include "base/process/kill.h"
|
|
|
|
#include "gin/converter.h"
|
2023-11-28 21:40:12 +00:00
|
|
|
#include "shell/common/gin_converters/std_converter.h"
|
2020-11-17 19:13:58 +00:00
|
|
|
|
|
|
|
namespace gin {
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct Converter<base::TerminationStatus> {
|
|
|
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
|
|
|
const base::TerminationStatus& status) {
|
|
|
|
switch (status) {
|
|
|
|
case base::TERMINATION_STATUS_NORMAL_TERMINATION:
|
|
|
|
return gin::ConvertToV8(isolate, "clean-exit");
|
|
|
|
case base::TERMINATION_STATUS_ABNORMAL_TERMINATION:
|
|
|
|
return gin::ConvertToV8(isolate, "abnormal-exit");
|
|
|
|
case base::TERMINATION_STATUS_PROCESS_WAS_KILLED:
|
|
|
|
return gin::ConvertToV8(isolate, "killed");
|
|
|
|
case base::TERMINATION_STATUS_PROCESS_CRASHED:
|
|
|
|
return gin::ConvertToV8(isolate, "crashed");
|
|
|
|
case base::TERMINATION_STATUS_STILL_RUNNING:
|
|
|
|
return gin::ConvertToV8(isolate, "still-running");
|
|
|
|
case base::TERMINATION_STATUS_LAUNCH_FAILED:
|
|
|
|
return gin::ConvertToV8(isolate, "launch-failed");
|
|
|
|
case base::TERMINATION_STATUS_OOM:
|
|
|
|
return gin::ConvertToV8(isolate, "oom");
|
2022-02-10 02:58:52 +00:00
|
|
|
#if BUILDFLAG(IS_WIN)
|
2020-11-17 19:13:58 +00:00
|
|
|
case base::TERMINATION_STATUS_INTEGRITY_FAILURE:
|
|
|
|
return gin::ConvertToV8(isolate, "integrity-failure");
|
|
|
|
#endif
|
|
|
|
case base::TERMINATION_STATUS_MAX_ENUM:
|
|
|
|
NOTREACHED();
|
|
|
|
return gin::ConvertToV8(isolate, "");
|
|
|
|
}
|
|
|
|
NOTREACHED();
|
|
|
|
return gin::ConvertToV8(isolate, "");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gin
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_COMMON_GIN_CONVERTERS_BASE_CONVERTER_H_
|