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

Unified Diff: chrome/browser/chromeos/policy/heartbeat_scheduler.h

Issue 1267983002: Signup for GCM upstream notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-registration
Patch Set: fix Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/heartbeat_scheduler.h
diff --git a/chrome/browser/chromeos/policy/heartbeat_scheduler.h b/chrome/browser/chromeos/policy/heartbeat_scheduler.h
index ab3140c612890872b28884fd7df1162ebe028345..d776cb7329b7af03466f870b999d009e76fd7f03 100644
--- a/chrome/browser/chromeos/policy/heartbeat_scheduler.h
+++ b/chrome/browser/chromeos/policy/heartbeat_scheduler.h
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "components/gcm_driver/gcm_app_handler.h"
#include "components/gcm_driver/gcm_client.h"
+#include "components/gcm_driver/gcm_connection_observer.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
namespace base {
@@ -33,7 +34,8 @@ class HeartbeatRegistrationHelper;
// Class responsible for periodically sending heartbeats to the policy service
// for monitoring device connectivity.
-class HeartbeatScheduler : public gcm::GCMAppHandler {
+class HeartbeatScheduler : public gcm::GCMAppHandler,
+ gcm::GCMConnectionObserver {
public:
// Default interval for how often we send up a heartbeat.
static const int64 kDefaultHeartbeatIntervalMs;
@@ -63,6 +65,9 @@ class HeartbeatScheduler : public gcm::GCMAppHandler {
void OnSendAcknowledged(const std::string& app_id,
const std::string& message_id) override;
+ // GCMConnectionObserver overrides.
+ void OnConnected(const net::IPEndPoint&) override;
+
private:
// Callback invoked periodically to send a heartbeat to the policy service.
void SendHeartbeat();
@@ -74,6 +79,10 @@ class HeartbeatScheduler : public gcm::GCMAppHandler {
void OnHeartbeatSent(const std::string& message_id,
gcm::GCMClient::Result result);
+ // Invoked after a upstream notification sign up message has been sent.
+ void OnUpstreamNotificationSent(const std::string& message_id,
+ gcm::GCMClient::Result result);
+
// Helper method that figures out when the next heartbeat should
// be scheduled.
void ScheduleNextHeartbeat();
@@ -92,6 +101,9 @@ class HeartbeatScheduler : public gcm::GCMAppHandler {
// Callback for the GCM id update request.
void OnGcmIdUpdateRequestSent(bool status);
+ // Helper function to signup for upstream notification.
+ void SignUpUpstreamNotification();
+
// TaskRunner used for scheduling heartbeats.
const scoped_refptr<base::SequencedTaskRunner> task_runner_;
@@ -134,6 +146,10 @@ class HeartbeatScheduler : public gcm::GCMAppHandler {
// destroyed.
bool registered_app_handler_ = false;
+ // Last upstream notification sign up time, a null value represents never
+ // signed up before.
+ base::TimeTicks last_upstream_notification_signup_time_;
+
// Helper class to manage registering with the GCM server, including
// retries, etc.
scoped_ptr<HeartbeatRegistrationHelper> registration_helper_;

Powered by Google App Engine
This is Rietveld 408576698