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

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

Issue 2828353002: Android: Remove GetApplicationContext part 3 (Closed)
Patch Set: Fix android webview tests Created 3 years, 8 months 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/android/context_utils.h"
8 #include "base/android/jni_array.h" 7 #include "base/android/jni_array.h"
9 #include "base/logging.h" 8 #include "base/logging.h"
10 #include "jni/NetworkChangeNotifier_jni.h" 9 #include "jni/NetworkChangeNotifier_jni.h"
11 #include "net/android/network_change_notifier_android.h" 10 #include "net/android/network_change_notifier_android.h"
12 11
13 using base::android::JavaParamRef; 12 using base::android::JavaParamRef;
14 using base::android::ScopedJavaLocalRef; 13 using base::android::ScopedJavaLocalRef;
15 14
16 namespace net { 15 namespace net {
17 16
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 jdouble GetMaxBandwidthForConnectionSubtype(JNIEnv* env, 66 jdouble GetMaxBandwidthForConnectionSubtype(JNIEnv* env,
68 const JavaParamRef<jclass>& caller, 67 const JavaParamRef<jclass>& caller,
69 jint subtype) { 68 jint subtype) {
70 return NetworkChangeNotifierAndroid::GetMaxBandwidthForConnectionSubtype( 69 return NetworkChangeNotifierAndroid::GetMaxBandwidthForConnectionSubtype(
71 ConvertConnectionSubtype(subtype)); 70 ConvertConnectionSubtype(subtype));
72 } 71 }
73 72
74 NetworkChangeNotifierDelegateAndroid::NetworkChangeNotifierDelegateAndroid() 73 NetworkChangeNotifierDelegateAndroid::NetworkChangeNotifierDelegateAndroid()
75 : observers_(new base::ObserverListThreadSafe<Observer>()) { 74 : observers_(new base::ObserverListThreadSafe<Observer>()) {
76 JNIEnv* env = base::android::AttachCurrentThread(); 75 JNIEnv* env = base::android::AttachCurrentThread();
77 java_network_change_notifier_.Reset( 76 java_network_change_notifier_.Reset(Java_NetworkChangeNotifier_init(env));
78 Java_NetworkChangeNotifier_init(
79 env, base::android::GetApplicationContext()));
80 Java_NetworkChangeNotifier_addNativeObserver( 77 Java_NetworkChangeNotifier_addNativeObserver(
81 env, java_network_change_notifier_, reinterpret_cast<intptr_t>(this)); 78 env, java_network_change_notifier_, reinterpret_cast<intptr_t>(this));
82 SetCurrentConnectionType( 79 SetCurrentConnectionType(
83 ConvertConnectionType(Java_NetworkChangeNotifier_getCurrentConnectionType( 80 ConvertConnectionType(Java_NetworkChangeNotifier_getCurrentConnectionType(
84 env, java_network_change_notifier_))); 81 env, java_network_change_notifier_)));
85 SetCurrentMaxBandwidth( 82 SetCurrentMaxBandwidth(
86 Java_NetworkChangeNotifier_getCurrentMaxBandwidthInMbps( 83 Java_NetworkChangeNotifier_getCurrentMaxBandwidthInMbps(
87 env, java_network_change_notifier_)); 84 env, java_network_change_notifier_));
88 SetCurrentDefaultNetwork(Java_NetworkChangeNotifier_getCurrentDefaultNetId( 85 SetCurrentDefaultNetwork(Java_NetworkChangeNotifier_getCurrentDefaultNetId(
89 env, java_network_change_notifier_)); 86 env, java_network_change_notifier_));
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 Java_NetworkChangeNotifier_fakeDefaultNetwork(env, network, type); 361 Java_NetworkChangeNotifier_fakeDefaultNetwork(env, network, type);
365 } 362 }
366 363
367 void NetworkChangeNotifierDelegateAndroid::FakeMaxBandwidthChanged( 364 void NetworkChangeNotifierDelegateAndroid::FakeMaxBandwidthChanged(
368 double max_bandwidth_mbps) { 365 double max_bandwidth_mbps) {
369 JNIEnv* env = base::android::AttachCurrentThread(); 366 JNIEnv* env = base::android::AttachCurrentThread();
370 Java_NetworkChangeNotifier_fakeMaxBandwidthChanged(env, max_bandwidth_mbps); 367 Java_NetworkChangeNotifier_fakeMaxBandwidthChanged(env, max_bandwidth_mbps);
371 } 368 }
372 369
373 } // namespace net 370 } // namespace net
OLDNEW
« no previous file with comments | « net/android/javatests/src/org/chromium/net/NetworkChangeNotifierTest.java ('k') | net/android/network_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698