| 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 #include "net/android/network_change_notifier_android.h" | 9 #include "net/android/network_change_notifier_android.h" |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 void NetworkChangeNotifierDelegateAndroid::NotifyConnectionTypeChanged( | 92 void NetworkChangeNotifierDelegateAndroid::NotifyConnectionTypeChanged( |
| 93 JNIEnv* env, | 93 JNIEnv* env, |
| 94 jobject obj, | 94 jobject obj, |
| 95 jint new_connection_type) { | 95 jint new_connection_type) { |
| 96 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
| 97 const ConnectionType actual_connection_type = ConvertConnectionType( | 97 const ConnectionType actual_connection_type = ConvertConnectionType( |
| 98 new_connection_type); | 98 new_connection_type); |
| 99 SetCurrentConnectionType(actual_connection_type); | 99 SetCurrentConnectionType(actual_connection_type); |
| 100 observers_->Notify(&Observer::OnConnectionTypeChanged); | 100 observers_->Notify(FROM_HERE, &Observer::OnConnectionTypeChanged); |
| 101 } | 101 } |
| 102 | 102 |
| 103 jint NetworkChangeNotifierDelegateAndroid::GetConnectionType(JNIEnv*, | 103 jint NetworkChangeNotifierDelegateAndroid::GetConnectionType(JNIEnv*, |
| 104 jobject) const { | 104 jobject) const { |
| 105 DCHECK(thread_checker_.CalledOnValidThread()); | 105 DCHECK(thread_checker_.CalledOnValidThread()); |
| 106 return GetCurrentConnectionType(); | 106 return GetCurrentConnectionType(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void NetworkChangeNotifierDelegateAndroid::NotifyMaxBandwidthChanged( | 109 void NetworkChangeNotifierDelegateAndroid::NotifyMaxBandwidthChanged( |
| 110 JNIEnv* env, | 110 JNIEnv* env, |
| 111 jobject obj, | 111 jobject obj, |
| 112 jdouble new_max_bandwidth) { | 112 jdouble new_max_bandwidth) { |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); | 113 DCHECK(thread_checker_.CalledOnValidThread()); |
| 114 DCHECK(new_max_bandwidth != GetCurrentMaxBandwidth()); | 114 DCHECK(new_max_bandwidth != GetCurrentMaxBandwidth()); |
| 115 SetCurrentMaxBandwidth(new_max_bandwidth); | 115 SetCurrentMaxBandwidth(new_max_bandwidth); |
| 116 observers_->Notify(&Observer::OnMaxBandwidthChanged, new_max_bandwidth); | 116 observers_->Notify(FROM_HERE, &Observer::OnMaxBandwidthChanged, |
| 117 new_max_bandwidth); |
| 117 } | 118 } |
| 118 | 119 |
| 119 void NetworkChangeNotifierDelegateAndroid::AddObserver( | 120 void NetworkChangeNotifierDelegateAndroid::AddObserver( |
| 120 Observer* observer) { | 121 Observer* observer) { |
| 121 observers_->AddObserver(observer); | 122 observers_->AddObserver(observer); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void NetworkChangeNotifierDelegateAndroid::RemoveObserver( | 125 void NetworkChangeNotifierDelegateAndroid::RemoveObserver( |
| 125 Observer* observer) { | 126 Observer* observer) { |
| 126 observers_->RemoveObserver(observer); | 127 observers_->RemoveObserver(observer); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 147 JNIEnv* env = base::android::AttachCurrentThread(); | 148 JNIEnv* env = base::android::AttachCurrentThread(); |
| 148 Java_NetworkChangeNotifier_forceConnectivityState(env, true); | 149 Java_NetworkChangeNotifier_forceConnectivityState(env, true); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void NetworkChangeNotifierDelegateAndroid::SetOffline() { | 152 void NetworkChangeNotifierDelegateAndroid::SetOffline() { |
| 152 JNIEnv* env = base::android::AttachCurrentThread(); | 153 JNIEnv* env = base::android::AttachCurrentThread(); |
| 153 Java_NetworkChangeNotifier_forceConnectivityState(env, false); | 154 Java_NetworkChangeNotifier_forceConnectivityState(env, false); |
| 154 } | 155 } |
| 155 | 156 |
| 156 } // namespace net | 157 } // namespace net |
| OLD | NEW |