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 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_ |
OLD | NEW |