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

Unified Diff: components/cronet/android/network_change_notifier_initer.cc

Issue 2811813003: [Cronet] Move NetworkChangeNotifier initialization off UI thread (Closed)
Patch Set: fix NPE 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 side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/network_change_notifier_initer.cc
diff --git a/components/cronet/android/network_change_notifier_initer.cc b/components/cronet/android/network_change_notifier_initer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..65d0b88f5b7af57edc388bc1dacf935494911757
--- /dev/null
+++ b/components/cronet/android/network_change_notifier_initer.cc
@@ -0,0 +1,33 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/cronet/android/network_change_notifier_initer.h"
+
+#include <jni.h>
+
+#include "jni/NetworkChangeNotifierIniter_jni.h"
+#include "net/android/network_change_notifier_factory_android.h"
+#include "net/base/network_change_notifier.h"
+
+namespace cronet {
+
+void NetworkChangeNotifierInit(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jclass>& jcaller) {
+ net::NetworkChangeNotifier::SetFactory(
+ new net::NetworkChangeNotifierFactoryAndroid());
+ net::NetworkChangeNotifier::Create();
+}
+
+void NetworkChangeNotifierInit() {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_NetworkChangeNotifierIniter_init(env);
+}
+
+// Explicitly register static JNI functions.
+bool NetworkChangeNotifierIniterRegisterJni(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+} // namespace cronet

Powered by Google App Engine
This is Rietveld 408576698