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

Unified Diff: net/android/java/src/org/chromium/net/NetworkChangeNotifier.java

Issue 669813003: Update from chromium https://crrev.com/301725/ (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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: net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
diff --git a/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java b/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
index 476ff344be196d38c8f3fed1a8579b942a09c72c..1008b7e41e89976f2054e7d853e3819a9b81c0e1 100644
--- a/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
+++ b/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
@@ -114,7 +114,7 @@ public class NetworkChangeNotifier {
* network connectivity.
*/
public static void setAutoDetectConnectivityState(boolean shouldAutoDetect) {
- getInstance().setAutoDetectConnectivityStateInternal(shouldAutoDetect);
+ getInstance().setAutoDetectConnectivityStateInternal(shouldAutoDetect, false);
}
private void destroyAutoDetector() {
@@ -124,7 +124,20 @@ public class NetworkChangeNotifier {
}
}
- private void setAutoDetectConnectivityStateInternal(boolean shouldAutoDetect) {
+ /**
+ * Registers to always receive network change notifications no matter if
+ * the app is in the background or foreground.
+ * Note that in normal circumstances, chrome embedders should use
+ * {@code setAutoDetectConnectivityState} to listen to network changes only
+ * when the app is in the foreground, because network change observers
+ * might perform expensive work depending on the network connectivity.
+ */
+ public static void registerToReceiveNotificationsAlways() {
+ getInstance().setAutoDetectConnectivityStateInternal(true, true);
+ }
+
+ private void setAutoDetectConnectivityStateInternal(
+ boolean shouldAutoDetect, boolean alwaysWatchForChanges) {
if (shouldAutoDetect) {
if (mAutoDetector == null) {
mAutoDetector = new NetworkChangeNotifierAutoDetect(
@@ -134,7 +147,8 @@ public class NetworkChangeNotifier {
updateCurrentConnectionType(newConnectionType);
}
},
- mContext);
+ mContext,
+ alwaysWatchForChanges);
updateCurrentConnectionType(mAutoDetector.getCurrentConnectionType());
}
} else {
« no previous file with comments | « mojo/tools/roll/ui_gl_init.patch ('k') | net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698