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

Unified Diff: net/android/network_change_notifier_delegate_android.cc

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « net/android/network_change_notifier_delegate_android.h ('k') | net/base/dns_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/android/network_change_notifier_delegate_android.cc
diff --git a/net/android/network_change_notifier_delegate_android.cc b/net/android/network_change_notifier_delegate_android.cc
index fbbaceddd948b73c460d471081b8f0735e462c03..a6a71322586998df43233ff8ffb12faa13ce48b0 100644
--- a/net/android/network_change_notifier_delegate_android.cc
+++ b/net/android/network_change_notifier_delegate_android.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "jni/NetworkChangeNotifier_jni.h"
+#include "net/android/network_change_notifier_android.h"
namespace net {
@@ -32,8 +33,24 @@ NetworkChangeNotifier::ConnectionType ConvertConnectionType(
return static_cast<NetworkChangeNotifier::ConnectionType>(connection_type);
}
+// Converts a Java side connection type (integer) to
+// the native side NetworkChangeNotifier::ConnectionType.
+NetworkChangeNotifier::ConnectionSubtype ConvertConnectionSubtype(
+ jint subtype) {
+ DCHECK(subtype >= 0 && subtype <= NetworkChangeNotifier::SUBTYPE_LAST);
+
+ return static_cast<NetworkChangeNotifier::ConnectionSubtype>(subtype);
+}
+
} // namespace
+jdouble GetMaxBandwidthForConnectionSubtype(JNIEnv* env,
+ jclass caller,
+ jint subtype) {
+ return NetworkChangeNotifierAndroid::GetMaxBandwidthForConnectionSubtype(
+ ConvertConnectionSubtype(subtype));
+}
+
NetworkChangeNotifierDelegateAndroid::NetworkChangeNotifierDelegateAndroid()
: observers_(new ObserverListThreadSafe<Observer>()) {
JNIEnv* env = base::android::AttachCurrentThread();
@@ -47,6 +64,8 @@ NetworkChangeNotifierDelegateAndroid::NetworkChangeNotifierDelegateAndroid()
ConvertConnectionType(
Java_NetworkChangeNotifier_getCurrentConnectionType(
env, java_network_change_notifier_.obj())));
+ SetCurrentMaxBandwidth(Java_NetworkChangeNotifier_getCurrentMaxBandwidth(
+ env, java_network_change_notifier_.obj()));
}
NetworkChangeNotifierDelegateAndroid::~NetworkChangeNotifierDelegateAndroid() {
@@ -60,10 +79,15 @@ NetworkChangeNotifierDelegateAndroid::~NetworkChangeNotifierDelegateAndroid() {
NetworkChangeNotifier::ConnectionType
NetworkChangeNotifierDelegateAndroid::GetCurrentConnectionType() const {
- base::AutoLock auto_lock(connection_type_lock_);
+ base::AutoLock auto_lock(connection_lock_);
return connection_type_;
}
+double NetworkChangeNotifierDelegateAndroid::GetCurrentMaxBandwidth() const {
+ base::AutoLock auto_lock(connection_lock_);
+ return connection_max_bandwidth_;
+}
+
void NetworkChangeNotifierDelegateAndroid::NotifyConnectionTypeChanged(
JNIEnv* env,
jobject obj,
@@ -72,6 +96,8 @@ void NetworkChangeNotifierDelegateAndroid::NotifyConnectionTypeChanged(
const ConnectionType actual_connection_type = ConvertConnectionType(
new_connection_type);
SetCurrentConnectionType(actual_connection_type);
+ SetCurrentMaxBandwidth(Java_NetworkChangeNotifier_getCurrentMaxBandwidth(
+ env, java_network_change_notifier_.obj()));
observers_->Notify(&Observer::OnConnectionTypeChanged);
}
@@ -98,10 +124,16 @@ bool NetworkChangeNotifierDelegateAndroid::Register(JNIEnv* env) {
void NetworkChangeNotifierDelegateAndroid::SetCurrentConnectionType(
ConnectionType new_connection_type) {
- base::AutoLock auto_lock(connection_type_lock_);
+ base::AutoLock auto_lock(connection_lock_);
connection_type_ = new_connection_type;
}
+void NetworkChangeNotifierDelegateAndroid::SetCurrentMaxBandwidth(
+ double max_bandwidth) {
+ base::AutoLock auto_lock(connection_lock_);
+ connection_max_bandwidth_ = max_bandwidth;
+}
+
void NetworkChangeNotifierDelegateAndroid::SetOnline() {
JNIEnv* env = base::android::AttachCurrentThread();
Java_NetworkChangeNotifier_forceConnectivityState(env, true);
« no previous file with comments | « net/android/network_change_notifier_delegate_android.h ('k') | net/base/dns_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698