Chromium Code Reviews| Index: chrome/browser/android/offline_pages/background_scheduler_bridge.cc |
| diff --git a/chrome/browser/android/offline_pages/background_scheduler_bridge.cc b/chrome/browser/android/offline_pages/background_scheduler_bridge.cc |
| index 9c59ebb6180918612532f3ed7eb8948f81d7268f..c82537338dcc151da6584cba3bab5b54925e9ecc 100644 |
| --- a/chrome/browser/android/offline_pages/background_scheduler_bridge.cc |
| +++ b/chrome/browser/android/offline_pages/background_scheduler_bridge.cc |
| @@ -56,6 +56,10 @@ static jboolean StartScheduledProcessing( |
| device_conditions, base::Bind(&ProcessingDoneCallback, j_callback_ref)); |
| } |
| +BackgroundSchedulerBridge::BackgroundSchedulerBridge() {} |
|
dewittj
2017/01/30 19:18:02
could use = default instead of {}
Pete Williamson
2017/01/30 21:35:23
Done.
|
| + |
| +BackgroundSchedulerBridge::~BackgroundSchedulerBridge() {} |
| + |
| void BackgroundSchedulerBridge::Schedule( |
| const TriggerConditions& trigger_conditions) { |
| JNIEnv* env = base::android::AttachCurrentThread(); |
| @@ -92,6 +96,25 @@ ScopedJavaLocalRef<jobject> BackgroundSchedulerBridge::CreateTriggerConditions( |
| require_unmetered_network); |
| } |
| +DeviceConditions& BackgroundSchedulerBridge::GetCurrentDeviceConditions() { |
|
dewittj
2017/01/30 19:18:02
const
Pete Williamson
2017/01/30 21:35:23
Done.
|
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + // Call the JNI methods to get the device conditions we need. |
| + jboolean jpower = Java_BackgroundSchedulerBridge_getPowerConditions(env); |
| + jint jbattery = Java_BackgroundSchedulerBridge_getBatteryConditions(env); |
| + jint jnetwork = Java_BackgroundSchedulerBridge_getNetworkConditions(env); |
| + |
| + // Cast the java types back to the types we use. |
| + bool power = static_cast<bool>(jpower); |
| + int battery = static_cast<int>(jbattery);; |
| + net::NetworkChangeNotifier::ConnectionType network_connection_type = |
| + static_cast<net::NetworkChangeNotifier::ConnectionType>(jnetwork); |
| + |
| + // Now return the current conditions to the caller. |
| + device_conditions_ = base::MakeUnique<DeviceConditions>( |
| + power, battery, network_connection_type); |
| + return *(device_conditions_.get()); |
|
dewittj
2017/01/30 19:18:02
I think you can just say *device_conditions_
Pete Williamson
2017/01/30 21:35:23
Done.
|
| +} |
| + |
| bool RegisterBackgroundSchedulerBridge(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |