If a C++ class implements native calls that all return void, it can
choose to have those calls go through a custom proxy function by
inheriting from mozilla::jni::UsesNativeCallProxy and override the
ProxyNativeCall member.
ProxyNativeCall accepts a rvalue reference to a
functor object specific to each call, and can alter the calling
environment (e.g. dispatch the call to another thread) before issuing
the actual native call through the functor's operator().
Any JNI refs contained in the call are automatically turned into global
refs so that the call can continue to work outside of the original JNI
call.
Native call proxy will be used to implement automatic dispatching of
native calls from the main thread to run on the Gecko thread.
This patch fixes a compile error when using WeakPtr, where Impl* was
expected but SupportsWeakPtr<Impl>* was given.
This patch also fixes a compile error when using the DisposeNative
implementation provided by the autogenerated Natives class. e.g.,
> struct Foo : Bar::Natives<Foo> {
> using Bar::Natives<Foo>::DisposeNative;
> };
This uses a default implementation of DisposeNative instead of a custom
implementation, and resulted in a compile error that this patch fixes.
The mangled name of a NativeStubImpl instantiation is longer than
necessary because of the ReturnType arg. This patch turns it into a bool
parameter. It also reorders the parameters for cleanness.
Add more constructors in LocalRef and GlobalRef to accommodate use cases
where a JNIEnv is already available for performance reasons. Also add
more null-checks when creating references for performance reasons.
One thing we do in the Fennec CLH is to make a speculative connection
based on the URI that's passed in. However, by the time the CLH runs,
we're far along into startup, and the advantage of a speculative
connection is reduced. This patch implements making speculative
connection as a method in GeckoThread, so that Fennec can make a
speculative connection without relying on the Fennec CLH.
Many Gecko operations depend on the profile being available. This
patch adds a PROFILE_READY Gecko state so that we can queue calls
until profile is loaded.
clang doesn't like it when we declare things as a struct in one place
and a class in another. This change makes all the current usages
consistent and clang happy.
GeneratedJNIWrappers.h was updated in bug 1192079 to use inherited
constructors, which is a gcc 4.8 feature. Many people are still using an
older version of NDK which only comes with gcc 4.7.
First we need to set the Gecko thread JNIEnv* in nsAndroidStartup, but
after that we can initialize and deinitialize the rest of JNI, including
AndroidBridge, in GeckoAppShell. This makes nsAppShell control the
AndroidBridge lifetime. Over time, parts of the AndroidBridge
functionality will be migrated to nsAppShell.
Merge all the init code into AndroidBridge constructor and
AndroidBridge::ConstructBridge; merge all the deinit code into
AndroidBridge destructor and AndroidBridge::DeconstructBridge.
In particular, the SetMainThread call is obsolete and removed.
Make NativeJSContainer/NativeJSObject Java objects own their
corresponding C++ objects directly, to reduce an extra
allocation/deallocation for each object and to simplify code.
Add a direct ownership model where the Java object owns the
corresponding C++ object directly, in addition to the WeakPtr model
where the Java object owns a WeakPtr to the C++ object. The WeakPtr
model is chosen when the implementing C++ class inherits from
SupportsWeakPtr. Otherwise, the direct ownership model is chosen. Under
the direct ownership model, a UniquePtr object must be used to attach
the containing C++ object to a Java object, to ensure ownership is
passed on to the Java object.
This patch adds:
* Conversion operator from String::Param to String::LocalRef.
* More overloads of the jni::ThrowException function.
* name members to built-in types like jni::Object, jni::String, etc.
This allows using jni::Accessors::EnsureClassRef on built-in types
to get built-in class refs (e.g. jclass for java/lang/String).
* Ability to implicitly convert LocalRef<Cls> to LocalRef<Object>
* Fixes for bugs in LocalRef/GlobalRef where new refs are not created.
* Fixes for inaccurate uses of mozilla::Forward in favor of mozilla::Move