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

Side by Side Diff: chrome/browser/net/nss_context.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/nss_context.h ('k') | chrome/browser/net/nss_context_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/net/nss_context.h"
6
7 #include "base/message_loop/message_loop_proxy.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/resource_context.h"
11
12 using content::BrowserThread;
13
14 namespace {
15
16 // Relays callback to the right message loop.
17 void DidGetCertDBOnIOThread(
18 scoped_refptr<base::MessageLoopProxy> response_message_loop,
19 const base::Callback<void(net::NSSCertDatabase*)>& callback,
20 net::NSSCertDatabase* cert_db) {
21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
22
23 response_message_loop->PostTask(FROM_HERE, base::Bind(callback, cert_db));
24 }
25
26 // Gets NSSCertDatabase for the resource context.
27 void GetCertDBOnIOThread(
28 content::ResourceContext* context,
29 scoped_refptr<base::MessageLoopProxy> response_message_loop,
30 const base::Callback<void(net::NSSCertDatabase*)>& callback) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
32
33 // Note that the callback will be used only if the cert database hasn't yet
34 // been initialized.
35 net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext(
36 context,
37 base::Bind(&DidGetCertDBOnIOThread, response_message_loop, callback));
38
39 if (cert_db)
40 DidGetCertDBOnIOThread(response_message_loop, callback, cert_db);
41 }
42
43 } // namespace
44
45 void GetNSSCertDatabaseForProfile(
46 Profile* profile,
47 const base::Callback<void(net::NSSCertDatabase*)>& callback) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
49
50 BrowserThread::PostTask(BrowserThread::IO,
51 FROM_HERE,
52 base::Bind(&GetCertDBOnIOThread,
53 profile->GetResourceContext(),
54 base::MessageLoopProxy::current(),
55 callback));
56 }
57
OLDNEW
« no previous file with comments | « chrome/browser/net/nss_context.h ('k') | chrome/browser/net/nss_context_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698