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

Unified Diff: components/certificate_transparency/observed_leaf.cc

Issue 2017563002: Add Certificate Transparency logs auditing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing all comments Created 4 years, 6 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/certificate_transparency/observed_leaf.cc
diff --git a/components/certificate_transparency/observed_leaf.cc b/components/certificate_transparency/observed_leaf.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ee010b6c2ad62cced99adace83062b25de4db79b
--- /dev/null
+++ b/components/certificate_transparency/observed_leaf.cc
@@ -0,0 +1,43 @@
+// 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 "components/certificate_transparency/observed_leaf.h"
+
+#include "base/time/time.h"
+
+using net::ct::MerkleTreeLeaf;
+
+ObservedLeaf::ObservedLeaf(MerkleTreeLeaf&& leaf, const base::Time& observed_at)
+ : leaf_(leaf), observed_at_(observed_at) {}
+
+ObservedLeaf::ObservedLeaf(const ObservedLeaf& other) = default;
+
+ObservedLeaf::ObservedLeaf(ObservedLeaf&&) = default;
+
+ObservedLeaf::~ObservedLeaf() = default;
+
+void ObservedLeaf::SetLeafIndex(uint64_t index) {
+ // The leaf index may be set only once. Doing so more than once indicates
+ // a programming error where the index is fetched more than once for a given
+ // leaf.
+ CHECK(!leaf_index_);
Ryan Sleevi 2016/06/30 22:48:18 Then programming errors should be met with DCHECK,
Eran Messeri 2016/07/01 13:24:00 Done.
+ leaf_index_ = index;
+}
+
+bool ObservedLeaf::HasLeafIndex() const {
+ return bool(leaf_index_);
+}
+
+uint64_t ObservedLeaf::GetLeafIndex() const {
+ CHECK(leaf_index_);
+ return leaf_index_.value();
+}
+
+const MerkleTreeLeaf& ObservedLeaf::GetLeaf() const {
+ return leaf_;
+}
+
+const base::Time& ObservedLeaf::ObservedAt() const {
+ return observed_at_;
+}

Powered by Google App Engine
This is Rietveld 408576698