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

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: Separated out ClientCertStoreChromeOS change. 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..bf44a1011920c8a3f7f345ee9d93fb192b1d8516
--- /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>
Joao da Silva 2014/10/30 09:48:01 used?
pneubeck (no reviews) 2014/11/05 14:53:37 Done.
+
+#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);
Joao da Silva 2014/10/30 09:48:01 explicit
pneubeck (no reviews) 2014/11/05 14:53:37 Done.
+ ~CertDatabaseService() override;
+
+ // 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();
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.
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698