Chromium Code Reviews| Index: chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
| diff --git a/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc b/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
| index f094c5fc5acba18af0e8264a1ddb499f34c473ea..0f5f23393b6561f3a4b7562a99af029d92d69dea 100644 |
| --- a/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
| +++ b/chrome/browser/chromeos/platform_keys/platform_keys_nss.cc |
| @@ -17,7 +17,9 @@ |
| #include "base/thread_task_runner_handle.h" |
| #include "base/threading/worker_pool.h" |
| #include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.h" |
| -#include "chrome/browser/net/nss_context.h" |
| +#include "chrome/browser/net/cert_database_service_factory.h" |
| +#include "components/cert_database/public/cert_database_service.h" |
| +#include "components/cert_database/public/cert_database_service_io_part.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "crypto/rsa_private_key.h" |
| @@ -103,16 +105,22 @@ void DidGetCertDBOnIOThread(const std::string& token_id, |
| callback.Run(cert_db); |
| } |
| -// Retrieves the NSSCertDatabase from |context| and, if |token_id| is not empty, |
| -// the slot for |token_id|. |
| +// Retrieves the NSSCertDatabase from |db_io_part| and, if |token_id| is not |
| +// empty, the slot for |token_id|. |
| // Must be called on the IO thread. |
| -void GetCertDatabaseOnIOThread(const std::string& token_id, |
| - const GetCertDBCallback& callback, |
| - content::ResourceContext* context, |
| - NSSOperationState* state) { |
| +void GetCertDatabaseOnIOThread( |
| + const std::string& token_id, |
| + const GetCertDBCallback& callback, |
| + const base::WeakPtr<cert_database::CertDatabaseServiceIOPart>& db_io_part, |
| + NSSOperationState* state) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
|
stevenjb
2014/10/29 18:43:51
nit: DCHECK(state) since we pass state to other me
pneubeck (no reviews)
2014/11/05 14:53:36
Done.
|
| - net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext( |
| - context, base::Bind(&DidGetCertDBOnIOThread, token_id, callback, state)); |
| + if (!db_io_part) { |
| + LOG(ERROR) << "CertDatabase shutdown."; |
| + state->OnError(FROM_HERE, kErrorInternal); |
| + return; |
| + } |
| + net::NSSCertDatabase* cert_db = db_io_part->GetNSSCertDatabase( |
| + base::Bind(&DidGetCertDBOnIOThread, token_id, callback, state)); |
| if (cert_db) |
| DidGetCertDBOnIOThread(token_id, callback, state, cert_db); |
| @@ -125,12 +133,17 @@ void GetCertDatabase(const std::string& token_id, |
| const GetCertDBCallback& callback, |
| BrowserContext* browser_context, |
| NSSOperationState* state) { |
| + // TODO(pneubeck): Pass in the CertDatabaseService instead of the |
| + // BrowserContext. |
| + cert_database::CertDatabaseService* cert_db_service = |
| + cert_database::CertDatabaseServiceFactory::GetForBrowserContext( |
| + browser_context); |
| BrowserThread::PostTask(BrowserThread::IO, |
| FROM_HERE, |
| base::Bind(&GetCertDatabaseOnIOThread, |
| token_id, |
| callback, |
| - browser_context->GetResourceContext(), |
| + cert_db_service->GetIOPart(), |
| state)); |
| } |