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

Unified Diff: net/android/network_change_notifier_delegate_android.cc

Issue 11628008: Provide NetworkChangeNotifierAndroid with the actual initial connection type. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make NCNA fetch the connection type through NCNDA Created 8 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
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 91b0cb0465e65c7a7513b5a2fc80a1aa090231b8..f92441c82ba4317d9795a34aacae81735d52ae43 100644
--- a/net/android/network_change_notifier_delegate_android.cc
+++ b/net/android/network_change_notifier_delegate_android.cc
@@ -32,6 +32,7 @@ bool CheckConnectionType(int connection_type) {
NetworkChangeNotifierDelegateAndroid::NetworkChangeNotifierDelegateAndroid()
: observers_(new ObserverListThreadSafe<Observer>()) {
+ SetConnectionType(NetworkChangeNotifier::CONNECTION_UNKNOWN);
java_network_change_notifier_.Reset(
Java_NetworkChangeNotifier_createInstance(
base::android::AttachCurrentThread(),
@@ -51,15 +52,22 @@ void NetworkChangeNotifierDelegateAndroid::NotifyConnectionTypeChanged(
jobject obj,
jint new_connection_type) {
DCHECK(thread_checker_.CalledOnValidThread());
- connection_type_ = CheckConnectionType(new_connection_type) ?
- static_cast<ConnectionType>(new_connection_type) :
- NetworkChangeNotifier::CONNECTION_UNKNOWN;
+ SetConnectionType(
+ CheckConnectionType(new_connection_type) ?
+ static_cast<ConnectionType>(new_connection_type) :
+ NetworkChangeNotifier::CONNECTION_UNKNOWN);
observers_->Notify(&Observer::OnConnectionTypeChanged, connection_type_);
}
jint NetworkChangeNotifierDelegateAndroid::GetConnectionType(JNIEnv*,
jobject) const {
DCHECK(thread_checker_.CalledOnValidThread());
+ return GetCurrentConnectionType();
+}
+
+NetworkChangeNotifierDelegateAndroid::ConnectionType
+NetworkChangeNotifierDelegateAndroid::GetCurrentConnectionType() const {
+ base::AutoLock auto_lock(connection_type_lock_);
return connection_type_;
}
@@ -85,4 +93,10 @@ bool NetworkChangeNotifierDelegateAndroid::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
+void NetworkChangeNotifierDelegateAndroid::SetConnectionType(
+ ConnectionType new_connection_type) {
+ base::AutoLock auto_lock(connection_type_lock_);
+ connection_type_ = new_connection_type;
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698