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

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

Issue 2779753002: [Android] Adding scheduling through GcmNetworkManager (Closed)
Patch Set: Ensuring task is called on UI thread Created 3 years, 8 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 com.google.android.gms.gcm.GcmNetworkManager;
8 import com.google.android.gms.gcm.GcmTaskService;
9 import com.google.android.gms.gcm.Task;
10
11 import org.robolectric.annotation.Implementation;
12 import org.robolectric.annotation.Implements;
13
14 /**
15 * Custom shadow for the OS's GcmNetworkManager. We use this to hook the call t o GcmNetworkManager
16 * to make sure it was invoked as we expect.
17 */
18 @Implements(GcmNetworkManager.class)
19 public class ShadowGcmNetworkManager {
20 private Task mTask;
21 private Task mCanceledTask;
22
23 @Implementation
24 public void schedule(Task task) {
25 mTask = task;
26 mCanceledTask = null;
27 }
28
29 @Implementation
30 public void cancelTask(String tag, Class<? extends GcmTaskService> gcmTaskSe rvice) {
31 if (mTask != null && mTask.getTag().equals(tag)
32 && mTask.getServiceName().equals(gcmTaskService.getName())) {
33 mCanceledTask = mTask;
34 mTask = null;
35 }
36 }
37
38 public Task getScheduledTask() {
39 return mTask;
40 }
41
42 public Task getCanceledTask() {
43 return mCanceledTask;
44 }
45
46 public void clear() {
47 mTask = null;
48 mCanceledTask = null;
49 }
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698