Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / components / gcm_driver / gcm_driver_android.h
bloba3c19e1ffa6e428f460bb43078ced8eb8d973138
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.
5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H
8 #include <jni.h>
10 #include "base/android/scoped_java_ref.h"
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13 #include "components/gcm_driver/gcm_driver.h"
15 namespace gcm {
17 // GCMDriver implementation for Android, using Android GCM APIs.
18 class GCMDriverAndroid : public GCMDriver {
19 public:
20 GCMDriverAndroid();
21 virtual ~GCMDriverAndroid();
23 // Methods called from Java via JNI:
24 void OnRegisterFinished(JNIEnv* env,
25 jobject obj,
26 jstring app_id,
27 jstring registration_id,
28 jboolean success);
29 void OnUnregisterFinished(JNIEnv* env,
30 jobject obj,
31 jstring app_id,
32 jboolean success);
33 void OnMessageReceived(JNIEnv* env,
34 jobject obj,
35 jstring app_id,
36 jstring sender_id,
37 jstring collapse_key,
38 jobjectArray data_keys_and_values);
39 void OnMessagesDeleted(JNIEnv* env,
40 jobject obj,
41 jstring app_id);
43 // Register JNI methods.
44 static bool RegisterBindings(JNIEnv* env);
46 // GCMDriver implementation:
47 virtual void OnSignedIn() override;
48 virtual void OnSignedOut() override;
49 virtual void Purge() override;
50 virtual void Enable() override;
51 virtual void AddConnectionObserver(GCMConnectionObserver* observer) override;
52 virtual void RemoveConnectionObserver(
53 GCMConnectionObserver* observer) override;
54 virtual void Disable() override;
55 virtual GCMClient* GetGCMClientForTesting() const override;
56 virtual bool IsStarted() const override;
57 virtual bool IsConnected() const override;
58 virtual void GetGCMStatistics(const GetGCMStatisticsCallback& callback,
59 bool clear_logs) override;
60 virtual void SetGCMRecording(const GetGCMStatisticsCallback& callback,
61 bool recording) override;
62 virtual void SetAccountTokens(
63 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override;
64 virtual void UpdateAccountMapping(
65 const AccountMapping& account_mapping) override;
66 virtual void RemoveAccountMapping(const std::string& account_id) override;
67 virtual base::Time GetLastTokenFetchTime() override;
68 virtual void SetLastTokenFetchTime(const base::Time& time) override;
70 protected:
71 // GCMDriver implementation:
72 virtual GCMClient::Result EnsureStarted() override;
73 virtual void RegisterImpl(
74 const std::string& app_id,
75 const std::vector<std::string>& sender_ids) override;
76 virtual void UnregisterImpl(const std::string& app_id) override;
77 virtual void SendImpl(const std::string& app_id,
78 const std::string& receiver_id,
79 const GCMClient::OutgoingMessage& message) override;
81 private:
82 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
84 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid);
87 } // namespace gcm
89 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H