OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/nss_context.h" | 5 #include "chrome/browser/net/nss_context.h" |
6 | 6 |
7 #include "base/message_loop/message_loop_proxy.h" | 7 #include "base/single_thread_task_runner.h" |
8 #include "base/thread_task_runner_handle.h" | |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/resource_context.h" | 11 #include "content/public/browser/resource_context.h" |
11 | 12 |
12 using content::BrowserThread; | 13 using content::BrowserThread; |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // Relays callback to the right message loop. | 17 // Relays callback to the right message loop. |
17 void DidGetCertDBOnIOThread( | 18 void DidGetCertDBOnIOThread( |
18 scoped_refptr<base::MessageLoopProxy> response_message_loop, | 19 scoped_refptr<base::SingleThreadTaskRunner> response_task_runner, |
Ryan Sleevi
2015/05/04 18:11:27
This should be passed as a SequencedTaskRunner and
Pranay
2015/05/05 04:18:38
Done.
| |
19 const base::Callback<void(net::NSSCertDatabase*)>& callback, | 20 const base::Callback<void(net::NSSCertDatabase*)>& callback, |
20 net::NSSCertDatabase* cert_db) { | 21 net::NSSCertDatabase* cert_db) { |
21 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 22 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
22 | 23 |
23 response_message_loop->PostTask(FROM_HERE, base::Bind(callback, cert_db)); | 24 response_task_runner->PostTask(FROM_HERE, base::Bind(callback, cert_db)); |
24 } | 25 } |
25 | 26 |
26 // Gets NSSCertDatabase for the resource context. | 27 // Gets NSSCertDatabase for the resource context. |
27 void GetCertDBOnIOThread( | 28 void GetCertDBOnIOThread( |
28 content::ResourceContext* context, | 29 content::ResourceContext* context, |
29 scoped_refptr<base::MessageLoopProxy> response_message_loop, | 30 scoped_refptr<base::SingleThreadTaskRunner> response_task_runner, |
Ryan Sleevi
2015/05/04 18:11:27
This should be a const-ref SequencedTaskRunner
Pranay
2015/05/05 04:18:38
Done.
| |
30 const base::Callback<void(net::NSSCertDatabase*)>& callback) { | 31 const base::Callback<void(net::NSSCertDatabase*)>& callback) { |
31 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 32 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
32 | 33 |
33 // Note that the callback will be used only if the cert database hasn't yet | 34 // Note that the callback will be used only if the cert database hasn't yet |
34 // been initialized. | 35 // been initialized. |
35 net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext( | 36 net::NSSCertDatabase* cert_db = GetNSSCertDatabaseForResourceContext( |
36 context, | 37 context, |
37 base::Bind(&DidGetCertDBOnIOThread, response_message_loop, callback)); | 38 base::Bind(&DidGetCertDBOnIOThread, response_task_runner, callback)); |
38 | 39 |
39 if (cert_db) | 40 if (cert_db) |
40 DidGetCertDBOnIOThread(response_message_loop, callback, cert_db); | 41 DidGetCertDBOnIOThread(response_task_runner, callback, cert_db); |
41 } | 42 } |
42 | 43 |
43 } // namespace | 44 } // namespace |
44 | 45 |
45 void GetNSSCertDatabaseForProfile( | 46 void GetNSSCertDatabaseForProfile( |
46 Profile* profile, | 47 Profile* profile, |
47 const base::Callback<void(net::NSSCertDatabase*)>& callback) { | 48 const base::Callback<void(net::NSSCertDatabase*)>& callback) { |
48 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 49 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
49 | 50 |
50 BrowserThread::PostTask(BrowserThread::IO, | 51 BrowserThread::PostTask(BrowserThread::IO, |
51 FROM_HERE, | 52 FROM_HERE, |
52 base::Bind(&GetCertDBOnIOThread, | 53 base::Bind(&GetCertDBOnIOThread, |
53 profile->GetResourceContext(), | 54 profile->GetResourceContext(), |
54 base::MessageLoopProxy::current(), | 55 base::ThreadTaskRunnerHandle::Get(), |
55 callback)); | 56 callback)); |
56 } | 57 } |
57 | 58 |
OLD | NEW |