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 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H |
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | |
10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "components/gcm_driver/gcm_driver.h" | 13 #include "components/gcm_driver/gcm_driver.h" |
13 | 14 |
14 namespace gcm { | 15 namespace gcm { |
15 | 16 |
16 // GCMDriver implementation for Android. | 17 // GCMDriver implementation for Android, using Android GCM APIs. |
17 class GCMDriverAndroid : public GCMDriver { | 18 class GCMDriverAndroid : public GCMDriver { |
18 public: | 19 public: |
19 GCMDriverAndroid(); | 20 GCMDriverAndroid(); |
20 virtual ~GCMDriverAndroid(); | 21 virtual ~GCMDriverAndroid(); |
21 | 22 |
22 // GCMDriver implementation: | 23 // GCMDriver implementation: |
23 virtual void Enable() OVERRIDE; | 24 virtual void Enable() OVERRIDE; |
24 virtual void Disable() OVERRIDE; | 25 virtual void Disable() OVERRIDE; |
25 virtual void Register(const std::string& app_id, | 26 virtual void Register(const std::string& app_id, |
26 const std::vector<std::string>& sender_ids, | 27 const std::vector<std::string>& sender_ids, |
27 const RegisterCallback& callback) OVERRIDE; | 28 const RegisterCallback& callback) OVERRIDE; |
28 virtual void Unregister(const std::string& app_id, | 29 virtual void Unregister(const std::string& app_id, |
29 const UnregisterCallback& callback) OVERRIDE; | 30 const UnregisterCallback& callback) OVERRIDE; |
30 virtual void Send(const std::string& app_id, | 31 virtual void Send(const std::string& app_id, |
31 const std::string& receiver_id, | 32 const std::string& receiver_id, |
32 const GCMClient::OutgoingMessage& message, | 33 const GCMClient::OutgoingMessage& message, |
33 const SendCallback& callback) OVERRIDE; | 34 const SendCallback& callback) OVERRIDE; |
34 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE; | 35 virtual GCMClient* GetGCMClientForTesting() const OVERRIDE; |
35 virtual bool IsStarted() const OVERRIDE; | 36 virtual bool IsStarted() const OVERRIDE; |
36 virtual bool IsGCMClientReady() const OVERRIDE; | 37 virtual bool IsGCMClientReady() const OVERRIDE; |
37 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, | 38 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback, |
38 bool clear_logs) OVERRIDE; | 39 bool clear_logs) OVERRIDE; |
39 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, | 40 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback, |
40 bool recording) OVERRIDE; | 41 bool recording) OVERRIDE; |
41 virtual std::string SignedInUserName() const OVERRIDE; | 42 virtual std::string SignedInUserName() const OVERRIDE; |
42 | 43 |
44 // Methods called from Java via JNI: | |
45 void OnRegisterFinished(JNIEnv* env, | |
46 jobject obj, | |
47 jstring app_id, | |
48 jstring registration_id, | |
49 jboolean success); | |
50 void OnUnregisterFinished(JNIEnv* env, | |
51 jobject obj, | |
52 jstring app_id, | |
53 jboolean success); | |
54 void OnMessageReceived(JNIEnv* env, | |
55 jobject obj, | |
56 jstring app_id, | |
57 jstring sender_id, | |
58 jstring collapse_key, | |
59 jobjectArray data_keys_and_values); | |
60 void OnMessagesDeletedByServer(JNIEnv* env, | |
fgorski
2014/06/03 17:38:25
OnMessagesDeleted for consistency.
johnme
2014/06/03 17:50:37
Done.
| |
61 jobject obj, | |
62 jstring app_id); | |
63 | |
43 // Register JNI methods. | 64 // Register JNI methods. |
44 static bool RegisterBindings(JNIEnv* env); | 65 static bool RegisterBindings(JNIEnv* env); |
45 | 66 |
46 private: | 67 private: |
68 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | |
69 | |
47 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid); | 70 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid); |
48 }; | 71 }; |
49 | 72 |
50 } // namespace gcm | 73 } // namespace gcm |
51 | 74 |
52 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H | 75 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H |
OLD | NEW |