OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/platform_verification_flow.h" | 5 #include "chrome/browser/chromeos/attestation/platform_verification_flow.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 PlatformVerificationFlow::ChallengeContext::~ChallengeContext() {} | 150 PlatformVerificationFlow::ChallengeContext::~ChallengeContext() {} |
151 | 151 |
152 PlatformVerificationFlow::PlatformVerificationFlow() | 152 PlatformVerificationFlow::PlatformVerificationFlow() |
153 : attestation_flow_(NULL), | 153 : attestation_flow_(NULL), |
154 async_caller_(cryptohome::AsyncMethodCaller::GetInstance()), | 154 async_caller_(cryptohome::AsyncMethodCaller::GetInstance()), |
155 cryptohome_client_(DBusThreadManager::Get()->GetCryptohomeClient()), | 155 cryptohome_client_(DBusThreadManager::Get()->GetCryptohomeClient()), |
156 delegate_(NULL), | 156 delegate_(NULL), |
157 timeout_delay_(base::TimeDelta::FromSeconds(kTimeoutInSeconds)) { | 157 timeout_delay_(base::TimeDelta::FromSeconds(kTimeoutInSeconds)) { |
158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
159 scoped_ptr<ServerProxy> attestation_ca_client(new AttestationCAClient()); | 159 std::unique_ptr<ServerProxy> attestation_ca_client(new AttestationCAClient()); |
160 default_attestation_flow_.reset(new AttestationFlow( | 160 default_attestation_flow_.reset(new AttestationFlow( |
161 async_caller_, cryptohome_client_, std::move(attestation_ca_client))); | 161 async_caller_, cryptohome_client_, std::move(attestation_ca_client))); |
162 attestation_flow_ = default_attestation_flow_.get(); | 162 attestation_flow_ = default_attestation_flow_.get(); |
163 default_delegate_.reset(new DefaultDelegate()); | 163 default_delegate_.reset(new DefaultDelegate()); |
164 delegate_ = default_delegate_.get(); | 164 delegate_ = default_delegate_.get(); |
165 } | 165 } |
166 | 166 |
167 PlatformVerificationFlow::PlatformVerificationFlow( | 167 PlatformVerificationFlow::PlatformVerificationFlow( |
168 AttestationFlow* attestation_flow, | 168 AttestationFlow* attestation_flow, |
169 cryptohome::AsyncMethodCaller* async_caller, | 169 cryptohome::AsyncMethodCaller* async_caller, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return; | 250 return; |
251 } | 251 } |
252 | 252 |
253 GetCertificate(context, user->GetAccountId(), | 253 GetCertificate(context, user->GetAccountId(), |
254 false /* Don't force a new key */); | 254 false /* Don't force a new key */); |
255 } | 255 } |
256 | 256 |
257 void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context, | 257 void PlatformVerificationFlow::GetCertificate(const ChallengeContext& context, |
258 const AccountId& account_id, | 258 const AccountId& account_id, |
259 bool force_new_key) { | 259 bool force_new_key) { |
260 scoped_ptr<base::Timer> timer(new base::Timer(false, // Don't retain. | 260 std::unique_ptr<base::Timer> timer(new base::Timer(false, // Don't retain. |
261 false)); // Don't repeat. | 261 false)); // Don't repeat. |
262 base::Closure timeout_callback = base::Bind( | 262 base::Closure timeout_callback = base::Bind( |
263 &PlatformVerificationFlow::OnCertificateTimeout, | 263 &PlatformVerificationFlow::OnCertificateTimeout, |
264 this, | 264 this, |
265 context); | 265 context); |
266 timer->Start(FROM_HERE, timeout_delay_, timeout_callback); | 266 timer->Start(FROM_HERE, timeout_delay_, timeout_callback); |
267 | 267 |
268 AttestationFlow::CertificateCallback certificate_callback = | 268 AttestationFlow::CertificateCallback certificate_callback = |
269 base::Bind(&PlatformVerificationFlow::OnCertificateReady, this, context, | 269 base::Bind(&PlatformVerificationFlow::OnCertificateReady, this, context, |
270 account_id, base::Passed(&timer)); | 270 account_id, base::Passed(&timer)); |
271 attestation_flow_->GetCertificate(PROFILE_CONTENT_PROTECTION_CERTIFICATE, | 271 attestation_flow_->GetCertificate(PROFILE_CONTENT_PROTECTION_CERTIFICATE, |
272 account_id, context.service_id, | 272 account_id, context.service_id, |
273 force_new_key, certificate_callback); | 273 force_new_key, certificate_callback); |
274 } | 274 } |
275 | 275 |
276 void PlatformVerificationFlow::OnCertificateReady( | 276 void PlatformVerificationFlow::OnCertificateReady( |
277 const ChallengeContext& context, | 277 const ChallengeContext& context, |
278 const AccountId& account_id, | 278 const AccountId& account_id, |
279 scoped_ptr<base::Timer> timer, | 279 std::unique_ptr<base::Timer> timer, |
280 bool operation_success, | 280 bool operation_success, |
281 const std::string& certificate_chain) { | 281 const std::string& certificate_chain) { |
282 // Log failure before checking the timer so all failures are logged, even if | 282 // Log failure before checking the timer so all failures are logged, even if |
283 // they took too long. | 283 // they took too long. |
284 if (!operation_success) { | 284 if (!operation_success) { |
285 LOG(WARNING) << "PlatformVerificationFlow: Failed to certify platform."; | 285 LOG(WARNING) << "PlatformVerificationFlow: Failed to certify platform."; |
286 } | 286 } |
287 if (!timer->IsRunning()) { | 287 if (!timer->IsRunning()) { |
288 LOG(WARNING) << "PlatformVerificationFlow: Certificate ready but call has " | 288 LOG(WARNING) << "PlatformVerificationFlow: Certificate ready but call has " |
289 << "already timed out."; | 289 << "already timed out."; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (!operation_success) { | 422 if (!operation_success) { |
423 LOG(WARNING) << "PlatformVerificationFlow: Failed to renew platform " | 423 LOG(WARNING) << "PlatformVerificationFlow: Failed to renew platform " |
424 "certificate."; | 424 "certificate."; |
425 return; | 425 return; |
426 } | 426 } |
427 VLOG(1) << "Certificate successfully renewed."; | 427 VLOG(1) << "Certificate successfully renewed."; |
428 } | 428 } |
429 | 429 |
430 } // namespace attestation | 430 } // namespace attestation |
431 } // namespace chromeos | 431 } // namespace chromeos |
OLD | NEW |