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

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

Issue 1258313002: Send GCM id to DMServer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adopt upstream protobuf changes Created 5 years, 4 months 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.cc
diff --git a/chrome/browser/chromeos/policy/heartbeat_scheduler.cc b/chrome/browser/chromeos/policy/heartbeat_scheduler.cc
index 4e4e4eff22166e6330b726a8238ad42e9256427c..a9109649dd59ef2996603b2b0f252dc59fa7615e 100644
--- a/chrome/browser/chromeos/policy/heartbeat_scheduler.cc
+++ b/chrome/browser/chromeos/policy/heartbeat_scheduler.cc
@@ -6,6 +6,8 @@
#include <string>
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/location.h"
#include "base/sequenced_task_runner.h"
@@ -160,6 +162,7 @@ void HeartbeatRegistrationHelper::OnRegisterAttemptComplete(
HeartbeatScheduler::HeartbeatScheduler(
gcm::GCMDriver* driver,
+ policy::CloudPolicyClient* cloud_policy_client,
const std::string& enrollment_domain,
const std::string& device_id,
const scoped_refptr<base::SequencedTaskRunner>& task_runner)
@@ -167,8 +170,9 @@ HeartbeatScheduler::HeartbeatScheduler(
enrollment_domain_(enrollment_domain),
device_id_(device_id),
heartbeat_enabled_(false),
- heartbeat_interval_(base::TimeDelta::FromMilliseconds(
- kDefaultHeartbeatIntervalMs)),
+ heartbeat_interval_(
+ base::TimeDelta::FromMilliseconds(kDefaultHeartbeatIntervalMs)),
+ cloud_policy_client_(cloud_policy_client),
gcm_driver_(driver),
weak_factory_(this) {
// If no GCMDriver (e.g. this is loaded as part of an unrelated unit test)
@@ -297,6 +301,15 @@ void HeartbeatScheduler::OnRegistrationComplete(
registration_helper_.reset();
registration_id_ = registration_id;
+ if (cloud_policy_client_) {
+ // TODO(binjin): Avoid sending the same GCM id to the server.
+ // See http://crbug.com/516375
+ cloud_policy_client_->UpdateGcmId(
+ registration_id,
+ base::Bind(&HeartbeatScheduler::OnGcmIdUpdateRequestSent,
+ weak_factory_.GetWeakPtr()));
+ }
+
// Now that GCM registration is complete, start sending heartbeats.
ScheduleNextHeartbeat();
}
@@ -372,4 +385,9 @@ void HeartbeatScheduler::OnSendAcknowledged(const std::string& app_id,
DVLOG(1) << "Heartbeat sent with message_id: " << message_id;
}
+void HeartbeatScheduler::OnGcmIdUpdateRequestSent(bool success) {
+ // TODO(binjin): Handle the failure, probably by exponential backoff.
+ LOG_IF(WARNING, !success) << "Failed to send GCM id to DM server";
+}
+
} // namespace policy
« no previous file with comments | « chrome/browser/chromeos/policy/heartbeat_scheduler.h ('k') | chrome/browser/chromeos/policy/heartbeat_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698