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

Side by Side Diff: net/android/network_change_notifier_delegate_android.cc

Issue 780293003: [NetInfo] Add MaxBandwidthChanged notification and implement on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@maxbandwidth_android
Patch Set: Don't monitor RSSI if there is no permission to act on it 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 unified diff | Download patch
OLDNEW
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 90
91 void NetworkChangeNotifierDelegateAndroid::NotifyConnectionTypeChanged( 91 void NetworkChangeNotifierDelegateAndroid::NotifyConnectionTypeChanged(
92 JNIEnv* env, 92 JNIEnv* env,
93 jobject obj, 93 jobject obj,
94 jint new_connection_type) { 94 jint new_connection_type) {
95 DCHECK(thread_checker_.CalledOnValidThread()); 95 DCHECK(thread_checker_.CalledOnValidThread());
96 const ConnectionType actual_connection_type = ConvertConnectionType( 96 const ConnectionType actual_connection_type = ConvertConnectionType(
97 new_connection_type); 97 new_connection_type);
98 SetCurrentConnectionType(actual_connection_type); 98 SetCurrentConnectionType(actual_connection_type);
99 SetCurrentMaxBandwidth(Java_NetworkChangeNotifier_getCurrentMaxBandwidth(
100 env, java_network_change_notifier_.obj()));
101 observers_->Notify(&Observer::OnConnectionTypeChanged); 99 observers_->Notify(&Observer::OnConnectionTypeChanged);
102 } 100 }
103 101
104 jint NetworkChangeNotifierDelegateAndroid::GetConnectionType(JNIEnv*, 102 jint NetworkChangeNotifierDelegateAndroid::GetConnectionType(JNIEnv*,
105 jobject) const { 103 jobject) const {
106 DCHECK(thread_checker_.CalledOnValidThread()); 104 DCHECK(thread_checker_.CalledOnValidThread());
107 return GetCurrentConnectionType(); 105 return GetCurrentConnectionType();
108 } 106 }
109 107
108 void NetworkChangeNotifierDelegateAndroid::NotifyMaxBandwidthChanged(
109 JNIEnv* env,
110 jobject obj,
111 jdouble new_max_bandwidth) {
112 DCHECK(thread_checker_.CalledOnValidThread());
113 DCHECK(new_max_bandwidth != connection_max_bandwidth_);
pauljensen 2014/12/11 16:13:57 I think this is missing the lock; shouldn't it cal
jkarlin 2014/12/15 19:43:55 Done. Thanks!
114 SetCurrentMaxBandwidth(new_max_bandwidth);
115 observers_->Notify(&Observer::OnMaxBandwidthChanged, new_max_bandwidth);
116 }
117
110 void NetworkChangeNotifierDelegateAndroid::AddObserver( 118 void NetworkChangeNotifierDelegateAndroid::AddObserver(
111 Observer* observer) { 119 Observer* observer) {
112 observers_->AddObserver(observer); 120 observers_->AddObserver(observer);
113 } 121 }
114 122
115 void NetworkChangeNotifierDelegateAndroid::RemoveObserver( 123 void NetworkChangeNotifierDelegateAndroid::RemoveObserver(
116 Observer* observer) { 124 Observer* observer) {
117 observers_->RemoveObserver(observer); 125 observers_->RemoveObserver(observer);
118 } 126 }
119 127
(...skipping 18 matching lines...) Expand all
138 JNIEnv* env = base::android::AttachCurrentThread(); 146 JNIEnv* env = base::android::AttachCurrentThread();
139 Java_NetworkChangeNotifier_forceConnectivityState(env, true); 147 Java_NetworkChangeNotifier_forceConnectivityState(env, true);
140 } 148 }
141 149
142 void NetworkChangeNotifierDelegateAndroid::SetOffline() { 150 void NetworkChangeNotifierDelegateAndroid::SetOffline() {
143 JNIEnv* env = base::android::AttachCurrentThread(); 151 JNIEnv* env = base::android::AttachCurrentThread();
144 Java_NetworkChangeNotifier_forceConnectivityState(env, false); 152 Java_NetworkChangeNotifier_forceConnectivityState(env, false);
145 } 153 }
146 154
147 } // namespace net 155 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698