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

Side by Side Diff: components/cert_database/cert_database_service_io_part.h

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
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_IO_PART_H_
6 #define COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_IO_PART_H_
7
8 #include <vector>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h"
14
15 namespace net {
16 class NSSCertDatabase;
17 }
18
19 namespace cert_database {
20
21 // Any object of this class is constructed on the UI thread. After it is
22 // initialized on the IO thread, it may only be accessed on the IO thread.
23 class CertDatabaseServiceIOPart {
24 public:
25 typedef base::Callback<void(net::NSSCertDatabase*)> GetCertDBCallback;
26
27 CertDatabaseServiceIOPart();
28 virtual ~CertDatabaseServiceIOPart();
29
30 virtual void Init();
31
32 // Returns the NSSCertDatabase synchronously if it is already available.
33 // Otherwise passes it asynchronously to |callback| once it is available.
34 WARN_UNUSED_RESULT net::NSSCertDatabase* GetNSSCertDatabase(
35 const GetCertDBCallback& callback);
36
37 // Before Init() is called, this can be called on the same thread as this
38 // object is constructed on.
39 // After Init(), this must be called on the IO thread.
40 base::WeakPtr<CertDatabaseServiceIOPart> GetWeakPtr();
41
42 protected:
43 // Returns false until Init() is called.
44 bool IsInitialized();
45
46 // Stores |db| and calls all pending GetNSSCertDatabase callbacks.
47 void SetNSSCertDatabase(scoped_ptr<net::NSSCertDatabase> db);
48
49 private:
50 base::ThreadChecker thread_checker_;
51
52 // False until Init() is called.
53 bool initialized_;
54
55 scoped_ptr<net::NSSCertDatabase> nss_cert_database_;
56 std::vector<GetCertDBCallback> get_cert_db_callbacks_;
57 base::WeakPtrFactory<CertDatabaseServiceIOPart> weak_ptr_factory_;
58
59 DISALLOW_COPY_AND_ASSIGN(CertDatabaseServiceIOPart);
60 };
61
62 } // namespace cert_database
63
64 #endif // COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_IO_PART_H_
OLDNEW
« no previous file with comments | « components/cert_database/cert_database_service.cc ('k') | components/cert_database/cert_database_service_io_part.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698