OLD | NEW |
---|---|
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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 SetState(STATE_TOKEN_UNMANAGED); | 249 SetState(STATE_TOKEN_UNMANAGED); |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 void CloudPolicyController::SendPolicyRequest() { | 254 void CloudPolicyController::SendPolicyRequest() { |
255 backend_.reset(service_->CreateBackend()); | 255 backend_.reset(service_->CreateBackend()); |
256 DCHECK(!data_store_->device_token().empty()); | 256 DCHECK(!data_store_->device_token().empty()); |
257 em::DevicePolicyRequest policy_request; | 257 em::DevicePolicyRequest policy_request; |
258 em::PolicyFetchRequest* fetch_request = policy_request.add_request(); | 258 em::PolicyFetchRequest* fetch_request = policy_request.add_request(); |
259 em::DeviceStatusReportRequest device_status; | |
259 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); | 260 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); |
260 fetch_request->set_policy_type(data_store_->policy_type()); | 261 fetch_request->set_policy_type(data_store_->policy_type()); |
261 if (!cache_->is_unmanaged() && | 262 if (!cache_->is_unmanaged() && |
262 !cache_->last_policy_refresh_time().is_null()) { | 263 !cache_->last_policy_refresh_time().is_null()) { |
263 base::TimeDelta timestamp = | 264 base::TimeDelta timestamp = |
264 cache_->last_policy_refresh_time() - base::Time::UnixEpoch(); | 265 cache_->last_policy_refresh_time() - base::Time::UnixEpoch(); |
265 fetch_request->set_timestamp(timestamp.InMilliseconds()); | 266 fetch_request->set_timestamp(timestamp.InMilliseconds()); |
266 } | 267 } |
267 int key_version = 0; | 268 int key_version = 0; |
268 if (cache_->GetPublicKeyVersion(&key_version)) | 269 if (cache_->GetPublicKeyVersion(&key_version)) |
269 fetch_request->set_public_key_version(key_version); | 270 fetch_request->set_public_key_version(key_version); |
270 | 271 |
272 data_store_->device_status_reporter()->GetStatus(&device_status); | |
273 | |
271 backend_->ProcessPolicyRequest(data_store_->device_token(), | 274 backend_->ProcessPolicyRequest(data_store_->device_token(), |
272 data_store_->device_id(), | 275 data_store_->device_id(), |
273 data_store_->user_affiliation(), | 276 data_store_->user_affiliation(), |
274 policy_request, this); | 277 policy_request, device_status, this); |
Mattias Nissler (ping if slow)
2011/11/25 14:15:19
One thing: We should reset our status counters aft
Patrick Dubroy
2011/11/29 18:01:46
Yeah, I was sure whether I should reset the data a
| |
275 } | 278 } |
276 | 279 |
277 void CloudPolicyController::DoWork() { | 280 void CloudPolicyController::DoWork() { |
278 switch (state_) { | 281 switch (state_) { |
279 case STATE_TOKEN_UNAVAILABLE: | 282 case STATE_TOKEN_UNAVAILABLE: |
280 case STATE_TOKEN_ERROR: | 283 case STATE_TOKEN_ERROR: |
281 FetchToken(); | 284 FetchToken(); |
282 return; | 285 return; |
283 case STATE_TOKEN_VALID: | 286 case STATE_TOKEN_VALID: |
284 case STATE_POLICY_VALID: | 287 case STATE_POLICY_VALID: |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 } | 381 } |
379 | 382 |
380 int64 CloudPolicyController::GetRefreshDelay() { | 383 int64 CloudPolicyController::GetRefreshDelay() { |
381 int64 deviation = (kPolicyRefreshDeviationFactorPercent * | 384 int64 deviation = (kPolicyRefreshDeviationFactorPercent * |
382 policy_refresh_rate_ms_) / 100; | 385 policy_refresh_rate_ms_) / 100; |
383 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds); | 386 deviation = std::min(deviation, kPolicyRefreshDeviationMaxInMilliseconds); |
384 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); | 387 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); |
385 } | 388 } |
386 | 389 |
387 } // namespace policy | 390 } // namespace policy |
OLD | NEW |