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

Side by Side Diff: chromeos/tpm_token_loader.cc

Issue 202483002: Merge 253942 "chromeos: Load chaps module and lookup TPM slots o..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1847/src/
Patch Set: Created 6 years, 9 months 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
« no previous file with comments | « no previous file | crypto/nss_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/tpm_token_loader.h" 5 #include "chromeos/tpm_token_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 30 matching lines...) Expand all
41 void CallOpenPersistentNSSDB() { 41 void CallOpenPersistentNSSDB() {
42 // Called from crypto_task_runner_. 42 // Called from crypto_task_runner_.
43 VLOG(1) << "CallOpenPersistentNSSDB"; 43 VLOG(1) << "CallOpenPersistentNSSDB";
44 44
45 // Ensure we've opened the user's key/certificate database. 45 // Ensure we've opened the user's key/certificate database.
46 if (base::SysInfo::IsRunningOnChromeOS()) 46 if (base::SysInfo::IsRunningOnChromeOS())
47 crypto::OpenPersistentNSSDB(); 47 crypto::OpenPersistentNSSDB();
48 crypto::EnableTPMTokenForNSS(); 48 crypto::EnableTPMTokenForNSS();
49 } 49 }
50 50
51 void PostResultToTaskRunner(scoped_refptr<base::SequencedTaskRunner> runner,
52 const base::Callback<void(bool)>& callback,
53 bool success) {
54 runner->PostTask(FROM_HERE, base::Bind(callback, success));
55 }
56
51 } // namespace 57 } // namespace
52 58
53 static TPMTokenLoader* g_tpm_token_loader = NULL; 59 static TPMTokenLoader* g_tpm_token_loader = NULL;
54 60
55 // static 61 // static
56 void TPMTokenLoader::Initialize() { 62 void TPMTokenLoader::Initialize() {
57 CHECK(!g_tpm_token_loader); 63 CHECK(!g_tpm_token_loader);
58 g_tpm_token_loader = new TPMTokenLoader(false /*for_test*/); 64 g_tpm_token_loader = new TPMTokenLoader(false /*for_test*/);
59 } 65 }
60 66
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 196 }
191 case TPM_TOKEN_READY: { 197 case TPM_TOKEN_READY: {
192 // Retrieve token_name_ and user_pin_ here since they will never change 198 // Retrieve token_name_ and user_pin_ here since they will never change
193 // and CryptohomeClient calls are not thread safe. 199 // and CryptohomeClient calls are not thread safe.
194 DBusThreadManager::Get()->GetCryptohomeClient()->Pkcs11GetTpmTokenInfo( 200 DBusThreadManager::Get()->GetCryptohomeClient()->Pkcs11GetTpmTokenInfo(
195 base::Bind(&TPMTokenLoader::OnPkcs11GetTpmTokenInfo, 201 base::Bind(&TPMTokenLoader::OnPkcs11GetTpmTokenInfo,
196 weak_factory_.GetWeakPtr())); 202 weak_factory_.GetWeakPtr()));
197 return; 203 return;
198 } 204 }
199 case TPM_TOKEN_INFO_RECEIVED: { 205 case TPM_TOKEN_INFO_RECEIVED: {
200 base::PostTaskAndReplyWithResult( 206 crypto_task_runner_->PostTask(
201 crypto_task_runner_.get(),
202 FROM_HERE, 207 FROM_HERE,
203 base::Bind(&crypto::InitializeTPMToken, tpm_token_slot_id_), 208 base::Bind(
204 base::Bind(&TPMTokenLoader::OnTPMTokenInitialized, 209 &crypto::InitializeTPMToken,
205 weak_factory_.GetWeakPtr())); 210 tpm_token_slot_id_,
211 base::Bind(&PostResultToTaskRunner,
212 base::MessageLoopProxy::current(),
213 base::Bind(&TPMTokenLoader::OnTPMTokenInitialized,
214 weak_factory_.GetWeakPtr()))));
206 return; 215 return;
207 } 216 }
208 case TPM_TOKEN_INITIALIZED: { 217 case TPM_TOKEN_INITIALIZED: {
209 NotifyTPMTokenReady(); 218 NotifyTPMTokenReady();
210 return; 219 return;
211 } 220 }
212 } 221 }
213 } 222 }
214 223
215 void TPMTokenLoader::RetryTokenInitializationLater() { 224 void TPMTokenLoader::RetryTokenInitializationLater() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 void TPMTokenLoader::NotifyTPMTokenReady() { 295 void TPMTokenLoader::NotifyTPMTokenReady() {
287 FOR_EACH_OBSERVER(Observer, observers_, OnTPMTokenReady()); 296 FOR_EACH_OBSERVER(Observer, observers_, OnTPMTokenReady());
288 } 297 }
289 298
290 void TPMTokenLoader::LoggedInStateChanged() { 299 void TPMTokenLoader::LoggedInStateChanged() {
291 VLOG(1) << "LoggedInStateChanged"; 300 VLOG(1) << "LoggedInStateChanged";
292 MaybeStartTokenInitialization(); 301 MaybeStartTokenInitialization();
293 } 302 }
294 303
295 } // namespace chromeos 304 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | crypto/nss_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698