Bug 1192082 - Expose GeckoThread states to C++; r=me

This commit is contained in:
Jim Chen 2015-08-13 00:53:39 -04:00
parent 38ecea75c0
commit f9b719335b
3 changed files with 407 additions and 0 deletions

View File

@ -37,6 +37,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class GeckoThread extends Thread implements GeckoEventListener {
private static final String LOGTAG = "GeckoThread";
@WrapForJNI
public enum State {
// After being loaded by class loader.
INITIAL,
@ -478,6 +479,7 @@ public class GeckoThread extends Thread implements GeckoEventListener {
return sState.get().isBetween(minState, maxState);
}
@WrapForJNI
private static void setState(final State newState) {
ThreadUtils.assertOnGeckoThread();
sState.set(newState);

View File

@ -765,6 +765,128 @@ auto GeckoThread::PumpMessageLoop(mozilla::jni::Object::Param a0) -> bool
return mozilla::jni::Method<PumpMessageLoop_t>::Call(nullptr, nullptr, a0);
}
constexpr char GeckoThread::SetState_t::name[];
constexpr char GeckoThread::SetState_t::signature[];
auto GeckoThread::SetState(mozilla::jni::Object::Param a0) -> void
{
return mozilla::jni::Method<SetState_t>::Call(nullptr, nullptr, a0);
}
constexpr char GeckoThread::State::name[];
constexpr char GeckoThread::State::New_t::name[];
constexpr char GeckoThread::State::New_t::signature[];
auto GeckoThread::State::New(mozilla::jni::String::Param a0, int32_t a1) -> State::LocalRef
{
return mozilla::jni::Constructor<New_t>::Call(nullptr, nullptr, a0, a1);
}
constexpr char GeckoThread::State::Is_t::name[];
constexpr char GeckoThread::State::Is_t::signature[];
auto GeckoThread::State::Is(State::Param a0) const -> bool
{
return mozilla::jni::Method<Is_t>::Call(this, nullptr, a0);
}
constexpr char GeckoThread::State::IsAtLeast_t::name[];
constexpr char GeckoThread::State::IsAtLeast_t::signature[];
auto GeckoThread::State::IsAtLeast(State::Param a0) const -> bool
{
return mozilla::jni::Method<IsAtLeast_t>::Call(this, nullptr, a0);
}
constexpr char GeckoThread::State::IsAtMost_t::name[];
constexpr char GeckoThread::State::IsAtMost_t::signature[];
auto GeckoThread::State::IsAtMost(State::Param a0) const -> bool
{
return mozilla::jni::Method<IsAtMost_t>::Call(this, nullptr, a0);
}
constexpr char GeckoThread::State::IsBetween_t::name[];
constexpr char GeckoThread::State::IsBetween_t::signature[];
auto GeckoThread::State::IsBetween(State::Param a0, State::Param a1) const -> bool
{
return mozilla::jni::Method<IsBetween_t>::Call(this, nullptr, a0, a1);
}
constexpr char GeckoThread::State::ValueOf_t::name[];
constexpr char GeckoThread::State::ValueOf_t::signature[];
auto GeckoThread::State::ValueOf(mozilla::jni::String::Param a0) -> State::LocalRef
{
return mozilla::jni::Method<ValueOf_t>::Call(nullptr, nullptr, a0);
}
constexpr char GeckoThread::State::Values_t::name[];
constexpr char GeckoThread::State::Values_t::signature[];
auto GeckoThread::State::Values() -> mozilla::jni::ObjectArray::LocalRef
{
return mozilla::jni::Method<Values_t>::Call(nullptr, nullptr);
}
constexpr char GeckoThread::State::EXITED_t::name[];
constexpr char GeckoThread::State::EXITED_t::signature[];
auto GeckoThread::State::EXITED() -> State::LocalRef
{
return mozilla::jni::Field<EXITED_t>::Get(nullptr, nullptr);
}
constexpr char GeckoThread::State::EXITING_t::name[];
constexpr char GeckoThread::State::EXITING_t::signature[];
auto GeckoThread::State::EXITING() -> State::LocalRef
{
return mozilla::jni::Field<EXITING_t>::Get(nullptr, nullptr);
}
constexpr char GeckoThread::State::INITIAL_t::name[];
constexpr char GeckoThread::State::INITIAL_t::signature[];
auto GeckoThread::State::INITIAL() -> State::LocalRef
{
return mozilla::jni::Field<INITIAL_t>::Get(nullptr, nullptr);
}
constexpr char GeckoThread::State::LAUNCHED_t::name[];
constexpr char GeckoThread::State::LAUNCHED_t::signature[];
auto GeckoThread::State::LAUNCHED() -> State::LocalRef
{
return mozilla::jni::Field<LAUNCHED_t>::Get(nullptr, nullptr);
}
constexpr char GeckoThread::State::LIBS_READY_t::name[];
constexpr char GeckoThread::State::LIBS_READY_t::signature[];
auto GeckoThread::State::LIBS_READY() -> State::LocalRef
{
return mozilla::jni::Field<LIBS_READY_t>::Get(nullptr, nullptr);
}
constexpr char GeckoThread::State::MOZGLUE_READY_t::name[];
constexpr char GeckoThread::State::MOZGLUE_READY_t::signature[];
auto GeckoThread::State::MOZGLUE_READY() -> State::LocalRef
{
return mozilla::jni::Field<MOZGLUE_READY_t>::Get(nullptr, nullptr);
}
constexpr char GeckoThread::State::RUNNING_t::name[];
constexpr char GeckoThread::State::RUNNING_t::signature[];
auto GeckoThread::State::RUNNING() -> State::LocalRef
{
return mozilla::jni::Field<RUNNING_t>::Get(nullptr, nullptr);
}
constexpr char RestrictedProfiles::name[];
constexpr char RestrictedProfiles::IsAllowed_t::name[];

View File

@ -1800,6 +1800,9 @@ public:
protected:
using Class::Class;
public:
class State;
public:
struct PumpMessageLoop_t {
typedef GeckoThread Owner;
@ -1818,6 +1821,286 @@ public:
static auto PumpMessageLoop(mozilla::jni::Object::Param) -> bool;
public:
struct SetState_t {
typedef GeckoThread Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
mozilla::jni::Object::Param> Args;
static constexpr char name[] = "setState";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/GeckoThread$State;)V";
static const bool isStatic = true;
static const bool isMultithreaded = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto SetState(mozilla::jni::Object::Param) -> void;
};
class GeckoThread::State : public mozilla::jni::Class<State>
{
public:
typedef mozilla::jni::Ref<State> Ref;
typedef mozilla::jni::LocalRef<State> LocalRef;
typedef mozilla::jni::GlobalRef<State> GlobalRef;
typedef const mozilla::jni::Param<State>& Param;
static constexpr char name[] =
"org/mozilla/gecko/GeckoThread$State";
protected:
using Class::Class;
public:
struct New_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<
mozilla::jni::String::Param,
int32_t> Args;
static constexpr char name[] = "<init>";
static constexpr char signature[] =
"(Ljava/lang/String;I)V";
static const bool isStatic = false;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto New(mozilla::jni::String::Param, int32_t) -> State::LocalRef;
public:
struct Is_t {
typedef State Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<
State::Param> Args;
static constexpr char name[] = "is";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/GeckoThread$State;)Z";
static const bool isStatic = false;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
auto Is(State::Param) const -> bool;
public:
struct IsAtLeast_t {
typedef State Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<
State::Param> Args;
static constexpr char name[] = "isAtLeast";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/GeckoThread$State;)Z";
static const bool isStatic = false;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
auto IsAtLeast(State::Param) const -> bool;
public:
struct IsAtMost_t {
typedef State Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<
State::Param> Args;
static constexpr char name[] = "isAtMost";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/GeckoThread$State;)Z";
static const bool isStatic = false;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
auto IsAtMost(State::Param) const -> bool;
public:
struct IsBetween_t {
typedef State Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<
State::Param,
State::Param> Args;
static constexpr char name[] = "isBetween";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/GeckoThread$State;Lorg/mozilla/gecko/GeckoThread$State;)Z";
static const bool isStatic = false;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
auto IsBetween(State::Param, State::Param) const -> bool;
public:
struct ValueOf_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<
mozilla::jni::String::Param> Args;
static constexpr char name[] = "valueOf";
static constexpr char signature[] =
"(Ljava/lang/String;)Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto ValueOf(mozilla::jni::String::Param) -> State::LocalRef;
public:
struct Values_t {
typedef State Owner;
typedef mozilla::jni::ObjectArray::LocalRef ReturnType;
typedef mozilla::jni::ObjectArray::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "values";
static constexpr char signature[] =
"()[Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto Values() -> mozilla::jni::ObjectArray::LocalRef;
public:
struct EXITED_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "EXITED";
static constexpr char signature[] =
"Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto EXITED() -> State::LocalRef;
public:
struct EXITING_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "EXITING";
static constexpr char signature[] =
"Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto EXITING() -> State::LocalRef;
public:
struct INITIAL_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "INITIAL";
static constexpr char signature[] =
"Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto INITIAL() -> State::LocalRef;
public:
struct LAUNCHED_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "LAUNCHED";
static constexpr char signature[] =
"Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto LAUNCHED() -> State::LocalRef;
public:
struct LIBS_READY_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "LIBS_READY";
static constexpr char signature[] =
"Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto LIBS_READY() -> State::LocalRef;
public:
struct MOZGLUE_READY_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "MOZGLUE_READY";
static constexpr char signature[] =
"Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto MOZGLUE_READY() -> State::LocalRef;
public:
struct RUNNING_t {
typedef State Owner;
typedef State::LocalRef ReturnType;
typedef State::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "RUNNING";
static constexpr char signature[] =
"Lorg/mozilla/gecko/GeckoThread$State;";
static const bool isStatic = true;
static const bool isMultithreaded = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto RUNNING() -> State::LocalRef;
};
class RestrictedProfiles : public mozilla::jni::Class<RestrictedProfiles>