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

Unified Diff: chrome/browser/chromeos/platform_keys/platform_keys_nss.cc

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flattened components/cert_database folders. Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..fe26f029c41c9ab62a4d472a677c87c8ca8c1005 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/cert_database_service.h"
+#include "components/cert_database/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,23 @@ 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));
- net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext(
- context, base::Bind(&DidGetCertDBOnIOThread, token_id, callback, state));
+ DCHECK(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 +134,18 @@ void GetCertDatabase(const std::string& token_id,
const GetCertDBCallback& callback,
BrowserContext* browser_context,
NSSOperationState* state) {
+ DCHECK(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));
}

Powered by Google App Engine
This is Rietveld 408576698