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

Side by Side Diff: components/cert_database/public/cert_database_service.h

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added Linux implementation. Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
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 #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 class CertDatabaseServiceIOPart;
16
17 namespace net {
18 class NSSCertDatabase;
19 }
20
21 class CertDatabaseService : public KeyedService {
22 public:
23 typedef base::Callback<void(net::NSSCertDatabase*)> GetCertDBCallback;
24
25 CertDatabaseService(
26 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner);
27 virtual ~CertDatabaseService();
28
29 // This function is for migrating from old users of nss_context. New users
30 // should use GetIOPart();
31 void GetNSSCertDatabase(const GetCertDBCallback& callback);
32
33 // The caller must ensure that the IOPart outlives this object.
34 void SetIOPart(scoped_ptr<CertDatabaseServiceIOPart> io_part);
35
36 base::WeakPtr<CertDatabaseServiceIOPart> GetIOPart();
37
38 private:
39 scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
40
41 // Whether |io_part_| was set. |io_part_| itself can't be checked on the UI
42 // thread.
43 bool is_io_part_set_;
44
45 // This service is owning the IOPart. However, it lives on the IO thread thus
46 // ScopedPtr should not be used. We keep a WeakPtr, so that we can copy
47 // further WeakPtrs on the UI thread.
48 base::WeakPtr<CertDatabaseServiceIOPart> io_part_;
49
50 DISALLOW_COPY_AND_ASSIGN(CertDatabaseService);
51 };
52
53 #endif // COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698