OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_GCM_ANDROID_H_ |
| 6 #define CHROME_BROWSER_ANDROID_GCM_ANDROID_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/android/jni_android.h" |
| 12 #include "base/android/scoped_java_ref.h" |
| 13 //#include "base/callback.h" |
| 14 #include "base/memory/singleton.h" |
| 15 #include "content/public/browser/push_messaging_service.h" |
| 16 |
| 17 namespace content{ |
| 18 class PushMessagingMessageFilter; |
| 19 } |
| 20 |
| 21 class GcmPlatformImplAndroid : public content::PushMessagingService { |
| 22 public: |
| 23 // Initiates registration with GCM. No caching of registrations is done, |
| 24 // except any provided by the underlying GoogleCloudMessaging API. |
| 25 void Register( |
| 26 const std::string& app_unique_id_currently_ignored, |
| 27 const std::vector<std::string>& sender_ids, |
| 28 const content::PushMessagingService::RegisterCallback& callback) OVERRIDE; |
| 29 // Not yet implemented. |
| 30 //void UnregisterApp(const std::string& app_unique_id_currently_ignored); |
| 31 |
| 32 void SetObserver(content::PushMessagingMessageFilter* observer); |
| 33 |
| 34 // Methods called from Java via JNI. |
| 35 void OnRegistrationFinished(JNIEnv* env, jobject obj, jstring data); |
| 36 void OnMessageReceived(JNIEnv* env, jobject obj, jstring data); |
| 37 void OnMessagesDeletedByServer(JNIEnv* env, jobject obj); |
| 38 |
| 39 // Static functions. |
| 40 static GcmPlatformImplAndroid* GetInstance(); |
| 41 static bool RegisterGcmPlatformImplAndroid(JNIEnv* env); |
| 42 |
| 43 private: |
| 44 friend struct DefaultSingletonTraits<GcmPlatformImplAndroid>; |
| 45 |
| 46 GcmPlatformImplAndroid(); |
| 47 virtual ~GcmPlatformImplAndroid(); |
| 48 |
| 49 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 50 content::PushMessagingMessageFilter* observer_; |
| 51 content::PushMessagingService::RegisterCallback register_cb_; |
| 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(GcmPlatformImplAndroid); |
| 54 }; |
| 55 |
| 56 #endif // CHROME_BROWSER_ANDROID_GCM_ANDROID_H_ |
OLD | NEW |