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

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: rebase 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
« no previous file with comments | « chrome/browser/policy/cloud_policy_client.h ('k') | chrome/browser/policy/cloud_policy_client_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fd26912c276967dd322c454768b4dfc1989bd581..9db7d34e595ff09864f6ab354b91a7bbee882eca 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) {
« no previous file with comments | « chrome/browser/policy/cloud_policy_client.h ('k') | chrome/browser/policy/cloud_policy_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698