| 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 "components/gcm_driver/gcm_driver.h" | 14 #include "components/gcm_driver/gcm_driver.h" |
| 15 #include "components/gcm_driver/gcm_stats_recorder_android.h" |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class FilePath; | 18 class FilePath; |
| 18 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace gcm { | 22 namespace gcm { |
| 22 | 23 |
| 23 // GCMDriver implementation for Android, using Android GCM APIs. | 24 // GCMDriver implementation for Android, using Android GCM APIs. |
| 24 class GCMDriverAndroid : public GCMDriver { | 25 class GCMDriverAndroid : public GCMDriver, |
| 26 public GCMStatsRecorderAndroid::Delegate { |
| 25 public: | 27 public: |
| 26 GCMDriverAndroid( | 28 GCMDriverAndroid( |
| 27 const base::FilePath& store_path, | 29 const base::FilePath& store_path, |
| 28 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); | 30 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner); |
| 29 ~GCMDriverAndroid() override; | 31 ~GCMDriverAndroid() override; |
| 30 | 32 |
| 31 // Methods called from Java via JNI: | 33 // Methods called from Java via JNI: |
| 32 void OnRegisterFinished( | 34 void OnRegisterFinished( |
| 33 JNIEnv* env, | 35 JNIEnv* env, |
| 34 const base::android::JavaParamRef<jobject>& obj, | 36 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; | 74 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; |
| 73 void UpdateAccountMapping(const AccountMapping& account_mapping) override; | 75 void UpdateAccountMapping(const AccountMapping& account_mapping) override; |
| 74 void RemoveAccountMapping(const std::string& account_id) override; | 76 void RemoveAccountMapping(const std::string& account_id) override; |
| 75 base::Time GetLastTokenFetchTime() override; | 77 base::Time GetLastTokenFetchTime() override; |
| 76 void SetLastTokenFetchTime(const base::Time& time) override; | 78 void SetLastTokenFetchTime(const base::Time& time) override; |
| 77 void WakeFromSuspendForHeartbeat(bool wake) override; | 79 void WakeFromSuspendForHeartbeat(bool wake) override; |
| 78 InstanceIDHandler* GetInstanceIDHandler() override; | 80 InstanceIDHandler* GetInstanceIDHandler() override; |
| 79 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; | 81 void AddHeartbeatInterval(const std::string& scope, int interval_ms) override; |
| 80 void RemoveHeartbeatInterval(const std::string& scope) override; | 82 void RemoveHeartbeatInterval(const std::string& scope) override; |
| 81 | 83 |
| 84 // GCMStatsRecorder::Delegate implementation: |
| 85 void OnActivityRecorded() override; |
| 86 |
| 82 protected: | 87 protected: |
| 83 // GCMDriver implementation: | 88 // GCMDriver implementation: |
| 84 GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) override; | 89 GCMClient::Result EnsureStarted(GCMClient::StartMode start_mode) override; |
| 85 void RegisterImpl(const std::string& app_id, | 90 void RegisterImpl(const std::string& app_id, |
| 86 const std::vector<std::string>& sender_ids) override; | 91 const std::vector<std::string>& sender_ids) override; |
| 87 void UnregisterImpl(const std::string& app_id) override; | 92 void UnregisterImpl(const std::string& app_id) override; |
| 88 void UnregisterWithSenderIdImpl(const std::string& app_id, | 93 void UnregisterWithSenderIdImpl(const std::string& app_id, |
| 89 const std::string& sender_id) override; | 94 const std::string& sender_id) override; |
| 90 void SendImpl(const std::string& app_id, | 95 void SendImpl(const std::string& app_id, |
| 91 const std::string& receiver_id, | 96 const std::string& receiver_id, |
| 92 const OutgoingMessage& message) override; | 97 const OutgoingMessage& message) override; |
| 93 | 98 |
| 94 private: | 99 private: |
| 95 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 100 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 96 | 101 |
| 102 // Callback for GetGCMStatistics. |
| 103 GetGCMStatisticsCallback get_gcm_statistics_callback_; |
| 104 |
| 105 // Recorder that logs GCM activities. |
| 106 GCMStatsRecorderAndroid recorder_; |
| 107 |
| 97 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid); | 108 DISALLOW_COPY_AND_ASSIGN(GCMDriverAndroid); |
| 98 }; | 109 }; |
| 99 | 110 |
| 100 } // namespace gcm | 111 } // namespace gcm |
| 101 | 112 |
| 102 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H | 113 #endif // COMPONENTS_GCM_DRIVER_GCM_DRIVER_ANDROID_H |
| OLD | NEW |