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 #ifndef COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_ | |
6 #define COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback_forward.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "components/keyed_service/core/keyed_service.h" | |
14 | |
15 namespace net { | |
16 class NSSCertDatabase; | |
17 } | |
18 | |
19 namespace cert_database { | |
20 | |
21 class CertDatabaseServiceIOPart; | |
22 | |
23 class CertDatabaseService : public KeyedService { | |
24 public: | |
25 typedef base::Callback<void(net::NSSCertDatabase*)> GetCertDBCallback; | |
26 | |
27 CertDatabaseService( | |
28 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | |
29 virtual ~CertDatabaseService(); | |
30 | |
31 // This function is for migrating from old users of nss_context. New users | |
32 // should use GetIOPart(); | |
33 void GetNSSCertDatabase(const GetCertDBCallback& callback); | |
34 | |
35 // The caller must ensure that the IOPart outlives this object. | |
36 void SetIOPart(scoped_ptr<CertDatabaseServiceIOPart> io_part); | |
37 | |
38 base::WeakPtr<CertDatabaseServiceIOPart> GetIOPart(); | |
39 | |
40 private: | |
41 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | |
42 | |
43 // Whether |io_part_| was set. |io_part_| itself can't be checked on the UI | |
44 // thread. | |
45 bool is_io_part_set_; | |
46 | |
47 // This service is owning the IOPart. However, it lives on the IO thread thus | |
tbarzic
2014/10/22 20:38:19
Maybe mention that the io_part delete task is post
pneubeck (no reviews)
2014/10/24 12:51:37
Done.
| |
48 // ScopedPtr should not be used. We keep a WeakPtr, so that we can copy | |
49 // further WeakPtrs on the UI thread. | |
50 base::WeakPtr<CertDatabaseServiceIOPart> io_part_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(CertDatabaseService); | |
53 }; | |
54 | |
55 } // namespace cert_database | |
56 | |
57 #endif // COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_ | |
OLD | NEW |