OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.components.gcm_driver; | 5 package org.chromium.components.gcm_driver; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.AsyncTask; | 8 import android.os.AsyncTask; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 * It uses Android's Java GCM APIs to implement GCM registration etc, and | 23 * It uses Android's Java GCM APIs to implement GCM registration etc, and |
24 * sends back GCM messages over JNI. | 24 * sends back GCM messages over JNI. |
25 * | 25 * |
26 * Threading model: all calls to/from C++ happen on the UI thread. | 26 * Threading model: all calls to/from C++ happen on the UI thread. |
27 */ | 27 */ |
28 @JNINamespace("gcm") | 28 @JNINamespace("gcm") |
29 public class GCMDriver { | 29 public class GCMDriver { |
30 private static final String TAG = "GCMDriver"; | 30 private static final String TAG = "GCMDriver"; |
31 | 31 |
32 // The instance of GCMDriver currently owned by a C++ GCMDriverAndroid, if a
ny. | 32 // The instance of GCMDriver currently owned by a C++ GCMDriverAndroid, if a
ny. |
33 private static GCMDriver sInstance = null; | 33 private static GCMDriver sInstance; |
34 | 34 |
35 private long mNativeGCMDriverAndroid; | 35 private long mNativeGCMDriverAndroid; |
36 private final Context mContext; | 36 private final Context mContext; |
37 private GoogleCloudMessagingSubscriber mSubscriber; | 37 private GoogleCloudMessagingSubscriber mSubscriber; |
38 | 38 |
39 private GCMDriver(long nativeGCMDriverAndroid, Context context) { | 39 private GCMDriver(long nativeGCMDriverAndroid, Context context) { |
40 mNativeGCMDriverAndroid = nativeGCMDriverAndroid; | 40 mNativeGCMDriverAndroid = nativeGCMDriverAndroid; |
41 mContext = context; | 41 mContext = context; |
42 mSubscriber = new GoogleCloudMessagingV2(context); | 42 mSubscriber = new GoogleCloudMessagingV2(context); |
43 } | 43 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 sInstance.mSubscriber = subscriber; | 159 sInstance.mSubscriber = subscriber; |
160 } | 160 } |
161 | 161 |
162 private native void nativeOnRegisterFinished(long nativeGCMDriverAndroid, St
ring appId, | 162 private native void nativeOnRegisterFinished(long nativeGCMDriverAndroid, St
ring appId, |
163 String registrationId, boolean success); | 163 String registrationId, boolean success); |
164 private native void nativeOnUnregisterFinished(long nativeGCMDriverAndroid,
String appId, | 164 private native void nativeOnUnregisterFinished(long nativeGCMDriverAndroid,
String appId, |
165 boolean success); | 165 boolean success); |
166 private native void nativeOnMessageReceived(long nativeGCMDriverAndroid, Str
ing appId, | 166 private native void nativeOnMessageReceived(long nativeGCMDriverAndroid, Str
ing appId, |
167 String senderId, String collapseKey, byte[] rawData, String[] dataKe
ysAndValues); | 167 String senderId, String collapseKey, byte[] rawData, String[] dataKe
ysAndValues); |
168 } | 168 } |
OLD | NEW |