Chromium Code Reviews| 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> | |
|
Joao da Silva
2014/10/30 09:48:01
used?
pneubeck (no reviews)
2014/11/05 14:53:37
Done.
| |
| 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); | |
|
Joao da Silva
2014/10/30 09:48:01
explicit
pneubeck (no reviews)
2014/11/05 14:53:37
Done.
| |
| 29 ~CertDatabaseService() override; | |
| 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 // Passes ownership of |io_part| to this service. | |
| 36 // This will initialize |io_part| by calling its Init() method. Afterwards it | |
| 37 // must only be accessed through a WeakPtr and on the IO thread. | |
| 38 void SetIOPart(scoped_ptr<CertDatabaseServiceIOPart> io_part); | |
| 39 | |
| 40 base::WeakPtr<CertDatabaseServiceIOPart> GetIOPart(); | |
|
Joao da Silva
2014/10/30 09:48:01
Please document on which thread this is meant to b
pneubeck (no reviews)
2014/11/05 14:53:37
Done.
| |
| 41 | |
| 42 private: | |
| 43 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; | |
| 44 | |
| 45 // Whether |io_part_| was set. |io_part_| itself can't be checked on the UI | |
| 46 // thread. | |
| 47 bool is_io_part_set_; | |
| 48 | |
| 49 // This service is owning the IOPart. However, it lives on the IO thread thus | |
| 50 // ScopedPtr should not be used. We keep a WeakPtr, so that we can copy | |
| 51 // further WeakPtrs on the UI thread. | |
| 52 // A task to delete |io_part_| is posted to the IO thread from the service's | |
| 53 // destructor. | |
| 54 base::WeakPtr<CertDatabaseServiceIOPart> io_part_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(CertDatabaseService); | |
| 57 }; | |
| 58 | |
| 59 } // namespace cert_database | |
| 60 | |
| 61 #endif // COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_ | |
| OLD | NEW |