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

Unified Diff: chrome/browser/chromeos/net/nss_cert_database_factory.cc

Issue 135193007: Use user specific NSSDatabase in CertLoader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: return of slow task runner Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/net/nss_cert_database_factory.cc
diff --git a/chrome/browser/chromeos/net/nss_cert_database_factory.cc b/chrome/browser/chromeos/net/nss_cert_database_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..60a27b6c7b9405a6d00f352baf3a4f2c138bf12c
--- /dev/null
+++ b/chrome/browser/chromeos/net/nss_cert_database_factory.cc
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/net/nss_cert_database_factory.h"
+
+#include "base/message_loop/message_loop_proxy.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/net/nss_context.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_context.h"
+
+using content::BrowserThread;
+
+namespace {
+
+// Relays callback to the right message loop.
+void DidGetCertDBOnIOThread(
+ scoped_refptr<base::MessageLoopProxy> response_message_loop,
+ const base::Callback<void(net::NSSCertDatabase*)>& callback,
+ net::NSSCertDatabase* cert_db) {
+ response_message_loop->PostTask(FROM_HERE, base::Bind(callback, cert_db));
+}
+
+// Gets NSSCertDatabase for the resource context. It must be called on IO
pneubeck (no reviews) 2014/01/24 13:18:02 Instead of the "It must be called on..." add a DCH
tbarzic 2014/01/25 00:26:27 Done.
+// thread.
+void GetCertDBOnIOThread(
+ content::ResourceContext* context,
+ scoped_refptr<base::MessageLoopProxy> response_message_loop,
+ const base::Callback<void(net::NSSCertDatabase*)>& callback) {
+ // Note that the callback will be used only if the cert database hasn't yet
+ // been initialized.
+ net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext(
+ context,
+ base::Bind(&DidGetCertDBOnIOThread, response_message_loop, callback));
+
+ if (cert_db)
+ DidGetCertDBOnIOThread(response_message_loop, callback, cert_db);
+}
+
+} // namespace
+
+namespace chromeos {
+
+void GetNSSCertDatabaseForProfile(
+ Profile* profile,
+ const base::Callback<void(net::NSSCertDatabase*)>& callback) {
+ BrowserThread::PostTask(BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&GetCertDBOnIOThread,
+ profile->GetResourceContext(),
+ base::MessageLoopProxy::current(),
+ callback));
+}
+
+} // namespace chromeos
+

Powered by Google App Engine
This is Rietveld 408576698