| 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_delegate_android.h" | 5 #include "net/android/network_change_notifier_delegate_android.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "jni/NetworkChangeNotifier_jni.h" | 8 #include "jni/NetworkChangeNotifier_jni.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // Converts a Java side connection type (integer) to | 14 // Converts a Java side connection type (integer) to |
| 15 // the native side NetworkChangeNotifier::ConnectionType. | 15 // the native side NetworkChangeNotifier::ConnectionType. |
| 16 NetworkChangeNotifier::ConnectionType ConvertConnectionType( | 16 NetworkChangeNotifier::ConnectionType ConvertConnectionType( |
| 17 jint connection_type) { | 17 jint connection_type) { |
| 18 switch (connection_type) { | 18 switch (connection_type) { |
| 19 case NetworkChangeNotifier::CONNECTION_UNKNOWN: | 19 case NetworkChangeNotifier::CONNECTION_UNKNOWN: |
| 20 case NetworkChangeNotifier::CONNECTION_ETHERNET: | 20 case NetworkChangeNotifier::CONNECTION_ETHERNET: |
| 21 case NetworkChangeNotifier::CONNECTION_WIFI: | 21 case NetworkChangeNotifier::CONNECTION_WIFI: |
| 22 case NetworkChangeNotifier::CONNECTION_2G: | 22 case NetworkChangeNotifier::CONNECTION_2G: |
| 23 case NetworkChangeNotifier::CONNECTION_3G: | 23 case NetworkChangeNotifier::CONNECTION_3G: |
| 24 case NetworkChangeNotifier::CONNECTION_4G: | 24 case NetworkChangeNotifier::CONNECTION_4G: |
| 25 case NetworkChangeNotifier::CONNECTION_NONE: | 25 case NetworkChangeNotifier::CONNECTION_NONE: |
| 26 case NetworkChangeNotifier::CONNECTION_BLUETOOTH: |
| 26 break; | 27 break; |
| 27 default: | 28 default: |
| 28 NOTREACHED() << "Unknown connection type received: " << connection_type; | 29 NOTREACHED() << "Unknown connection type received: " << connection_type; |
| 29 return NetworkChangeNotifier::CONNECTION_UNKNOWN; | 30 return NetworkChangeNotifier::CONNECTION_UNKNOWN; |
| 30 } | 31 } |
| 31 return static_cast<NetworkChangeNotifier::ConnectionType>(connection_type); | 32 return static_cast<NetworkChangeNotifier::ConnectionType>(connection_type); |
| 32 } | 33 } |
| 33 | 34 |
| 34 } // namespace | 35 } // namespace |
| 35 | 36 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 JNIEnv* env = base::android::AttachCurrentThread(); | 106 JNIEnv* env = base::android::AttachCurrentThread(); |
| 106 Java_NetworkChangeNotifier_forceConnectivityState(env, true); | 107 Java_NetworkChangeNotifier_forceConnectivityState(env, true); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void NetworkChangeNotifierDelegateAndroid::SetOffline() { | 110 void NetworkChangeNotifierDelegateAndroid::SetOffline() { |
| 110 JNIEnv* env = base::android::AttachCurrentThread(); | 111 JNIEnv* env = base::android::AttachCurrentThread(); |
| 111 Java_NetworkChangeNotifier_forceConnectivityState(env, false); | 112 Java_NetworkChangeNotifier_forceConnectivityState(env, false); |
| 112 } | 113 } |
| 113 | 114 |
| 114 } // namespace net | 115 } // namespace net |
| OLD | NEW |