| Index: net/cert/ct_trans_item.h
|
| diff --git a/net/cert/ct_trans_item.h b/net/cert/ct_trans_item.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..42e2863ceac04a4ccae7abbacf79f0173eb83af5
|
| --- /dev/null
|
| +++ b/net/cert/ct_trans_item.h
|
| @@ -0,0 +1,93 @@
|
| +// Copyright 2015 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_CT_TRANS_ITEM_H_
|
| +#define NET_CERT_CT_TRANS_ITEM_H_
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "net/base/net_export.h"
|
| +
|
| +namespace net {
|
| +namespace ct {
|
| +
|
| +struct MerkleConsistencyProof;
|
| +struct SignedCertificateTimestamp;
|
| +struct SignedTreeHead;
|
| +
|
| +// These values are disjoint because we only need a subset of the CTv1 types.
|
| +enum class TransType : uint16_t {
|
| + X509_SCT = 2,
|
| + SIGNED_TREE_HEAD = 5,
|
| + CONSISTENCY_PROOF = 6,
|
| +};
|
| +
|
| +NET_EXPORT std::ostream& operator<<(std::ostream& stream,
|
| + const TransType& type);
|
| +
|
| +struct NET_EXPORT TransItemV1 {
|
| + TransItemV1();
|
| + ~TransItemV1();
|
| +
|
| + bool IsTypeSet() const { return type_ != nullptr; }
|
| + TransType type() const;
|
| +
|
| + scoped_refptr<SignedCertificateTimestamp> x509_sct() const;
|
| + const SignedTreeHead& signed_tree_head() const;
|
| + const MerkleConsistencyProof& consistency_proof() const;
|
| +
|
| + void SetX509Sct(scoped_refptr<SignedCertificateTimestamp> sct);
|
| + void SetSignedTreeHead(const SignedTreeHead& sth);
|
| + void SetConsistencyProof(const MerkleConsistencyProof& proof);
|
| +
|
| + private:
|
| + void Clear();
|
| +
|
| + scoped_ptr<TransType> type_;
|
| + // Only one of the following should be set, based on the value of |type|.
|
| + scoped_refptr<SignedCertificateTimestamp> x509_sct_;
|
| + scoped_ptr<SignedTreeHead> signed_tree_head_;
|
| + scoped_ptr<MerkleConsistencyProof> consistency_proof_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TransItemV1);
|
| +};
|
| +
|
| +NET_EXPORT std::ostream& operator<<(std::ostream& stream,
|
| + const TransItemV1& item);
|
| +
|
| +struct NET_EXPORT TransItem {
|
| + enum class Version : unsigned {
|
| + V1 = 0,
|
| + };
|
| +
|
| + TransItem();
|
| + explicit TransItem(scoped_ptr<TransItemV1> item);
|
| + ~TransItem();
|
| +
|
| + bool IsVersionSet() const { return version_ != nullptr; }
|
| + Version version() const;
|
| +
|
| + const TransItemV1& v1() const;
|
| +
|
| + void Set(scoped_ptr<TransItemV1> item);
|
| +
|
| + private:
|
| + void Clear();
|
| +
|
| + scoped_ptr<Version> version_;
|
| + // Only one of the following should be set, based on the value of |version|.
|
| + scoped_ptr<TransItemV1> v1_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TransItem);
|
| +};
|
| +
|
| +NET_EXPORT std::ostream& operator<<(std::ostream& stream,
|
| + const TransItem::Version& version);
|
| +NET_EXPORT std::ostream& operator<<(std::ostream& stream,
|
| + const TransItem& item);
|
| +
|
| +} // namespace ct
|
| +} // namespace net
|
| +
|
| +#endif // NET_CERT_CT_TRANS_ITEM_H_
|
|
|