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 "chromeos/cert_loader.h" | 5 #include "chromeos/cert_loader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 // Cap the delay to prevent an overflow. This threshold is arbitrarily chosen. | 38 // Cap the delay to prevent an overflow. This threshold is arbitrarily chosen. |
39 const base::TimeDelta max_delay = | 39 const base::TimeDelta max_delay = |
40 base::TimeDelta::FromMilliseconds(kMaxRequestDelayMs); | 40 base::TimeDelta::FromMilliseconds(kMaxRequestDelayMs); |
41 if (next_delay > max_delay) | 41 if (next_delay > max_delay) |
42 next_delay = max_delay; | 42 next_delay = max_delay; |
43 return next_delay; | 43 return next_delay; |
44 } | 44 } |
45 | 45 |
46 void LoadNSSCertificates(net::CertificateList* cert_list) { | 46 void LoadNSSCertificates(net::CertificateList* cert_list) { |
47 if (base::chromeos::IsRunningOnChromeOS()) | 47 net::NSSCertDatabase::GetInstance()->ListCerts(cert_list); |
48 net::NSSCertDatabase::GetInstance()->ListCerts(cert_list); | |
49 } | 48 } |
50 | 49 |
51 void CallOpenPersistentNSSDB() { | 50 void CallOpenPersistentNSSDB() { |
52 // Called from crypto_task_runner_. | 51 // Called from crypto_task_runner_. |
53 VLOG(1) << "CallOpenPersistentNSSDB"; | 52 VLOG(1) << "CallOpenPersistentNSSDB"; |
54 | 53 |
55 // Ensure we've opened the user's key/certificate database. | 54 // Ensure we've opened the user's key/certificate database. |
56 crypto::OpenPersistentNSSDB(); | 55 crypto::OpenPersistentNSSDB(); |
57 if (base::chromeos::IsRunningOnChromeOS()) | 56 if (base::chromeos::IsRunningOnChromeOS()) |
58 crypto::EnableTPMTokenForNSS(); | 57 crypto::EnableTPMTokenForNSS(); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 } | 337 } |
339 | 338 |
340 void CertLoader::UpdateCertificates(net::CertificateList* cert_list) { | 339 void CertLoader::UpdateCertificates(net::CertificateList* cert_list) { |
341 CHECK(thread_checker_.CalledOnValidThread()); | 340 CHECK(thread_checker_.CalledOnValidThread()); |
342 DCHECK(certificates_update_running_); | 341 DCHECK(certificates_update_running_); |
343 VLOG(1) << "UpdateCertificates: " << cert_list->size(); | 342 VLOG(1) << "UpdateCertificates: " << cert_list->size(); |
344 | 343 |
345 // Ignore any existing certificates. | 344 // Ignore any existing certificates. |
346 cert_list_.swap(*cert_list); | 345 cert_list_.swap(*cert_list); |
347 | 346 |
348 NotifyCertificatesLoaded(!certificates_loaded_); | |
349 certificates_loaded_ = true; | 347 certificates_loaded_ = true; |
348 NotifyCertificatesLoaded(certificates_loaded_); | |
stevenjb
2013/07/26 19:40:53
This will never call NotifyCertificatesLoaded with
pneubeck (no reviews)
2013/07/29 06:19:40
Oh. totally missed that.
| |
350 | 349 |
351 certificates_update_running_ = false; | 350 certificates_update_running_ = false; |
352 if (certificates_update_required_) | 351 if (certificates_update_required_) |
353 StartLoadCertificates(); | 352 StartLoadCertificates(); |
354 } | 353 } |
355 | 354 |
356 void CertLoader::NotifyCertificatesLoaded(bool initial_load) { | 355 void CertLoader::NotifyCertificatesLoaded(bool initial_load) { |
357 FOR_EACH_OBSERVER(Observer, observers_, | 356 FOR_EACH_OBSERVER(Observer, observers_, |
358 OnCertificatesLoaded(cert_list_, initial_load)); | 357 OnCertificatesLoaded(cert_list_, initial_load)); |
359 } | 358 } |
(...skipping 10 matching lines...) Expand all Loading... | |
370 VLOG(1) << "OnCertRemoved"; | 369 VLOG(1) << "OnCertRemoved"; |
371 StartLoadCertificates(); | 370 StartLoadCertificates(); |
372 } | 371 } |
373 | 372 |
374 void CertLoader::LoggedInStateChanged(LoginState::LoggedInState state) { | 373 void CertLoader::LoggedInStateChanged(LoginState::LoggedInState state) { |
375 VLOG(1) << "LoggedInStateChanged: " << state; | 374 VLOG(1) << "LoggedInStateChanged: " << state; |
376 MaybeRequestCertificates(); | 375 MaybeRequestCertificates(); |
377 } | 376 } |
378 | 377 |
379 } // namespace chromeos | 378 } // namespace chromeos |
OLD | NEW |