Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/net/nss_cert_database_factory.h" | |
| 6 | |
| 7 #include "base/message_loop/message_loop_proxy.h" | |
| 8 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 9 #include "chrome/browser/net/nss_context.h" | |
| 10 #include "chrome/browser/profiles/profile.h" | |
| 11 #include "content/public/browser/browser_thread.h" | |
| 12 #include "content/public/browser/resource_context.h" | |
| 13 | |
| 14 using content::BrowserThread; | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 // Relays callback to the right message loop. | |
| 19 void DidGetCertDBOnIOThread( | |
| 20 scoped_refptr<base::MessageLoopProxy> response_message_loop, | |
| 21 const base::Callback<void(net::NSSCertDatabase*)>& callback, | |
| 22 net::NSSCertDatabase* cert_db) { | |
| 23 response_message_loop->PostTask(FROM_HERE, base::Bind(callback, cert_db)); | |
| 24 } | |
| 25 | |
| 26 // 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.
| |
| 27 // thread. | |
| 28 void GetCertDBOnIOThread( | |
| 29 content::ResourceContext* context, | |
| 30 scoped_refptr<base::MessageLoopProxy> response_message_loop, | |
| 31 const base::Callback<void(net::NSSCertDatabase*)>& callback) { | |
| 32 // Note that the callback will be used only if the cert database hasn't yet | |
| 33 // been initialized. | |
| 34 net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext( | |
| 35 context, | |
| 36 base::Bind(&DidGetCertDBOnIOThread, response_message_loop, callback)); | |
| 37 | |
| 38 if (cert_db) | |
| 39 DidGetCertDBOnIOThread(response_message_loop, callback, cert_db); | |
| 40 } | |
| 41 | |
| 42 } // namespace | |
| 43 | |
| 44 namespace chromeos { | |
| 45 | |
| 46 void GetNSSCertDatabaseForProfile( | |
| 47 Profile* profile, | |
| 48 const base::Callback<void(net::NSSCertDatabase*)>& callback) { | |
| 49 BrowserThread::PostTask(BrowserThread::IO, | |
| 50 FROM_HERE, | |
| 51 base::Bind(&GetCertDBOnIOThread, | |
| 52 profile->GetResourceContext(), | |
| 53 base::MessageLoopProxy::current(), | |
| 54 callback)); | |
| 55 } | |
| 56 | |
| 57 } // namespace chromeos | |
| 58 | |
| OLD | NEW |