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

Unified Diff: components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMListener.java

Issue 314293006: Implement GCMDriver.java using MultiplexingGcmListener (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix FindBugs Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMListener.java
diff --git a/components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMListener.java b/components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..d3cb556f930e9155ced28ea364ca0ec0e3a4d433
--- /dev/null
+++ b/components/gcm_driver/android/java/src/org/chromium/components/gcm_driver/GCMListener.java
@@ -0,0 +1,75 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.gcm_driver;
+
+import android.content.Intent;
+
+import com.google.ipc.invalidation.external.client.contrib.MultiplexingGcmListener;
+
+import org.chromium.base.ThreadUtils;
+
+/**
+ * Receives GCM registration events and messages rebroadcast by MultiplexingGcmListener.
+ */
+public class GCMListener extends MultiplexingGcmListener.AbstractListener {
+ /**
+ * Receiver for broadcasts by the multiplexed GCM service. It forwards them to
+ * GCMListener.
+ *
+ * This class is public so that it can be instantiated by the Android runtime.
+ */
+ public static class Receiver extends MultiplexingGcmListener.AbstractListener.Receiver {
+ @Override
+ protected Class<?> getServiceClass() {
+ return GCMListener.class;
+ }
+ }
+
+ private static final String TAG = "GCMListener";
+
+ public GCMListener() {
+ super(TAG);
+ }
+
+ @Override
+ protected void onRegistered(final String registrationId) {
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override public void run() {
+ // TODO(johnme): Get app ID.
+ GCMDriver.onRegisterFinished("unknown-app-id", registrationId);
+ }
+ });
+ }
+
+ @Override
+ protected void onUnregistered(String registrationId) {
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override public void run() {
+ // TODO(johnme): Get app ID.
+ GCMDriver.onUnregisterFinished("unknown-app-id");
+ }
+ });
+ }
+
+ @Override
+ protected void onMessage(final Intent intent) {
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override public void run() {
+ // TODO(johnme): Get app ID.
+ GCMDriver.onMessageReceived("unknown-app-id", intent.getExtras());
+ }
+ });
+ }
+
+ @Override
+ protected void onDeletedMessages(int total) {
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override public void run() {
+ // TODO(johnme): Get app ID.
+ GCMDriver.onMessagesDeleted("unknown-app-id");
+ }
+ });
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698