Chromium Code Reviews| 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 org.chromium.base.Callback; | 7 import org.chromium.base.Callback; |
| 8 import org.chromium.base.ContextUtils; | 8 import org.chromium.base.ContextUtils; |
| 9 import org.chromium.base.annotations.CalledByNative; | 9 import org.chromium.base.annotations.CalledByNative; |
| 10 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 // TODO(dougarnett): consider adding policy check api to let caller | 25 // TODO(dougarnett): consider adding policy check api to let caller |
| 26 // separately determine if not allowed by policy. | 26 // separately determine if not allowed by policy. |
| 27 public static boolean startProcessing( | 27 public static boolean startProcessing( |
| 28 DeviceConditions deviceConditions, Callback<Boolean> callback) { | 28 DeviceConditions deviceConditions, Callback<Boolean> callback) { |
| 29 return nativeStartProcessing(deviceConditions.isPowerConnected(), | 29 return nativeStartProcessing(deviceConditions.isPowerConnected(), |
| 30 deviceConditions.getBatteryPercentage(), deviceConditions.getNet ConnectionType(), | 30 deviceConditions.getBatteryPercentage(), deviceConditions.getNet ConnectionType(), |
| 31 callback); | 31 callback); |
| 32 } | 32 } |
| 33 | 33 |
| 34 @CalledByNative | 34 @CalledByNative |
| 35 private static void schedule() { | 35 private static void schedule(TriggerConditions triggerConditions) { |
| 36 BackgroundScheduler.schedule(ContextUtils.getApplicationContext()); | 36 BackgroundScheduler.schedule(ContextUtils.getApplicationContext(), trigg erConditions); |
| 37 } | 37 } |
| 38 | 38 |
| 39 @CalledByNative | 39 @CalledByNative |
| 40 private static void unschedule() { | 40 private static void unschedule() { |
| 41 BackgroundScheduler.unschedule(ContextUtils.getApplicationContext()); | 41 BackgroundScheduler.unschedule(ContextUtils.getApplicationContext()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 @CalledByNative | |
|
Pete Williamson
2016/06/20 23:14:03
We might document *why* we have a createTriggerCon
dougarnett
2016/06/22 19:54:18
Done.
| |
| 45 private static TriggerConditions createTriggerConditions(boolean requirePowe rConnected, | |
| 46 int minimumBatteryPercentage, boolean requireUnmeteredNetwork) { | |
| 47 return new TriggerConditions( | |
| 48 requirePowerConnected, minimumBatteryPercentage, requireUnmetere dNetwork); | |
| 49 } | |
| 50 | |
| 44 private static native boolean nativeStartProcessing(boolean powerConnected, | 51 private static native boolean nativeStartProcessing(boolean powerConnected, |
| 45 int batteryPercentage, int netConnectionType, Callback<Boolean> call back); | 52 int batteryPercentage, int netConnectionType, Callback<Boolean> call back); |
| 46 } | 53 } |
| OLD | NEW |