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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_ANDROID_H_
6 #define GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_ANDROID_H_
7
8 #include <vector>
9
10 #include "base/android/jni_android.h"
11 #include "base/memory/ref_counted.h"
12 #include "google_apis/gcm/gcm_client.h"
13 #include "google_apis/gcm/protocol/checkin.pb.h"
14
15 namespace gcm {
16
17 // Implements the GCM Client on Android. Can perform registrations, receive
18 // messages, etc. It communicates back to the host application via the delegate
19 // provided.
20 class GCM_EXPORT GCMClientImplAndroid : public GCMClient {
21 public:
22 explicit GCMClientImplAndroid();
23 virtual ~GCMClientImplAndroid();
24
25 // Overridden from GCMClient:
26 virtual void Initialize(
27 const checkin_proto::ChromeBuildProto& unused,
28 const base::FilePath& unused,
29 const std::vector<std::string>& unused,
30 const scoped_refptr<base::SequencedTaskRunner>& unused,
31 const scoped_refptr<net::URLRequestContextGetter>& unused,
32 Delegate* delegate) OVERRIDE;
33 virtual void Load() OVERRIDE;
34 virtual void Stop() OVERRIDE;
35 virtual void CheckOut() OVERRIDE;
36 virtual void Register(const std::string& app_id,
37 const std::vector<std::string>& sender_ids) OVERRIDE;
38 virtual void Unregister(const std::string& app_id) OVERRIDE;
39 virtual void Send(const std::string& app_id,
40 const std::string& receiver_id,
41 const OutgoingMessage& message) OVERRIDE;
42 virtual GCMStatistics GetStatistics() const OVERRIDE;
43
44 // Methods called from Java via JNI.
45 void OnRegisterCompleted(JNIEnv* env,
46 jobject obj,
47 jstring app_id,
48 jboolean success,
49 jstring registration_id);
50 void OnUnregisterCompleted(JNIEnv* env,
51 jobject obj,
52 jstring app_id,
53 jboolean success);
54 void OnMessageReceived(JNIEnv* env,
55 jobject obj,
56 jstring sender_id,
57 jstring app_id,
58 jstring collapse_key,
59 jobjectArray data);
60 void OnMessagesDeletedByServer(JNIEnv* env,
61 jobject obj,
62 jstring app_id);
63
64 private:
65 // State is tracked mainly for compatibility with the desktop implementation.
66 enum State {
67 // Uninitialized.
68 UNINITIALIZED,
69 // Initialized,
70 INITIALIZED,
71 // Ready to accept requests.
72 READY
73 };
74
75 // Returns text representation of the enum State.
76 std::string GetStateString() const;
77
78 // State of the GCM Client Implementation.
79 State state_;
80
81 Delegate* delegate_;
82
83 DISALLOW_COPY_AND_ASSIGN(GCMClientImplAndroid);
84 };
85
86 } // namespace gcm
87
88 #endif // GOOGLE_APIS_GCM_GCM_CLIENT_IMPL_ANDROID_H_
OLDNEW
« 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