| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/attestation/attestation_policy_observer.h" | 5 #include "chrome/browser/chromeos/attestation/attestation_policy_observer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 AttestationPolicyObserver::AttestationPolicyObserver( | 93 AttestationPolicyObserver::AttestationPolicyObserver( |
| 94 policy::CloudPolicyClient* policy_client) | 94 policy::CloudPolicyClient* policy_client) |
| 95 : cros_settings_(CrosSettings::Get()), | 95 : cros_settings_(CrosSettings::Get()), |
| 96 policy_client_(policy_client), | 96 policy_client_(policy_client), |
| 97 cryptohome_client_(NULL), | 97 cryptohome_client_(NULL), |
| 98 attestation_flow_(NULL), | 98 attestation_flow_(NULL), |
| 99 num_retries_(0), | 99 num_retries_(0), |
| 100 retry_delay_(kRetryDelay), | 100 retry_delay_(kRetryDelay), |
| 101 weak_factory_(this) { | 101 weak_factory_(this) { |
| 102 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 102 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 103 attestation_subscription_ = cros_settings_->AddSettingsObserver( | 103 attestation_subscription_ = cros_settings_->AddSettingsObserver( |
| 104 kDeviceAttestationEnabled, | 104 kDeviceAttestationEnabled, |
| 105 base::Bind(&AttestationPolicyObserver::AttestationSettingChanged, | 105 base::Bind(&AttestationPolicyObserver::AttestationSettingChanged, |
| 106 base::Unretained(this))); | 106 base::Unretained(this))); |
| 107 Start(); | 107 Start(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 AttestationPolicyObserver::AttestationPolicyObserver( | 110 AttestationPolicyObserver::AttestationPolicyObserver( |
| 111 policy::CloudPolicyClient* policy_client, | 111 policy::CloudPolicyClient* policy_client, |
| 112 CryptohomeClient* cryptohome_client, | 112 CryptohomeClient* cryptohome_client, |
| 113 AttestationFlow* attestation_flow) | 113 AttestationFlow* attestation_flow) |
| 114 : cros_settings_(CrosSettings::Get()), | 114 : cros_settings_(CrosSettings::Get()), |
| 115 policy_client_(policy_client), | 115 policy_client_(policy_client), |
| 116 cryptohome_client_(cryptohome_client), | 116 cryptohome_client_(cryptohome_client), |
| 117 attestation_flow_(attestation_flow), | 117 attestation_flow_(attestation_flow), |
| 118 num_retries_(0), | 118 num_retries_(0), |
| 119 retry_delay_(kRetryDelay), | 119 retry_delay_(kRetryDelay), |
| 120 weak_factory_(this) { | 120 weak_factory_(this) { |
| 121 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 121 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 122 attestation_subscription_ = cros_settings_->AddSettingsObserver( | 122 attestation_subscription_ = cros_settings_->AddSettingsObserver( |
| 123 kDeviceAttestationEnabled, | 123 kDeviceAttestationEnabled, |
| 124 base::Bind(&AttestationPolicyObserver::AttestationSettingChanged, | 124 base::Bind(&AttestationPolicyObserver::AttestationSettingChanged, |
| 125 base::Unretained(this))); | 125 base::Unretained(this))); |
| 126 Start(); | 126 Start(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 AttestationPolicyObserver::~AttestationPolicyObserver() { | 129 AttestationPolicyObserver::~AttestationPolicyObserver() { |
| 130 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 130 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void AttestationPolicyObserver::AttestationSettingChanged() { | 133 void AttestationPolicyObserver::AttestationSettingChanged() { |
| 134 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 134 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 135 num_retries_ = 0; | 135 num_retries_ = 0; |
| 136 Start(); | 136 Start(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void AttestationPolicyObserver::Start() { | 139 void AttestationPolicyObserver::Start() { |
| 140 // If attestation is not enabled, there is nothing to do. | 140 // If attestation is not enabled, there is nothing to do. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 base::Bind(&AttestationPolicyObserver::Start, | 303 base::Bind(&AttestationPolicyObserver::Start, |
| 304 weak_factory_.GetWeakPtr()), | 304 weak_factory_.GetWeakPtr()), |
| 305 base::TimeDelta::FromSeconds(retry_delay_)); | 305 base::TimeDelta::FromSeconds(retry_delay_)); |
| 306 } else { | 306 } else { |
| 307 LOG(WARNING) << "AttestationPolicyObserver: Retry limit exceeded."; | 307 LOG(WARNING) << "AttestationPolicyObserver: Retry limit exceeded."; |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 | 310 |
| 311 } // namespace attestation | 311 } // namespace attestation |
| 312 } // namespace chromeos | 312 } // namespace chromeos |
| OLD | NEW |