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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/invalidation/InvalidationController.java

Issue 2790703002: cache_invalidation: Restrict background services only on O. (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.chrome.browser.invalidation; 5 package org.chromium.chrome.browser.invalidation;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.os.AsyncTask; 9 import android.os.AsyncTask;
10 import android.os.Handler; 10 import android.os.Handler;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 mUseGcmUpstream = canUseGcmUpstream; 353 mUseGcmUpstream = canUseGcmUpstream;
354 mCanDisableSessionInvalidations = canDisableSessionInvalidations; 354 mCanDisableSessionInvalidations = canDisableSessionInvalidations;
355 mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations; 355 mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations;
356 mEnableSessionInvalidationsTimer = new Timer(); 356 mEnableSessionInvalidationsTimer = new Timer();
357 357
358 ApplicationStatus.registerApplicationStateListener(this); 358 ApplicationStatus.registerApplicationStateListener(this);
359 } 359 }
360 360
361 private boolean shouldRestrictBackgroundServices() { 361 private boolean shouldRestrictBackgroundServices() {
362 // Restricts the use of background services when not in foreground. See crbug.com/680812. 362 // Restricts the use of background services when not in foreground. See crbug.com/680812.
363 return BuildInfo.isGreaterThanN() && !ApplicationStatus.hasVisibleActivi ties(); 363 return BuildInfo.isAtLeastO() && !ApplicationStatus.hasVisibleActivities ();
364 } 364 }
365 365
366 @Override 366 @Override
367 public void onApplicationStateChange(int newState) { 367 public void onApplicationStateChange(int newState) {
368 // The isSyncEnabled() check is used to check whether the InvalidationCo ntroller would be 368 // The isSyncEnabled() check is used to check whether the InvalidationCo ntroller would be
369 // started if it did not stop itself when the application is paused. 369 // started if it did not stop itself when the application is paused.
370 if (AndroidSyncSettings.isSyncEnabled(mContext)) { 370 if (AndroidSyncSettings.isSyncEnabled(mContext)) {
371 if (newState == ApplicationState.HAS_RUNNING_ACTIVITIES) { 371 if (newState == ApplicationState.HAS_RUNNING_ACTIVITIES) {
372 start(); 372 start();
373 } else if (newState == ApplicationState.HAS_PAUSED_ACTIVITIES) { 373 } else if (newState == ApplicationState.HAS_PAUSED_ACTIVITIES) {
374 stop(); 374 stop();
375 } 375 }
376 } 376 }
377 } 377 }
378 } 378 }
OLDNEW
« no previous file with comments | « no previous file | components/invalidation/impl/android/java/src/org/chromium/components/invalidation/InvalidationClientService.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698