|
|
Fix potential threading issues in NetworkChangeNotifierAndroid.
NetworkChangeNotifierAndroid's constructor can be called on any thread. It
calls some Java code (still on any thread) initializing a singleton.
This singleton is also accessed from the UI thread on the application side.
While in practice it didn't seem to be a problem it seems safer to perform all
the JNI calls on a single thread (UI thread) to avoid accessing mutable state
from multiple threads.
Another potential issue with the current implementation was that
NetworkChangeNotifierAndroid could be deleted on the network thread while it
was receiving at the same time a notification on the UI thread.
That could have led to a user after free.
This CL addresses these two issues by introducing a Delegate who outlives
NetworkChangeNotifierAndroid and defers JNI calls to the UI thread.
|