| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.offlinepages; | 5 package org.chromium.chrome.browser.offlinepages; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Bundle; | 8 import android.os.Bundle; |
| 9 | 9 |
| 10 import org.chromium.base.ApplicationStatus; | 10 import org.chromium.base.ApplicationStatus; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 * Also starts UMA collection. | 53 * Also starts UMA collection. |
| 54 * | 54 * |
| 55 * @returns true for success | 55 * @returns true for success |
| 56 */ | 56 */ |
| 57 private boolean startBackgroundRequestsImpl( | 57 private boolean startBackgroundRequestsImpl( |
| 58 Context context, Bundle bundle, final ChromeBackgroundServiceWaiter
waiter) { | 58 Context context, Bundle bundle, final ChromeBackgroundServiceWaiter
waiter) { |
| 59 // Set up backup scheduled task in case processing is killed before Requ
estCoordinator | 59 // Set up backup scheduled task in case processing is killed before Requ
estCoordinator |
| 60 // has a chance to reschedule base on remaining work. | 60 // has a chance to reschedule base on remaining work. |
| 61 TriggerConditions previousTriggerConditions = | 61 TriggerConditions previousTriggerConditions = |
| 62 TaskExtrasPacker.unpackTriggerConditionsFromBundle(bundle); | 62 TaskExtrasPacker.unpackTriggerConditionsFromBundle(bundle); |
| 63 BackgroundScheduler.backupSchedule(context, previousTriggerConditions, D
EFER_START_SECONDS); | 63 BackgroundScheduler.getInstance(context).backupSchedule( |
| 64 previousTriggerConditions, DEFER_START_SECONDS); |
| 64 | 65 |
| 65 DeviceConditions currentConditions = OfflinePageUtils.getDeviceCondition
s(context); | 66 DeviceConditions currentConditions = OfflinePageUtils.getDeviceCondition
s(context); |
| 66 if (!currentConditions.isPowerConnected() | 67 if (!currentConditions.isPowerConnected() |
| 67 && currentConditions.getBatteryPercentage() | 68 && currentConditions.getBatteryPercentage() |
| 68 < previousTriggerConditions.getMinimumBatteryPercentage(
)) { | 69 < previousTriggerConditions.getMinimumBatteryPercentage(
)) { |
| 69 Log.d(TAG, "Battery percentage is lower than minimum to start proces
sing"); | 70 Log.d(TAG, "Battery percentage is lower than minimum to start proces
sing"); |
| 70 return false; | 71 return false; |
| 71 } | 72 } |
| 72 | 73 |
| 73 if (SysUtils.isLowEndDevice() && ApplicationStatus.hasVisibleActivities(
)) { | 74 if (SysUtils.isLowEndDevice() && ApplicationStatus.hasVisibleActivities(
)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 88 /** Callback releasing the wakelock once background work concludes.
*/ | 89 /** Callback releasing the wakelock once background work concludes.
*/ |
| 89 @Override | 90 @Override |
| 90 public void onResult(Boolean result) { | 91 public void onResult(Boolean result) { |
| 91 Log.d(TAG, "onProcessingDone"); | 92 Log.d(TAG, "onProcessingDone"); |
| 92 // Release the wake lock. | 93 // Release the wake lock. |
| 93 waiter.onWaitDone(); | 94 waiter.onWaitDone(); |
| 94 } | 95 } |
| 95 }; | 96 }; |
| 96 } | 97 } |
| 97 } | 98 } |
| OLD | NEW |