OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // ---------------------------- | 5 // ---------------------------- |
6 // Overview of error design | 6 // Overview of error design |
7 // ---------------------------- | 7 // ---------------------------- |
8 // | 8 // |
9 // Certificate path validation/parsing may emit a sequence of | 9 // Certificate path validation/parsing may emit a sequence of |
10 // errors/warnings/context. These are represented by a tree of CertErrorNodes. | 10 // errors/warnings/context. These are represented by a tree of CertErrorNodes. |
11 // Each node is comprised of: | 11 // Each node is comprised of: |
12 // | 12 // |
13 // * A unique identifier. | 13 // * A unique identifier. |
14 // | 14 // |
15 // This serves similarly to an error code, and is useful for querying if a | 15 // This serves similarly to an error code, and is useful for querying if a |
16 // particular error occurred. | 16 // particular error occurred. |
17 // | 17 // |
18 // * [optional] A parameters object. | 18 // * [optional] A parameters object. |
19 // | 19 // |
20 // Nodes may attach a heap-allocated subclass of CertErrorParams, to carry | 20 // Nodes may attach a heap-allocated subclass of CertErrorParams, to carry |
21 // extra information that is useful when reporting the error. For instance | 21 // extra information that is useful when reporting the error. For instance |
22 // a parsing error may want to describe where in the DER the failure | 22 // a parsing error may want to describe where in the DER the failure |
23 // happened, or what the unexpected value was. | 23 // happened, or what the unexpected value was. |
24 // | 24 // |
25 // * [optional] Child nodes. | 25 // * [optional] Child nodes. |
26 // | 26 // |
27 // Error nodes are arranged in a tree. The parent/child hiearchy is used to | 27 // Error nodes are arranged in a tree. The parent/child hierarchy is used to |
28 // group errors that share some common state. | 28 // group errors that share some common state. |
29 // For instance during path processing it is useful to group the | 29 // For instance during path processing it is useful to group the |
30 // errors/warnings that happened while processing certificate "i" as | 30 // errors/warnings that happened while processing certificate "i" as |
31 // children of a shared "context" node. The context node in this case | 31 // children of a shared "context" node. The context node in this case |
32 // doesn't describe a particular error, but rather some shared event and | 32 // doesn't describe a particular error, but rather some shared event and |
33 // its parameters. | 33 // its parameters. |
34 // | 34 // |
35 // ---------------------------- | 35 // ---------------------------- |
36 // Using errors in other APIs | 36 // Using errors in other APIs |
37 // ---------------------------- | 37 // ---------------------------- |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 public: | 118 public: |
119 CertErrors(); | 119 CertErrors(); |
120 ~CertErrors(); | 120 ~CertErrors(); |
121 | 121 |
122 // Adds a node to the current insertion point in the error tree. |params| may | 122 // Adds a node to the current insertion point in the error tree. |params| may |
123 // be null. | 123 // be null. |
124 void Add(CertErrorNodeType node_type, | 124 void Add(CertErrorNodeType node_type, |
125 CertErrorId id, | 125 CertErrorId id, |
126 std::unique_ptr<CertErrorParams> params); | 126 std::unique_ptr<CertErrorParams> params); |
127 | 127 |
128 // TODO(crbug.com/634443): Eliminate this and use AddError() instead (which | |
129 // is less ambiguous). | |
130 void Add(CertErrorId id); | |
131 | |
132 void AddError(CertErrorId id, std::unique_ptr<CertErrorParams> params); | 128 void AddError(CertErrorId id, std::unique_ptr<CertErrorParams> params); |
133 void AddError(CertErrorId id); | 129 void AddError(CertErrorId id); |
134 | 130 |
135 void AddWarning(CertErrorId id, std::unique_ptr<CertErrorParams> params); | 131 void AddWarning(CertErrorId id, std::unique_ptr<CertErrorParams> params); |
136 void AddWarning(CertErrorId id); | 132 void AddWarning(CertErrorId id); |
137 | 133 |
138 // Returns true if the tree is empty. Note that emptiness of the error tree | 134 // Returns true if the tree is empty. Note that emptiness of the error tree |
139 // is NOT equivalent to success for some call, and vice versa. (For instance | 135 // is NOT equivalent to success for some call, and vice versa. (For instance |
140 // consumers may forget to emit errors on failures, or some errors may be | 136 // consumers may forget to emit errors on failures, or some errors may be |
141 // non-fatal warnings). | 137 // non-fatal warnings). |
(...skipping 17 matching lines...) Expand all Loading... |
159 // The top-most CertErrorScoper that is currently in scope (and which affects | 155 // The top-most CertErrorScoper that is currently in scope (and which affects |
160 // the parent node for newly added errors). | 156 // the parent node for newly added errors). |
161 CertErrorScoper* current_scoper_ = nullptr; | 157 CertErrorScoper* current_scoper_ = nullptr; |
162 | 158 |
163 DISALLOW_COPY_AND_ASSIGN(CertErrors); | 159 DISALLOW_COPY_AND_ASSIGN(CertErrors); |
164 }; | 160 }; |
165 | 161 |
166 } // namespace net | 162 } // namespace net |
167 | 163 |
168 #endif // NET_CERT_INTERNAL_CERT_ERRORS_H_ | 164 #endif // NET_CERT_INTERNAL_CERT_ERRORS_H_ |
OLD | NEW |