Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: components/background_task_scheduler/android/java/src/org/chromium/components/background_task_scheduler/BackgroundTaskSchedulerFactory.java

Issue 2714463002: [android] Add JobScheduler-based BackgroundTaskScheduler. (Closed)
Patch Set: FindBugs wants the real Pi, but I won't give it. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.components.background_task_scheduler;
6
7 import android.annotation.TargetApi;
8 import android.os.Build;
9
10 import org.chromium.base.ThreadUtils;
11
12 /**
13 * A factory for {@link BackgroundTaskScheduler} that ensures there is only ever a single instance.
14 */
15 public final class BackgroundTaskSchedulerFactory {
16 private static BackgroundTaskScheduler sInstance;
17
18 @TargetApi(Build.VERSION_CODES.M)
19 private static BackgroundTaskSchedulerDelegate getSchedulerDelegate() {
20 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
21 return new BackgroundTaskSchedulerJobService();
22 } else {
23 throw new RuntimeException("Not able to schedule through GCM yet.");
24 }
25 }
26
27 /**
28 * @return the current instance of the {@link BackgroundTaskScheduler}. Crea tes one if none
29 * exist.
30 */
31 public static BackgroundTaskScheduler getScheduler() {
32 ThreadUtils.assertOnUiThread();
33 if (sInstance == null) sInstance = new BackgroundTaskScheduler(getSchedu lerDelegate());
34 return sInstance;
35 }
36
37 // Do not instantiate.
38 private BackgroundTaskSchedulerFactory() {}
39 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698