| Index: net/android/network_change_notifier_android.cc
|
| diff --git a/net/android/network_change_notifier_android.cc b/net/android/network_change_notifier_android.cc
|
| index d810a33568c5b050ea221a9957a44dbb2fb04291..b9dc3e9d3ccf81477c8e0e0d87ab254db28c14c1 100644
|
| --- a/net/android/network_change_notifier_android.cc
|
| +++ b/net/android/network_change_notifier_android.cc
|
| @@ -4,49 +4,29 @@
|
|
|
| #include "net/android/network_change_notifier_android.h"
|
|
|
| -#include "base/logging.h"
|
| -#include "base/android/jni_android.h"
|
| -#include "jni/network_change_notifier_jni.h"
|
| -
|
| namespace net {
|
| namespace android {
|
|
|
| -NetworkChangeNotifier::NetworkChangeNotifier() {
|
| - JNIEnv* env = base::android::AttachCurrentThread();
|
| - CreateJavaObject(env);
|
| +NetworkChangeNotifier::NetworkChangeNotifier() : is_connected_(false) {
|
| }
|
|
|
| NetworkChangeNotifier::~NetworkChangeNotifier() {
|
| - JNIEnv* env = base::android::AttachCurrentThread();
|
| - Java_NetworkChangeNotifier_unregisterReceiver(
|
| - env, java_network_change_notifier_.obj());
|
| -}
|
| -
|
| -void NetworkChangeNotifier::CreateJavaObject(JNIEnv* env) {
|
| - java_network_change_notifier_.Reset(
|
| - Java_NetworkChangeNotifier_create(
|
| - env,
|
| - base::android::GetApplicationContext(),
|
| - reinterpret_cast<jint>(this)));
|
| -}
|
| -
|
| -void NetworkChangeNotifier::NotifyObservers(JNIEnv* env, jobject obj) {
|
| - NotifyObserversOfConnectionTypeChange();
|
| }
|
|
|
| net::NetworkChangeNotifier::ConnectionType
|
| NetworkChangeNotifier::GetCurrentConnectionType() const {
|
| - JNIEnv* env = base::android::AttachCurrentThread();
|
| - // TODO(droger): Return something more detailed than CONNECTION_UNKNOWN.
|
| - return Java_NetworkChangeNotifier_isConnected(
|
| - env, java_network_change_notifier_.obj()) ?
|
| - net::NetworkChangeNotifier::CONNECTION_UNKNOWN :
|
| - net::NetworkChangeNotifier::CONNECTION_NONE;
|
| + // TODO(benm): Add support for returning different types of connection here.
|
| + // See crbug.com/112937
|
| + return is_connected_ ?
|
| + net::NetworkChangeNotifier::CONNECTION_UNKNOWN :
|
| + net::NetworkChangeNotifier::CONNECTION_NONE;
|
| }
|
|
|
| -// static
|
| -bool NetworkChangeNotifier::Register(JNIEnv* env) {
|
| - return RegisterNativesImpl(env);
|
| +void NetworkChangeNotifier::setConnected(bool network_up) {
|
| + if (is_connected_ != network_up) {
|
| + is_connected_ = network_up;
|
| + NotifyObserversOfConnectionTypeChange();
|
| + }
|
| }
|
|
|
| } // namespace android
|
|
|