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

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: Rebase 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..6fa7f4f952453e0380e1c3961b62a5d1c7373afc 100644
--- a/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
+++ b/net/android/java/src/org/chromium/net/NetworkChangeNotifierAutoDetect.java
@@ -14,7 +14,8 @@ import android.net.wifi.WifiManager;
import android.telephony.TelephonyManager;
import android.util.Log;
-import org.chromium.base.ActivityStatus;
+import org.chromium.base.ApplicationState;
+import org.chromium.base.ApplicationStatus;
/**
* Used by the NetworkChangeNotifier to listens to platform changes in connectivity.
@@ -22,7 +23,7 @@ import org.chromium.base.ActivityStatus;
* ACCESS_NETWORK_STATE permission.
*/
public class NetworkChangeNotifierAutoDetect extends BroadcastReceiver
- implements ActivityStatus.StateListener {
+ implements ApplicationStatus.ApplicationStateListener {
/** Queries the ConnectivityManager for information about the current connection. */
static class ConnectivityManagerDelegate {
@@ -107,7 +108,7 @@ public class NetworkChangeNotifierAutoDetect extends BroadcastReceiver
mWifiManagerDelegate = new WifiManagerDelegate(context);
mConnectionType = getCurrentConnectionType();
mWifiSSID = getCurrentWifiSSID();
- ActivityStatus.registerStateListener(this);
+ ApplicationStatus.registerApplicationStateListener(this);
}
/**
@@ -203,19 +204,13 @@ public class NetworkChangeNotifierAutoDetect extends BroadcastReceiver
connectionTypeChanged();
}
- // ActivityStatus.StateListener
+ // ApplicationStatus.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 == ApplicationState.HAS_RUNNING_ACTIVITIES) {
connectionTypeChanged();
registerReceiver();
- } else if (state == ActivityStatus.PAUSED) {
+ } else if (newState == ApplicationState.HAS_PAUSED_ACTIVITIES) {
unregisterReceiver();
}
}

Powered by Google App Engine
This is Rietveld 408576698