| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.components.background_task_scheduler; | 5 package org.chromium.components.background_task_scheduler; |
| 6 | 6 |
| 7 import android.os.Build; |
| 8 |
| 7 import com.google.android.gms.gcm.GcmNetworkManager; | 9 import com.google.android.gms.gcm.GcmNetworkManager; |
| 8 import com.google.android.gms.gcm.GcmTaskService; | 10 import com.google.android.gms.gcm.GcmTaskService; |
| 9 import com.google.android.gms.gcm.TaskParams; | 11 import com.google.android.gms.gcm.TaskParams; |
| 10 | 12 |
| 11 import org.chromium.base.ContextUtils; | 13 import org.chromium.base.ContextUtils; |
| 12 import org.chromium.base.Log; | 14 import org.chromium.base.Log; |
| 13 import org.chromium.base.ThreadUtils; | 15 import org.chromium.base.ThreadUtils; |
| 14 | 16 |
| 15 import java.util.concurrent.CountDownLatch; | 17 import java.util.concurrent.CountDownLatch; |
| 16 import java.util.concurrent.TimeUnit; | 18 import java.util.concurrent.TimeUnit; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 ContextUtils.getApplicationContext(),
taskParams))) { | 106 ContextUtils.getApplicationContext(),
taskParams))) { |
| 105 return GcmNetworkManager.RESULT_RESCHEDULE; | 107 return GcmNetworkManager.RESULT_RESCHEDULE; |
| 106 } | 108 } |
| 107 } | 109 } |
| 108 | 110 |
| 109 return GcmNetworkManager.RESULT_SUCCESS; | 111 return GcmNetworkManager.RESULT_SUCCESS; |
| 110 } | 112 } |
| 111 | 113 |
| 112 @Override | 114 @Override |
| 113 public void onInitializeTasks() { | 115 public void onInitializeTasks() { |
| 116 // Ignore the event on OSs supporting JobScheduler. |
| 117 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) return; |
| 114 BackgroundTaskSchedulerFactory.getScheduler().reschedule( | 118 BackgroundTaskSchedulerFactory.getScheduler().reschedule( |
| 115 ContextUtils.getApplicationContext()); | 119 ContextUtils.getApplicationContext()); |
| 116 } | 120 } |
| 117 } | 121 } |
| OLD | NEW |