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

Unified Diff: net/cert/internal/cert_error_scoper.h

Issue 2329593002: Add optional context for certificate errors. (Closed)
Patch Set: Address Matt's comments Created 4 years, 3 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
« no previous file with comments | « net/cert/internal/cert_error_params.cc ('k') | net/cert/internal/cert_error_scoper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/cert_error_scoper.h
diff --git a/net/cert/internal/cert_error_scoper.h b/net/cert/internal/cert_error_scoper.h
new file mode 100644
index 0000000000000000000000000000000000000000..141581270df1d1df00f4db9f146015f0b486753e
--- /dev/null
+++ b/net/cert/internal/cert_error_scoper.h
@@ -0,0 +1,59 @@
+// Copyright 2016 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 NET_CERT_INTERNAL_CERT_ERROR_SCOPER_H_
+#define NET_CERT_INTERNAL_CERT_ERROR_SCOPER_H_
+
+#include <memory>
+
+#include "base/compiler_specific.h"
+#include "base/macros.h"
+#include "net/base/net_export.h"
+#include "net/cert/internal/cert_error_id.h"
+
+namespace net {
+
+class CertErrors;
+struct CertErrorNode;
+
+// CertErrorScoper is a base class for adding parent nodes into a CertErrors
+// object.
+class NET_EXPORT CertErrorScoper {
+ public:
+ explicit CertErrorScoper(CertErrors* parent_errors);
+ virtual ~CertErrorScoper();
+
+ // BuildRootNode() will be called at most once, to create the desired parent
+ // node. It may never be called if no errors are added to the CertErrors
+ // parent.
+ virtual std::unique_ptr<CertErrorNode> BuildRootNode() = 0;
+
+ // Returns the parent node for this scoper (the one created by
+ // BuildRootNode()).
+ CertErrorNode* LazyGetRootNode();
+
+ private:
+ CertErrorScoper* parent_scoper_ = nullptr;
+ CertErrors* parent_errors_ = nullptr;
+ CertErrorNode* root_node_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(CertErrorScoper);
+};
+
+// Implementation of CertErrorScoper that creates a simple parent node with no
+// parameters (just an ID).
+class NET_EXPORT CertErrorScoperNoParams : public CertErrorScoper {
+ public:
+ CertErrorScoperNoParams(CertErrors* parent_errors, CertErrorId id);
+ std::unique_ptr<CertErrorNode> BuildRootNode() override;
+
+ private:
+ CertErrorId id_;
+
+ DISALLOW_COPY_AND_ASSIGN(CertErrorScoperNoParams);
+};
+
+} // namespace net
+
+#endif // NET_CERT_INTERNAL_CERT_ERROR_SCOPER_H_
« no previous file with comments | « net/cert/internal/cert_error_params.cc ('k') | net/cert/internal/cert_error_scoper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698