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.download; | 5 package org.chromium.chrome.browser.download; |
6 | 6 |
| 7 import android.annotation.SuppressLint; |
7 import android.content.Context; | 8 import android.content.Context; |
8 import android.content.Intent; | 9 import android.content.Intent; |
9 | 10 |
10 import com.google.android.gms.gcm.GcmNetworkManager; | 11 import com.google.android.gms.gcm.GcmNetworkManager; |
11 import com.google.android.gms.gcm.OneoffTask; | 12 import com.google.android.gms.gcm.OneoffTask; |
12 import com.google.android.gms.gcm.Task; | 13 import com.google.android.gms.gcm.Task; |
13 | 14 |
14 import org.chromium.base.Log; | 15 import org.chromium.base.Log; |
15 import org.chromium.base.VisibleForTesting; | 16 import org.chromium.base.VisibleForTesting; |
16 import org.chromium.base.annotations.SuppressFBWarnings; | 17 import org.chromium.base.annotations.SuppressFBWarnings; |
17 import org.chromium.chrome.browser.ChromeBackgroundService; | 18 import org.chromium.chrome.browser.ChromeBackgroundService; |
18 | 19 |
19 /** | 20 /** |
20 * Class for scheduing download resumption tasks. | 21 * Class for scheduing download resumption tasks. |
21 */ | 22 */ |
22 public class DownloadResumptionScheduler { | 23 public class DownloadResumptionScheduler { |
23 public static final String TASK_TAG = "DownloadResumption"; | 24 public static final String TASK_TAG = "DownloadResumption"; |
24 private static final String TAG = "DownloadScheduler"; | 25 private static final String TAG = "DownloadScheduler"; |
25 private static final int ONE_DAY_IN_SECONDS = 24 * 60 * 60; | 26 private static final int ONE_DAY_IN_SECONDS = 24 * 60 * 60; |
26 private final Context mContext; | 27 private final Context mContext; |
| 28 @SuppressLint("StaticFieldLeak") |
27 private static DownloadResumptionScheduler sDownloadResumptionScheduler; | 29 private static DownloadResumptionScheduler sDownloadResumptionScheduler; |
28 | 30 |
29 @SuppressFBWarnings("LI_LAZY_INIT") | 31 @SuppressFBWarnings("LI_LAZY_INIT") |
30 public static DownloadResumptionScheduler getDownloadResumptionScheduler(Con
text context) { | 32 public static DownloadResumptionScheduler getDownloadResumptionScheduler(Con
text context) { |
31 assert context == context.getApplicationContext(); | 33 assert context == context.getApplicationContext(); |
32 if (sDownloadResumptionScheduler == null) { | 34 if (sDownloadResumptionScheduler == null) { |
33 sDownloadResumptionScheduler = new DownloadResumptionScheduler(conte
xt); | 35 sDownloadResumptionScheduler = new DownloadResumptionScheduler(conte
xt); |
34 } | 36 } |
35 return sDownloadResumptionScheduler; | 37 return sDownloadResumptionScheduler; |
36 } | 38 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 /** | 84 /** |
83 * Start browser process and resumes all interrupted downloads. | 85 * Start browser process and resumes all interrupted downloads. |
84 */ | 86 */ |
85 public void handleDownloadResumption() { | 87 public void handleDownloadResumption() { |
86 // Fire an intent to the DownloadNotificationService so that it will han
dle download | 88 // Fire an intent to the DownloadNotificationService so that it will han
dle download |
87 // resumption. | 89 // resumption. |
88 Intent intent = new Intent(DownloadNotificationService.ACTION_DOWNLOAD_R
ESUME_ALL); | 90 Intent intent = new Intent(DownloadNotificationService.ACTION_DOWNLOAD_R
ESUME_ALL); |
89 DownloadNotificationService.startDownloadNotificationService(mContext, i
ntent); | 91 DownloadNotificationService.startDownloadNotificationService(mContext, i
ntent); |
90 } | 92 } |
91 } | 93 } |
OLD | NEW |