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

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: Clean up background section of documentation 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.os.Build;
8
9 import org.chromium.base.ThreadUtils;
10
11 /**
12 * A factory for {@link BackgroundTaskScheduler} that ensures there is only ever a single instance.
David Trainor- moved to gerrit 2017/02/24 07:19:49 Do we really ensure this? Should we make the task
Peter Beverloo 2017/02/24 18:07:09 The BackgroundTaskScheduler's constructor already
nyquist 2017/02/24 23:41:11 I guess since the constructor is package protected
13 */
14 public final class BackgroundTaskSchedulerFactory {
15 private static BackgroundTaskScheduler sInstance;
16
17 private static BackgroundTaskSchedulerDelegate getSchedulerDelegate() {
Peter Beverloo 2017/02/24 18:07:09 Wild idea: should we mark this with @TargetApi on
nyquist 2017/02/24 23:41:12 Good call. I'll do that for now until we have GcmN
18 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
19 return new BackgroundTaskSchedulerJobService();
20 } else {
21 throw new RuntimeException("Not able to schedule through GCM yet.");
22 }
23 }
24
25 /**
26 * @return the current instance of the {@link BackgroundTaskScheduler}. Crea tes one if none
27 * exist.
28 */
29 public static BackgroundTaskScheduler getScheduler() {
30 ThreadUtils.assertOnUiThread();
31 if (sInstance == null) sInstance = new BackgroundTaskScheduler(getSchedu lerDelegate());
32 return sInstance;
33 }
34
35 // Do not instantiate.
36 private BackgroundTaskSchedulerFactory() {}
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698