cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / gcm_driver / gcm_driver_android.h
blobc894973c82791df45a6f9782d4c8042ca9051075
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 "base/memory/ref_counted.h"
14 #include "components/gcm_driver/gcm_driver.h"
16 namespace base {
17 class FilePath;
18 class SequencedTaskRunner;
21 namespace gcm {
23 // GCMDriver implementation for Android, using Android GCM APIs.
24 class GCMDriverAndroid : public GCMDriver {
25 public:
26 GCMDriverAndroid(
27 const base::FilePath& store_path,
28 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner);
29 ~GCMDriverAndroid() override;
31 // Methods called from Java via JNI:
32 void OnRegisterFinished(JNIEnv* env,
33 jobject obj,
34 jstring app_id,
35 jstring registration_id,
36 jboolean success);
37 void OnUnregisterFinished(JNIEnv* env,
38 jobject obj,
39 jstring app_id,
40 jboolean success);
41 void OnMessageReceived(JNIEnv* env,
42 jobject obj,
43 jstring app_id,
44 jstring sender_id,
45 jstring collapse_key,
46 jbyteArray raw_data,
47 jobjectArray data_keys_and_values);
48 void OnMessagesDeleted(JNIEnv* env,
49 jobject obj,
50 jstring app_id);
52 // Register JNI methods.
53 static bool RegisterBindings(JNIEnv* env);
55 // GCMDriver implementation:
56 void OnSignedIn() override;
57 void OnSignedOut() override;
58 void Enable() override;
59 void AddConnectionObserver(GCMConnectionObserver* observer) override;
60 void RemoveConnectionObserver(GCMConnectionObserver* observer) override;
61 void Disable() override;
62 GCMClient* GetGCMClientForTesting() const override;
63 bool IsStarted() const override;
64 bool IsConnected() const override;
65 void GetGCMStatistics(const GetGCMStatisticsCallback& callback,
66 bool clear_logs) override;
67 void SetGCMRecording(const GetGCMStatisticsCallback& callback,
68 bool recording) override;
69 void SetAccountTokens(
70 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override;
71 void UpdateAccountMapping(const AccountMapping& account_mapping) override;
72 void RemoveAccountMapping(const std::string& account_id) override;
73 base::Time GetLastTokenFetchTime() override;
74 void SetLastTokenFetchTime(const base::Time& time) override;
75 void WakeFromSuspendForHeartbeat(bool wake) override;
76 InstanceIDHandler* GetInstanceIDHandler() override;
77 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override;
78 void RemoveHeartbeatInterval(const std::string& scope) override;
80 protected:
81 // GCMDriver implementation:
82 GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) override;
83 void RegisterImpl(const std::string& app_id,
84 const std::vector<std::string>& sender_ids) override;
85 void UnregisterImpl(const std::string& app_id) override;
86 void UnregisterWithSenderIdImpl(const std::string& app_id,
87 const std::string& sender_id) override;
88 void SendImpl(const std::string& app_id,
89 const std::string& receiver_id,
90 const OutgoingMessage& message) override;
92 private:
93 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
95 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid);
98 } // namespace gcm
100 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H