Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: net/android/network_change_notifier_android.cc

Issue 10928193: Add native-side unit test for Android NetworkChangeNotifier (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebasing Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 473fa644eca3a15a2904577f4f2df9087c0f5f70..66aacaf1a8edc68402fe0ff6aeaa0313415a1989 100644
--- a/net/android/network_change_notifier_android.cc
+++ b/net/android/network_change_notifier_android.cc
@@ -9,33 +9,35 @@
#include "jni/NetworkChangeNotifier_jni.h"
namespace net {
-namespace android {
-NetworkChangeNotifier::NetworkChangeNotifier() {
+NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid() {
JNIEnv* env = base::android::AttachCurrentThread();
- CreateJavaObject(env);
+ java_network_change_notifier_.Reset(
+ Java_NetworkChangeNotifier_createInstance(
+ env,
+ base::android::GetApplicationContext(),
+ reinterpret_cast<jint>(this)));
}
-NetworkChangeNotifier::~NetworkChangeNotifier() {
+NetworkChangeNotifierAndroid::~NetworkChangeNotifierAndroid() {
JNIEnv* env = base::android::AttachCurrentThread();
- Java_NetworkChangeNotifier_destroy(
- env, java_network_change_notifier_.obj());
+ Java_NetworkChangeNotifier_destroyInstance(env);
+ java_network_change_notifier_.Reset();
}
-void NetworkChangeNotifier::CreateJavaObject(JNIEnv* env) {
- java_network_change_notifier_.Reset(
- Java_NetworkChangeNotifier_create(
- env,
- base::android::GetApplicationContext(),
- reinterpret_cast<jint>(this)));
+void NetworkChangeNotifierAndroid::NotifyObserversOfConnectionTypeChange(
+ JNIEnv* env,
+ jobject obj) {
+ NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange();
}
-void NetworkChangeNotifier::NotifyObservers(JNIEnv* env, jobject obj) {
- NotifyObserversOfConnectionTypeChange();
+void NetworkChangeNotifierAndroid::ForceConnectivityState(bool state) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_NetworkChangeNotifier_forceConnectivityState(env, state);
}
-net::NetworkChangeNotifier::ConnectionType
- NetworkChangeNotifier::GetCurrentConnectionType() const {
+NetworkChangeNotifier::ConnectionType
+ NetworkChangeNotifierAndroid::GetCurrentConnectionType() const {
JNIEnv* env = base::android::AttachCurrentThread();
// Pull the connection type from the Java-side then convert it to a
@@ -64,9 +66,8 @@ net::NetworkChangeNotifier::ConnectionType
}
// static
-bool NetworkChangeNotifier::Register(JNIEnv* env) {
+bool NetworkChangeNotifierAndroid::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
-} // namespace android
} // namespace net
« no previous file with comments | « net/android/network_change_notifier_android.h ('k') | net/android/network_change_notifier_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698