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

Side by Side Diff: components/gcm_driver/gcm_driver_android.h

Issue 312683004: JNI bindings for GCMDriverAndroid (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed OnMessagesDeletedByServer 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 OnMessagesDeleted(JNIEnv* env,
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698