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

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

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_scoper.h ('k') | net/cert/internal/cert_errors.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/cert_error_scoper.cc
diff --git a/net/cert/internal/cert_error_scoper.cc b/net/cert/internal/cert_error_scoper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c970f9acde6edf40bd0b4e13e781c68cc817367a
--- /dev/null
+++ b/net/cert/internal/cert_error_scoper.cc
@@ -0,0 +1,54 @@
+// 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.
+
+#include "net/cert/internal/cert_error_scoper.h"
+
+#include <memory>
+
+#include "base/logging.h"
+#include "base/memory/ptr_util.h"
+#include "net/cert/internal/cert_error_params.h"
+#include "net/cert/internal/cert_errors.h"
+
+namespace net {
+
+CertErrorScoper::CertErrorScoper(CertErrors* parent_errors) {
+ DCHECK(parent_errors);
+ parent_errors_ = parent_errors;
+ parent_scoper_ = parent_errors->SetScoper(this);
+}
+
+CertErrorScoper::~CertErrorScoper() {
+ CertErrorScoper* prev = parent_errors_->SetScoper(parent_scoper_);
+ DCHECK_EQ(prev, this);
+}
+
+CertErrorNode* CertErrorScoper::LazyGetRootNode() {
+ if (!root_node_) {
+ // Create the node.
+ auto root_node = BuildRootNode();
+ root_node_ = root_node.get();
+
+ // Attach it to the node hiearchy (ownership of this node is passed off
+ // to its parent, which is ultimately rooted in the CertErrors object).
+ if (parent_scoper_) {
+ parent_scoper_->LazyGetRootNode()->AddChild(std::move(root_node));
+ } else {
+ parent_errors_->nodes_.push_back(std::move(root_node));
+ }
+ }
+
+ return root_node_;
+}
+
+CertErrorScoperNoParams::CertErrorScoperNoParams(CertErrors* parent_errors,
+ CertErrorId id)
+ : CertErrorScoper(parent_errors), id_(id) {}
+
+std::unique_ptr<CertErrorNode> CertErrorScoperNoParams::BuildRootNode() {
+ return base::MakeUnique<CertErrorNode>(CertErrorNodeType::TYPE_CONTEXT, id_,
+ nullptr);
+}
+
+} // namespace net
« no previous file with comments | « net/cert/internal/cert_error_scoper.h ('k') | net/cert/internal/cert_errors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698