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

Unified Diff: chrome/browser/policy/cloud_policy_client.cc

Issue 12209070: Fix cloud policy duplicate registrations issue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 10 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/policy/cloud_policy_client.cc
diff --git a/chrome/browser/policy/cloud_policy_client.cc b/chrome/browser/policy/cloud_policy_client.cc
index 51f8ae3c8e09a6452e18ec6a6a73f501c62fc717..a7b08716b026d8b9c3a5deabc57a03e076c81958 100644
--- a/chrome/browser/policy/cloud_policy_client.cc
+++ b/chrome/browser/policy/cloud_policy_client.cc
@@ -110,6 +110,9 @@ void CloudPolicyClient::Register(em::DeviceRegisterRequest::Type type,
if (is_auto_enrollement)
request->set_auto_enrolled(true);
+ request_job_->SetRetryCallback(
+ base::Bind(&CloudPolicyClient::OnRetryRegister, base::Unretained(this)));
+
request_job_->Start(base::Bind(&CloudPolicyClient::OnRegisterCompleted,
base::Unretained(this)));
}
@@ -207,6 +210,16 @@ const em::PolicyFetchResponse* CloudPolicyClient::GetPolicyFor(
return it == responses_.end() ? NULL : it->second;
}
+void CloudPolicyClient::OnRetryRegister(DeviceManagementRequestJob* job) {
+ DCHECK_EQ(request_job_.get(), job);
+ // If the initial request managed to get to the server but the response didn't
+ // arrive at the client then retrying with the same client ID will fail.
+ // Set the re-registration flag so that the server accepts it.
+ // If the server hasn't seen the client ID before then it will also accept
+ // the re-registration.
+ job->GetRequest()->mutable_register_request()->set_reregister(true);
+}
+
void CloudPolicyClient::OnRegisterCompleted(
DeviceManagementStatus status,
const em::DeviceManagementResponse& response) {

Powered by Google App Engine
This is Rietveld 408576698