Index: google_apis/gcm/gcm_client_impl_android.h |
diff --git a/google_apis/gcm/gcm_client_impl_android.h b/google_apis/gcm/gcm_client_impl_android.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d09492a9f76ea5640c2e8db2f7b9e37af443b695 |
--- /dev/null |
+++ b/google_apis/gcm/gcm_client_impl_android.h |
@@ -0,0 +1,88 @@ |
+// 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. |
+ |
+#ifndef GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_ANDROID_H_ |
+#define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_ANDROID_H_ |
+ |
+#include <vector> |
+ |
+#include "base/android/jni_android.h" |
+#include "base/memory/ref_counted.h" |
+#include "google_apis/gcm/gcm_client.h" |
+#include "google_apis/gcm/protocol/checkin.pb.h" |
+ |
+namespace gcm { |
+ |
+// Implements the GCM Client on Android. Can perform registrations, receive |
+// messages, etc. It communicates back to the host application via the delegate |
+// provided. |
+class GCM_EXPORT GCMClientImplAndroid : public GCMClient { |
+ public: |
+ explicit GCMClientImplAndroid(); |
+ virtual ~GCMClientImplAndroid(); |
+ |
+ // Overridden from GCMClient: |
+ virtual void Initialize( |
+ const checkin_proto::ChromeBuildProto& unused, |
+ const base::FilePath& unused, |
+ const std::vector<std::string>& unused, |
+ const scoped_refptr<base::SequencedTaskRunner>& unused, |
+ const scoped_refptr<net::URLRequestContextGetter>& unused, |
+ Delegate* delegate) OVERRIDE; |
+ virtual void Load() OVERRIDE; |
+ virtual void Stop() OVERRIDE; |
+ virtual void CheckOut() OVERRIDE; |
+ virtual void Register(const std::string& app_id, |
+ const std::vector<std::string>& sender_ids) OVERRIDE; |
+ virtual void Unregister(const std::string& app_id) OVERRIDE; |
+ virtual void Send(const std::string& app_id, |
+ const std::string& receiver_id, |
+ const OutgoingMessage& message) OVERRIDE; |
+ virtual GCMStatistics GetStatistics() const OVERRIDE; |
+ |
+ // Methods called from Java via JNI. |
+ void OnRegisterCompleted(JNIEnv* env, |
+ jobject obj, |
+ jstring app_id, |
+ jboolean success, |
+ jstring registration_id); |
+ void OnUnregisterCompleted(JNIEnv* env, |
+ jobject obj, |
+ jstring app_id, |
+ jboolean success); |
+ void OnMessageReceived(JNIEnv* env, |
+ jobject obj, |
+ jstring sender_id, |
+ jstring app_id, |
+ jstring collapse_key, |
+ jobjectArray data); |
+ void OnMessagesDeletedByServer(JNIEnv* env, |
+ jobject obj, |
+ jstring app_id); |
+ |
+ private: |
+ // State is tracked mainly for compatibility with the desktop implementation. |
+ enum State { |
+ // Uninitialized. |
+ UNINITIALIZED, |
+ // Initialized, |
+ INITIALIZED, |
+ // Ready to accept requests. |
+ READY |
+ }; |
+ |
+ // Returns text representation of the enum State. |
+ std::string GetStateString() const; |
+ |
+ // State of the GCM Client Implementation. |
+ State state_; |
+ |
+ Delegate* delegate_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(GCMClientImplAndroid); |
+}; |
+ |
+} // namespace gcm |
+ |
+#endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_ANDROID_H_ |