| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/android/network_change_notifier_android.h" | 5 #include "net/android/network_change_notifier_android.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "jni/network_change_notifier_jni.h" | 9 #include "jni/network_change_notifier_jni.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 void NetworkChangeNotifier::CreateJavaObject(JNIEnv* env) { | 25 void NetworkChangeNotifier::CreateJavaObject(JNIEnv* env) { |
| 26 java_network_change_notifier_.Reset( | 26 java_network_change_notifier_.Reset( |
| 27 Java_NetworkChangeNotifier_create( | 27 Java_NetworkChangeNotifier_create( |
| 28 env, | 28 env, |
| 29 base::android::GetApplicationContext(), | 29 base::android::GetApplicationContext(), |
| 30 reinterpret_cast<jint>(this))); | 30 reinterpret_cast<jint>(this))); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void NetworkChangeNotifier::NotifyObservers(JNIEnv* env, jobject obj) { | 33 void NetworkChangeNotifier::NotifyObservers(JNIEnv* env, jobject obj) { |
| 34 NotifyObserversOfOnlineStateChange(); | 34 NotifyObserversOfConnectionTypeChange(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool NetworkChangeNotifier::IsCurrentlyOffline() const { | 37 net::NetworkChangeNotifier::ConnectionType |
| 38 NetworkChangeNotifier::GetCurrentConnectionType() const { |
| 38 JNIEnv* env = base::android::AttachCurrentThread(); | 39 JNIEnv* env = base::android::AttachCurrentThread(); |
| 39 return !Java_NetworkChangeNotifier_isConnected( | 40 // TODO(droger): Return something more detailed than CONNECTION_UNKNOWN. |
| 40 env, java_network_change_notifier_.obj()); | 41 return Java_NetworkChangeNotifier_isConnected( |
| 42 env, java_network_change_notifier_.obj()) ? |
| 43 net::NetworkChangeNotifier::CONNECTION_UNKNOWN : |
| 44 net::NetworkChangeNotifier::CONNECTION_NONE; |
| 41 } | 45 } |
| 42 | 46 |
| 43 // static | 47 // static |
| 44 bool NetworkChangeNotifier::Register(JNIEnv* env) { | 48 bool NetworkChangeNotifier::Register(JNIEnv* env) { |
| 45 return RegisterNativesImpl(env); | 49 return RegisterNativesImpl(env); |
| 46 } | 50 } |
| 47 | 51 |
| 48 } // namespace android | 52 } // namespace android |
| 49 } // namespace net | 53 } // namespace net |
| OLD | NEW |