OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H | 5 #ifndef COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H |
6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H | 6 #define COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 | 9 |
10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | |
Nicolas Zea
2015/12/16 22:24:32
is this needed?
Peter Beverloo
2015/12/17 17:08:24
No. Removed.
| |
14 #include "components/gcm_driver/gcm_driver.h" | 15 #include "components/gcm_driver/gcm_driver.h" |
16 #include "components/gcm_driver/gcm_stats_recorder_android.h" | |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 class FilePath; | 19 class FilePath; |
18 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
19 } | 21 } |
20 | 22 |
21 namespace gcm { | 23 namespace gcm { |
22 | 24 |
23 // GCMDriver implementation for Android, using Android GCM APIs. | 25 // GCMDriver implementation for Android, using Android GCM APIs. |
24 class GCMDriverAndroid : public GCMDriver { | 26 class GCMDriverAndroid : public GCMDriver, |
27 public GCMStatsRecorderAndroid::Delegate { | |
25 public: | 28 public: |
26 GCMDriverAndroid( | 29 GCMDriverAndroid( |
27 const base::FilePath& store_path, | 30 const base::FilePath& store_path, |
28 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); | 31 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); |
29 ~GCMDriverAndroid() override; | 32 ~GCMDriverAndroid() override; |
30 | 33 |
31 // Methods called from Java via JNI: | 34 // Methods called from Java via JNI: |
32 void OnRegisterFinished( | 35 void OnRegisterFinished( |
33 JNIEnv* env, | 36 JNIEnv* env, |
34 const base::android::JavaParamRef<jobject>& obj, | 37 const base::android::JavaParamRef<jobject>& obj, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; | 75 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; |
73 void UpdateAccountMapping(const AccountMapping& account_mapping) override; | 76 void UpdateAccountMapping(const AccountMapping& account_mapping) override; |
74 void RemoveAccountMapping(const std::string& account_id) override; | 77 void RemoveAccountMapping(const std::string& account_id) override; |
75 base::Time GetLastTokenFetchTime() override; | 78 base::Time GetLastTokenFetchTime() override; |
76 void SetLastTokenFetchTime(const base::Time& time) override; | 79 void SetLastTokenFetchTime(const base::Time& time) override; |
77 void WakeFromSuspendForHeartbeat(bool wake) override; | 80 void WakeFromSuspendForHeartbeat(bool wake) override; |
78 InstanceIDHandler* GetInstanceIDHandler() override; | 81 InstanceIDHandler* GetInstanceIDHandler() override; |
79 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; | 82 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; |
80 void RemoveHeartbeatInterval(const std::string& scope) override; | 83 void RemoveHeartbeatInterval(const std::string& scope) override; |
81 | 84 |
85 // GCMStatsRecorder::Delegate implementation: | |
86 void OnActivityRecorded() override; | |
87 | |
82 protected: | 88 protected: |
83 // GCMDriver implementation: | 89 // GCMDriver implementation: |
84 GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) override; | 90 GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) override; |
85 void RegisterImpl(const std::string& app_id, | 91 void RegisterImpl(const std::string& app_id, |
86 const std::vector<std::string>& sender_ids) override; | 92 const std::vector<std::string>& sender_ids) override; |
87 void UnregisterImpl(const std::string& app_id) override; | 93 void UnregisterImpl(const std::string& app_id) override; |
88 void UnregisterWithSenderIdImpl(const std::string& app_id, | 94 void UnregisterWithSenderIdImpl(const std::string& app_id, |
89 const std::string& sender_id) override; | 95 const std::string& sender_id) override; |
90 void SendImpl(const std::string& app_id, | 96 void SendImpl(const std::string& app_id, |
91 const std::string& receiver_id, | 97 const std::string& receiver_id, |
92 const OutgoingMessage& message) override; | 98 const OutgoingMessage& message) override; |
93 | 99 |
94 private: | 100 private: |
95 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 101 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
96 | 102 |
103 // Callback for GetGCMStatistics. | |
104 GetGCMStatisticsCallback get_gcm_statistics_callback_; | |
105 | |
106 // Recorder that logs GCM activities. | |
107 GCMStatsRecorderAndroid recorder_; | |
108 | |
97 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid); | 109 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid); |
98 }; | 110 }; |
99 | 111 |
100 } // namespace gcm | 112 } // namespace gcm |
101 | 113 |
102 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H | 114 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H |
OLD | NEW |