Provide NetworkChangeNotifierAndroid with the actual initial connection type.

The Android NetworkChangeNotifier is initialized with connection_type =
CONNECTION_UNKNOWN.
This means that the result returned by NetworkChangeNotifier::IsOffline() is
inaccurate until the first network change happens.
This can happen for the whole initialization path if the user starts Chrome
after he explicitly disabled WiFi and 3G.

This CL updates NetworkChangeNotifier.java to support multiple native
observers. This can happen in case NetworkChangeNotifierDelegateAndroid is
instantiated multiple times (e.g. when multiple factories are instantiated).

Still on the Java side, NetworkChangeNotifier.java was also changed to fetch
the actual connection type as soon as the auto-detector (interacting with the
Android platform) is enabled.

On the native side, NetworkChangeNotifierDelegateAndroid now fetches at
construction time the current connection type from the Java side singleton
through a direct JNI function call (possible since the delegate is constructed
on the JNI thread).
NetworkChangeNotifierAndroid::GetCurrentConnectionType() is now a simple
wrapper around the delegate's GetCurrentConnectionType() method (which is
thread-safe).

BUG=166883

Review URL: https://codereview.chromium.org/11628008

git-svn-id: http://src.chromium.org/svn/trunk/src/build@175138 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
pliard@chromium.org 2013-01-04 12:34:34 +00:00
Родитель 50abe55900
Коммит b9c3847550
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -100,7 +100,7 @@ M M IS: Inconsistent synchronization of org.chromium.content.browser.SandboxedPr
M M LI: Incorrect lazy initialization and update of static field org.chromium.base.SystemMonitor.sInstance in org.chromium.base.SystemMonitor.create(Context) At SystemMonitor.java
M M LI: Incorrect lazy initialization and update of static field org.chromium.content.browser.ContentVideoView.sContentVideoView in org.chromium.content.browser.ContentVideoView.createContentVideoView(int) At ContentVideoView.java
M M LI: Incorrect lazy initialization and update of static field org.chromium.net.test.util.TestWebServer.sReasons in org.chromium.net.test.util.TestWebServer.createResponse(int) At TestWebServer.java
M M LI: Incorrect lazy initialization of static field org.chromium.net.NetworkChangeNotifier.sInstance in org.chromium.net.NetworkChangeNotifier.createInstance(Context, int) At NetworkChangeNotifier.java
M M LI: Incorrect lazy initialization of static field org.chromium.net.NetworkChangeNotifier.sInstance in org.chromium.net.NetworkChangeNotifier.init(Context) At NetworkChangeNotifier.java
M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getBooleanValue() is unsynchronized, org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.setBooleanValue(boolean) is synchronized At JavaBridgeReturnValuesTest.java
M M UG: org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.getStringValue() is unsynchronized, org.chromium.content.browser.JavaBridgeReturnValuesTest$TestObject.setStringValue(String) is synchronized At JavaBridgeReturnValuesTest.java
M P SIC: Should org.chromium.android_webview.test.TestAwContentsClient$AddMessageToConsoleHelper be a _static_ inner class? At TestAwContentsClient.java