| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.net; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import org.chromium.base.ApplicationState; | 7 import org.chromium.base.ApplicationState; |
| 8 import org.chromium.base.ApplicationStatus; | 8 import org.chromium.base.ApplicationStatus; |
| 9 import org.chromium.base.VisibleForTesting; | 9 import org.chromium.base.VisibleForTesting; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Regsitration policy which depends on the ApplicationState. | 12 * Regsitration policy which depends on the ApplicationState. |
| 13 */ | 13 */ |
| 14 public class RegistrationPolicyApplicationStatus | 14 public class RegistrationPolicyApplicationStatus |
| 15 extends NetworkChangeNotifierAutoDetect.RegistrationPolicy | 15 extends NetworkChangeNotifierAutoDetect.RegistrationPolicy |
| 16 implements ApplicationStatus.ApplicationStateListener { | 16 implements ApplicationStatus.ApplicationStateListener { |
| 17 private boolean mDestroyed = false; | 17 private boolean mDestroyed; |
| 18 | 18 |
| 19 @Override | 19 @Override |
| 20 protected void init(NetworkChangeNotifierAutoDetect notifier) { | 20 protected void init(NetworkChangeNotifierAutoDetect notifier) { |
| 21 super.init(notifier); | 21 super.init(notifier); |
| 22 ApplicationStatus.registerApplicationStateListener(this); | 22 ApplicationStatus.registerApplicationStateListener(this); |
| 23 onApplicationStateChange(getApplicationState()); | 23 onApplicationStateChange(getApplicationState()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 protected void destroy() { | 26 protected void destroy() { |
| 27 if (mDestroyed) return; | 27 if (mDestroyed) return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Returns the activity's status. | 43 * Returns the activity's status. |
| 44 * @return an {@code int} that is one of {@code ApplicationState.HAS_*_ACTIV
ITIES}. | 44 * @return an {@code int} that is one of {@code ApplicationState.HAS_*_ACTIV
ITIES}. |
| 45 */ | 45 */ |
| 46 @VisibleForTesting | 46 @VisibleForTesting |
| 47 int getApplicationState() { | 47 int getApplicationState() { |
| 48 return ApplicationStatus.getStateForApplication(); | 48 return ApplicationStatus.getStateForApplication(); |
| 49 } | 49 } |
| 50 } | 50 } |
| OLD | NEW |