| Index: components/cert_database/public/cert_database_service.h
|
| diff --git a/components/cert_database/public/cert_database_service.h b/components/cert_database/public/cert_database_service.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..562173c2afa855fcb7abc93299f9adb2c9043a75
|
| --- /dev/null
|
| +++ b/components/cert_database/public/cert_database_service.h
|
| @@ -0,0 +1,61 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_
|
| +#define COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/callback_forward.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "components/keyed_service/core/keyed_service.h"
|
| +
|
| +namespace net {
|
| +class NSSCertDatabase;
|
| +}
|
| +
|
| +namespace cert_database {
|
| +
|
| +class CertDatabaseServiceIOPart;
|
| +
|
| +class CertDatabaseService : public KeyedService {
|
| + public:
|
| + typedef base::Callback<void(net::NSSCertDatabase*)> GetCertDBCallback;
|
| +
|
| + CertDatabaseService(
|
| + const scoped_refptr<base::SequencedTaskRunner>& io_task_runner);
|
| + virtual ~CertDatabaseService();
|
| +
|
| + // This function is for migrating from old users of nss_context. New users
|
| + // should use GetIOPart();
|
| + void GetNSSCertDatabase(const GetCertDBCallback& callback);
|
| +
|
| + // Passes ownership of |io_part| to this service.
|
| + // This will initialize |io_part| by calling its Init() method. Afterwards it
|
| + // must only be accessed through a WeakPtr and on the IO thread.
|
| + void SetIOPart(scoped_ptr<CertDatabaseServiceIOPart> io_part);
|
| +
|
| + base::WeakPtr<CertDatabaseServiceIOPart> GetIOPart();
|
| +
|
| + private:
|
| + scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
|
| +
|
| + // Whether |io_part_| was set. |io_part_| itself can't be checked on the UI
|
| + // thread.
|
| + bool is_io_part_set_;
|
| +
|
| + // This service is owning the IOPart. However, it lives on the IO thread thus
|
| + // ScopedPtr should not be used. We keep a WeakPtr, so that we can copy
|
| + // further WeakPtrs on the UI thread.
|
| + // A task to delete |io_part_| is posted to the IO thread from the service's
|
| + // destructor.
|
| + base::WeakPtr<CertDatabaseServiceIOPart> io_part_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CertDatabaseService);
|
| +};
|
| +
|
| +} // namespace cert_database
|
| +
|
| +#endif // COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_
|
|
|