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

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

Issue 159173002: Refactor ActivityStatus to not store current activity (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Comments Created 6 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
Index: net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
diff --git a/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java b/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
index 981e3dc5f7aa6ce57d3d75331b802f08bbe063f9..e372002000b40c82c7da2352976bc9836b3382da 100644
--- a/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
+++ b/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
@@ -22,7 +22,7 @@ import org.chromium.base.ActivityStatus;
* ACCESS_NETWORK_STATE permission.
*/
public class NetworkChangeNotifierAutoDetect extends BroadcastReceiver
- implements ActivityStatus.StateListener {
+ implements ActivityStatus.ApplicationStateListener {
/** Queries the ConnectivityManager for information about the current connection. */
static class ConnectivityManagerDelegate {
@@ -107,7 +107,7 @@ public class NetworkChangeNotifierAutoDetect extends BroadcastReceiver
mWifiManagerDelegate = new WifiManagerDelegate(context);
mConnectionType = getCurrentConnectionType();
mWifiSSID = getCurrentWifiSSID();
- ActivityStatus.registerStateListener(this);
+ ActivityStatus.registerApplicationStateListener(this);
}
/**
@@ -203,19 +203,13 @@ public class NetworkChangeNotifierAutoDetect extends BroadcastReceiver
connectionTypeChanged();
}
- // ActivityStatus.StateListener
+ // ActivityStatus.ApplicationStateListener
@Override
- public void onActivityStateChange(int state) {
- if (state == ActivityStatus.RESUMED) {
- // Note that this also covers the case where the main activity is created. The CREATED
- // event is always followed by the RESUMED event. This is a temporary "hack" until
- // http://crbug.com/176837 is fixed. The CREATED event can't be used reliably for now
- // since its notification is deferred. This means that it can immediately follow a
- // DESTROYED/STOPPED/... event which is problematic.
- // TODO(pliard): fix http://crbug.com/176837.
+ public void onApplicationStateChange(int newState) {
+ if (newState == ActivityStatus.APP_RUNNING) {
connectionTypeChanged();
registerReceiver();
- } else if (state == ActivityStatus.PAUSED) {
+ } else if (newState == ActivityStatus.APP_PAUSED) {
unregisterReceiver();
}
}

Powered by Google App Engine
This is Rietveld 408576698