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

Unified 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: Rebase, format. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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..864f13df06e9890838705ea55ab3dc0219a4153a
--- /dev/null
+++ b/components/cert_database/public/cert_database_service.h
@@ -0,0 +1,57 @@
+// 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);
+
+ // The caller must ensure that the IOPart outlives this object.
+ 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
tbarzic 2014/10/22 20:38:19 Maybe mention that the io_part delete task is post
pneubeck (no reviews) 2014/10/24 12:51:37 Done.
+ // ScopedPtr should not be used. We keep a WeakPtr, so that we can copy
+ // further WeakPtrs on the UI thread.
+ base::WeakPtr<CertDatabaseServiceIOPart> io_part_;
+
+ DISALLOW_COPY_AND_ASSIGN(CertDatabaseService);
+};
+
+} // namespace cert_database
+
+#endif // COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698