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

Unified Diff: components/cert_database/cert_database_service_io_part.h

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Flattened components/cert_database folders. Created 6 years, 1 month 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/cert_database_service_io_part.h
diff --git a/components/cert_database/cert_database_service_io_part.h b/components/cert_database/cert_database_service_io_part.h
new file mode 100644
index 0000000000000000000000000000000000000000..eccb46b5af84521ef2ad5a56fcedc2d2452c49ae
--- /dev/null
+++ b/components/cert_database/cert_database_service_io_part.h
@@ -0,0 +1,64 @@
+// 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_IO_PART_H_
+#define COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_IO_PART_H_
+
+#include <vector>
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/threading/thread_checker.h"
+
+namespace net {
+class NSSCertDatabase;
+}
+
+namespace cert_database {
+
+// Any object of this class is constructed on the UI thread. After it is
+// initialized on the IO thread, it may only be accessed on the IO thread.
+class CertDatabaseServiceIOPart {
+ public:
+ typedef base::Callback<void(net::NSSCertDatabase*)> GetCertDBCallback;
+
+ CertDatabaseServiceIOPart();
+ virtual ~CertDatabaseServiceIOPart();
+
+ virtual void Init();
+
+ // Returns the NSSCertDatabase synchronously if it is already available.
+ // Otherwise passes it asynchronously to |callback| once it is available.
+ WARN_UNUSED_RESULT net::NSSCertDatabase* GetNSSCertDatabase(
+ const GetCertDBCallback& callback);
+
+ // Before Init() is called, this can be called on the same thread as this
+ // object is constructed on.
+ // After Init(), this must be called on the IO thread.
+ base::WeakPtr<CertDatabaseServiceIOPart> GetWeakPtr();
+
+ protected:
+ // Returns false until Init() is called.
+ bool IsInitialized();
+
+ // Stores |db| and calls all pending GetNSSCertDatabase callbacks.
+ void SetNSSCertDatabase(scoped_ptr<net::NSSCertDatabase> db);
+
+ private:
+ base::ThreadChecker thread_checker_;
+
+ // False until Init() is called.
+ bool initialized_;
+
+ scoped_ptr<net::NSSCertDatabase> nss_cert_database_;
+ std::vector<GetCertDBCallback> get_cert_db_callbacks_;
+ base::WeakPtrFactory<CertDatabaseServiceIOPart> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(CertDatabaseServiceIOPart);
+};
+
+} // namespace cert_database
+
+#endif // COMPONENTS_CERT_DATABASE_PUBLIC_CERT_DATABASE_SERVICE_IO_PART_H_
« no previous file with comments | « components/cert_database/cert_database_service.cc ('k') | components/cert_database/cert_database_service_io_part.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698