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

Side by Side Diff: components/certificate_transparency/log_dns_client.h

Issue 2369373002: LogDnsClient now returns some errors synchronously (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_ 5 #ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_
6 #define COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_ 6 #define COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <string>
12 11
13 #include "base/callback.h" 12 #include "base/callback.h"
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
16 #include "net/base/network_change_notifier.h" 15 #include "net/base/network_change_notifier.h"
17 #include "net/log/net_log.h" 16 #include "net/log/net_log.h"
18 17
19 namespace net { 18 namespace net {
20 class DnsClient; 19 class DnsClient;
21 class DnsResponse;
22 class DnsTransaction;
23 namespace ct { 20 namespace ct {
24 struct MerkleAuditProof; 21 struct MerkleAuditProof;
25 } // namespace ct 22 } // namespace ct
26 } // namespace net 23 } // namespace net
27 24
28 namespace certificate_transparency { 25 namespace certificate_transparency {
29 26
30 // Queries Certificate Transparency (CT) log servers via DNS. 27 // Queries Certificate Transparency (CT) log servers via DNS.
31 // All queries are performed asynchronously. 28 // All queries are performed asynchronously.
32 // For more information, see 29 // For more information, see
(...skipping 30 matching lines...) Expand all
63 60
64 // Called by NetworkChangeNotifier when the DNS config is first read. 61 // Called by NetworkChangeNotifier when the DNS config is first read.
65 // The DnsClient's config will be updated in response. 62 // The DnsClient's config will be updated in response.
66 void OnInitialDNSConfigRead() override; 63 void OnInitialDNSConfigRead() override;
67 64
68 // Queries a CT log to retrieve an audit proof for the leaf with |leaf_hash|. 65 // Queries a CT log to retrieve an audit proof for the leaf with |leaf_hash|.
69 // The |leaf_hash| is the SHA-256 Merkle leaf hash (see RFC6962, section 2.1). 66 // The |leaf_hash| is the SHA-256 Merkle leaf hash (see RFC6962, section 2.1).
70 // The size of the CT log tree must be provided in |tree_size|. 67 // The size of the CT log tree must be provided in |tree_size|.
71 // The log is identified by |domain_for_log|, which is the DNS name used as a 68 // The log is identified by |domain_for_log|, which is the DNS name used as a
72 // suffix for all queries. 69 // suffix for all queries.
73 // The |callback| is invoked when the query is complete, or an error occurs. 70 // The |callback| is invoked when the query is complete, or an error occurs.
Eran Messeri 2016/09/28 13:44:08 Document the return value - that on successful sub
Rob Percival 2016/09/28 16:19:14 Done.
74 void QueryAuditProof(const std::string& domain_for_log, 71 int QueryAuditProof(base::StringPiece domain_for_log,
Eran Messeri 2016/09/28 13:44:08 Question to rsleevi: Why not use net::Error here?
75 base::StringPiece leaf_hash, 72 base::StringPiece leaf_hash,
76 uint64_t tree_size, 73 uint64_t tree_size,
77 const AuditProofCallback& callback); 74 const AuditProofCallback& callback);
78 75
79 private: 76 private:
80 // An audit proof query that is in progress. 77 // An audit proof query that is in progress.
81 class AuditProofQuery; 78 class AuditProofQuery;
82 79
83 // Invoked when an audit proof query completes. 80 // Invoked when an audit proof query completes.
84 // |callback| is the user-provided callback that should be notified. 81 // |callback| is the user-provided callback that should be notified.
85 // |result| is a net::Error indicating success or failure. 82 // |result| is a net::Error indicating success or failure.
86 // |query| is the query that has completed. 83 // |query| is the query that has completed.
87 // The query is removed from |audit_proof_queries_| by this method. 84 // The query is removed from |audit_proof_queries_| by this method.
88 void QueryAuditProofComplete(const AuditProofCallback& callback, 85 void QueryAuditProofComplete(const AuditProofCallback& callback,
89 int result, 86 int result,
90 AuditProofQuery* query); 87 AuditProofQuery* query);
91 88
92 // Returns true if the maximum number of queries are currently in flight. 89 // Returns true if the maximum number of queries are currently in flight.
93 // If the maximum number of concurrency queries is set to 0, this will always 90 // If the maximum number of concurrency queries is set to 0, this will always
94 // return false. 91 // return false.
95 bool HasMaxConcurrentQueriesInProgress() const; 92 bool HasMaxConcurrentQueriesInProgress() const;
96 93
97 // Updates the |dns_client_| config using NetworkChangeNotifier. 94 // Updates the |dns_client_| config using NetworkChangeNotifier.
98 void UpdateDnsConfig(); 95 void UpdateDnsConfig();
99 96
100 // Used to perform DNS queries. 97 // Used to perform DNS queries.
101 std::unique_ptr<net::DnsClient> dns_client_; 98 std::unique_ptr<net::DnsClient> dns_client_;
102 // Passed to the DNS client for logging. 99 // Passed to the DNS client for logging.
103 net::BoundNetLog net_log_; 100 net::BoundNetLog net_log_;
104 // Audit proof queries that haven't completed yet. 101 // Audit proof queries that haven't completed yet.
102 // Expected to typically be a FIFO queue of queries, so a std::list should be
103 // efficient.
Eran Messeri 2016/09/28 13:44:08 Be more explicit in the comment: // A FIFO queue o
Rob Percival 2016/09/28 16:19:14 Done.
105 std::list<std::unique_ptr<AuditProofQuery>> audit_proof_queries_; 104 std::list<std::unique_ptr<AuditProofQuery>> audit_proof_queries_;
106 // The maximum number of queries that can be in flight at one time. 105 // The maximum number of queries that can be in flight at one time.
107 size_t max_concurrent_queries_; 106 size_t max_concurrent_queries_;
108 // Creates weak_ptrs to this, for callback purposes. 107 // Creates weak_ptrs to this, for callback purposes.
109 base::WeakPtrFactory<LogDnsClient> weak_ptr_factory_; 108 base::WeakPtrFactory<LogDnsClient> weak_ptr_factory_;
110 109
111 DISALLOW_COPY_AND_ASSIGN(LogDnsClient); 110 DISALLOW_COPY_AND_ASSIGN(LogDnsClient);
112 }; 111 };
113 112
114 } // namespace certificate_transparency 113 } // namespace certificate_transparency
115 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_ 114 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698