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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/NotificationJobService.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, 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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.notifications; 5 package org.chromium.chrome.browser.notifications;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.app.job.JobParameters; 8 import android.app.job.JobParameters;
9 import android.app.job.JobService; 9 import android.app.job.JobService;
10 import android.content.Intent; 10 import android.content.Intent;
11 import android.os.Build; 11 import android.os.Build;
12 import android.os.Bundle; 12 import android.os.Bundle;
13 import android.os.PersistableBundle; 13 import android.os.PersistableBundle;
14 14
15 import org.chromium.base.ThreadUtils; 15 import org.chromium.base.ThreadUtils;
16 16
17 /** 17 /**
18 * Processes jobs scheduled when user actions are issued on web notifications. 18 * Processes jobs scheduled when user actions are issued on web notifications.
19 * We use this instead of starting the NotificationService on N+. 19 * We use this instead of starting the NotificationService on N+.
20 */ 20 */
21 @TargetApi(Build.VERSION_CODES.N) 21 @TargetApi(Build.VERSION_CODES.N)
22 public class NotificationJobService extends JobService { 22 public class NotificationJobService extends JobService {
23 // We don't need to distinguish between jobs sent to this service, so we can reuse one job id.
24 // But it ought to be distinct from job ids used with other JobService class es in our code.
25 static final int JOB_ID = 21;
26
27 static PersistableBundle getJobExtrasFromIntent(Intent intent) { 23 static PersistableBundle getJobExtrasFromIntent(Intent intent) {
28 PersistableBundle bundle = new PersistableBundle(); 24 PersistableBundle bundle = new PersistableBundle();
29 bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_ID, 25 bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_ID,
30 intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_I D)); 26 intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_I D));
31 bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN, 27 bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN,
32 intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_I NFO_ORIGIN)); 28 intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_I NFO_ORIGIN));
33 bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_INFO_PROFILE_I D, 29 bundle.putString(NotificationConstants.EXTRA_NOTIFICATION_INFO_PROFILE_I D,
34 intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_I NFO_PROFILE_ID)); 30 intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_I NFO_PROFILE_ID));
35 bundle.putBoolean(NotificationConstants.EXTRA_NOTIFICATION_INFO_PROFILE_ INCOGNITO, 31 bundle.putBoolean(NotificationConstants.EXTRA_NOTIFICATION_INFO_PROFILE_ INCOGNITO,
36 intent.getBooleanExtra( 32 intent.getBooleanExtra(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 78
83 @Override 79 @Override
84 public boolean onStopJob(JobParameters params) { 80 public boolean onStopJob(JobParameters params) {
85 // As it stands, all our job processing is done synchronously in onStart Job so there is 81 // As it stands, all our job processing is done synchronously in onStart Job so there is
86 // nothing to do here. Even once we include further async processing in our jobs 82 // nothing to do here. Even once we include further async processing in our jobs
87 // (crbug.com/685197) it may by infeasible to cancel this halfway throug h. 83 // (crbug.com/685197) it may by infeasible to cancel this halfway throug h.
88 // TODO(crbug.com/685197): Check what we can safely do here and update c omment. 84 // TODO(crbug.com/685197): Check what we can safely do here and update c omment.
89 return false; 85 return false;
90 } 86 }
91 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698