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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwNetworkChangeNotifierRegistrationPolicy.java

Issue 1761983003: [Android WebView] Implement support for Network Information API and enable it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 10 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
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwContents.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwNetworkChangeNotifierRegistrationPolicy.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwNetworkChangeNotifierRegistrationPolicy.java b/android_webview/java/src/org/chromium/android_webview/AwNetworkChangeNotifierRegistrationPolicy.java
new file mode 100644
index 0000000000000000000000000000000000000000..798a9af2d784031c62069545beeb696238f80bc7
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwNetworkChangeNotifierRegistrationPolicy.java
@@ -0,0 +1,37 @@
+// Copyright 2016 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.
+
+package org.chromium.android_webview;
+
+import org.chromium.net.NetworkChangeNotifierAutoDetect;
+
+/**
+ * Registration policy to make sure we only listen to network changes when
+ * there are live webview instances.
+ */
+public class AwNetworkChangeNotifierRegistrationPolicy
+ extends NetworkChangeNotifierAutoDetect.RegistrationPolicy
+ implements AwContentsLifecycleNotifier.Observer {
+
+ @Override
+ protected void init(NetworkChangeNotifierAutoDetect notifier) {
+ super.init(notifier);
+ AwContentsLifecycleNotifier.addObserver(this);
+ }
+
+ protected void destroy() {
+ AwContentsLifecycleNotifier.removeObserver(this);
+ }
+
+ // AwContentsLifecycleNotifier.Observer
+ @Override
+ public void onFirstWebViewCreated() {
+ register();
+ }
+
+ @Override
+ public void onLastWebViewDestroyed() {
+ unregister();
+ }
+}
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwContents.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698