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

Side by Side Diff: chrome/browser/policy/cloud_policy_controller.cc

Issue 8702009: Add device status reports to policy requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove some now-dead code. Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/policy/cloud_policy_controller.h" 5 #include "chrome/browser/policy/cloud_policy_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } else { 255 } else {
256 VLOG(1) << "Not ready to fetch DMToken yet, will try again later."; 256 VLOG(1) << "Not ready to fetch DMToken yet, will try again later.";
257 } 257 }
258 } 258 }
259 259
260 void CloudPolicyController::SendPolicyRequest() { 260 void CloudPolicyController::SendPolicyRequest() {
261 backend_.reset(service_->CreateBackend()); 261 backend_.reset(service_->CreateBackend());
262 DCHECK(!data_store_->device_token().empty()); 262 DCHECK(!data_store_->device_token().empty());
263 em::DevicePolicyRequest policy_request; 263 em::DevicePolicyRequest policy_request;
264 em::PolicyFetchRequest* fetch_request = policy_request.add_request(); 264 em::PolicyFetchRequest* fetch_request = policy_request.add_request();
265 em::DeviceStatusReportRequest device_status;
265 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); 266 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA);
266 fetch_request->set_policy_type(data_store_->policy_type()); 267 fetch_request->set_policy_type(data_store_->policy_type());
267 if (!cache_->is_unmanaged() && 268 if (!cache_->is_unmanaged() &&
268 !cache_->last_policy_refresh_time().is_null()) { 269 !cache_->last_policy_refresh_time().is_null()) {
269 base::TimeDelta timestamp = 270 base::TimeDelta timestamp =
270 cache_->last_policy_refresh_time() - base::Time::UnixEpoch(); 271 cache_->last_policy_refresh_time() - base::Time::UnixEpoch();
271 fetch_request->set_timestamp(timestamp.InMilliseconds()); 272 fetch_request->set_timestamp(timestamp.InMilliseconds());
272 } 273 }
273 int key_version = 0; 274 int key_version = 0;
274 if (cache_->GetPublicKeyVersion(&key_version)) 275 if (cache_->GetPublicKeyVersion(&key_version))
275 fetch_request->set_public_key_version(key_version); 276 fetch_request->set_public_key_version(key_version);
276 277
278 if (data_store_->device_status_collector())
279 data_store_->device_status_collector()->GetStatus(&device_status);
280
277 backend_->ProcessPolicyRequest(data_store_->device_token(), 281 backend_->ProcessPolicyRequest(data_store_->device_token(),
278 data_store_->device_id(), 282 data_store_->device_id(),
279 data_store_->user_affiliation(), 283 data_store_->user_affiliation(),
280 policy_request, this); 284 policy_request, &device_status, this);
281 } 285 }
282 286
283 void CloudPolicyController::DoWork() { 287 void CloudPolicyController::DoWork() {
284 switch (state_) { 288 switch (state_) {
285 case STATE_TOKEN_UNAVAILABLE: 289 case STATE_TOKEN_UNAVAILABLE:
286 case STATE_TOKEN_ERROR: 290 case STATE_TOKEN_ERROR:
287 FetchToken(); 291 FetchToken();
288 return; 292 return;
289 case STATE_TOKEN_VALID: 293 case STATE_TOKEN_VALID:
290 case STATE_POLICY_VALID: 294 case STATE_POLICY_VALID:
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 388 }
385 389
386 int64 CloudPolicyController::GetRefreshDelay() { 390 int64 CloudPolicyController::GetRefreshDelay() {
387 int64 deviation = (kPolicyRefreshDeviationFactorPercent * 391 int64 deviation = (kPolicyRefreshDeviationFactorPercent *
388 policy_refresh_rate_ms_) / 100; 392 policy_refresh_rate_ms_) / 100;
389 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds); 393 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds);
390 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); 394 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1);
391 } 395 }
392 396
393 } // namespace policy 397 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.cc ('k') | chrome/browser/policy/cloud_policy_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698