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

Unified Diff: google_apis/gcm/gcm_client_impl_android.h

Issue 246863004: WIP initial sketch for an Android GCMClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gcm/gcm.gyp ('k') | google_apis/gcm/gcm_client_impl_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « google_apis/gcm/gcm.gyp ('k') | google_apis/gcm/gcm_client_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698