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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/services/gcm/GCMJobService.java

Issue 2690163008: Route through a JobService when receiving a message for the GCM Driver (Closed)
Patch Set: Route through a JobService when receiving a message for the GCM Driver Created 3 years, 9 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.chrome.browser.services.gcm;
6
7 import android.annotation.TargetApi;
8 import android.app.job.JobParameters;
9 import android.app.job.JobService;
10 import android.os.Build;
11 import android.os.PersistableBundle;
12
13 import org.chromium.base.Log;
14 import org.chromium.components.gcm_driver.GCMMessage;
15
16 /**
17 * Processes jobs that have been scheduled for delivering GCM messages to the na tive GCM Driver,
18 * processing for which may exceed the lifetime of the GcmListenerService.
19 */
20 @TargetApi(Build.VERSION_CODES.N)
21 public class GCMJobService extends JobService {
22 private static final String TAG = "GCMJobService";
23
24 /**
25 * Called when a GCM message is ready to be delivered to the GCM Driver cons umer.
26 *
27 * @param params The parameters that define the job that is to be started.
28 * @return True if the service has remaining asynchronous work and will use {@link #jobFinished}
29 * when done. (So the system will hold a wakelock.) False otherwise.
30 */
31 @Override
32 public boolean onStartJob(JobParameters params) {
33 PersistableBundle extras = params.getExtras();
34 if (!GCMMessage.validatePersistableBundle(extras)) {
35 Log.e(TAG, "The received bundle containing message data could not be validated.");
36 return false;
37 }
38
39 ChromeGcmListenerService.dispatchMessageToDriver(this, new GCMMessage(pa rams.getExtras()));
40 return false;
41 }
42
43 /**
44 * Called when the system has determined that processing the GCM message mus t be stopped.
45 *
46 * @param params The parameters that define the job that is to be stopped.
47 * @return True if the job has finished and the wakelock is ready to be rele ased. False if there
48 * is remaining (asynchronous) work to be done.
49 */
50 @Override
51 public boolean onStopJob(JobParameters params) {
52 // The GCM Driver has no mechanism for aborting previously dispatched me ssages.
53 return false;
54 }
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698