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 #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> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 ~LogDnsClient() override; | 48 ~LogDnsClient() override; |
49 | 49 |
50 // Called by NetworkChangeNotifier when the DNS config changes. | 50 // Called by NetworkChangeNotifier when the DNS config changes. |
51 // The DnsClient's config will be updated in response. | 51 // The DnsClient's config will be updated in response. |
52 void OnDNSChanged() override; | 52 void OnDNSChanged() override; |
53 | 53 |
54 // Called by NetworkChangeNotifier when the DNS config is first read. | 54 // Called by NetworkChangeNotifier when the DNS config is first read. |
55 // The DnsClient's config will be updated in response. | 55 // The DnsClient's config will be updated in response. |
56 void OnInitialDNSConfigRead() override; | 56 void OnInitialDNSConfigRead() override; |
57 | 57 |
| 58 // Registers a callback to be invoked when the number of concurrent queries |
| 59 // falls below the limit defined by |max_concurrent_queries| (passed to the |
| 60 // constructor of LogDnsClient). This callback will fire once and then be |
| 61 // unregistered. Should only be used if QueryAuditProof() returns |
| 62 // net::ERR_TEMPORARILY_THROTTLED. |
| 63 void NotifyWhenNotThrottled(const base::Closure& callback); |
| 64 |
58 // 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|. |
59 // The log is identified by |domain_for_log|, which is the DNS name used as a | 66 // The log is identified by |domain_for_log|, which is the DNS name used as a |
60 // suffix for all queries. | 67 // suffix for all queries. |
61 // The |leaf_hash| is the SHA-256 Merkle leaf hash (see RFC6962, section 2.1). | 68 // The |leaf_hash| is the SHA-256 Merkle leaf hash (see RFC6962, section 2.1). |
62 // The size of the CT log tree, for which the proof is requested, must be | 69 // The size of the CT log tree, for which the proof is requested, must be |
63 // provided in |tree_size|. | 70 // provided in |tree_size|. |
64 // The leaf index and audit proof obtained from the CT log will be placed in | 71 // The leaf index and audit proof obtained from the CT log will be placed in |
65 // |proof|. | 72 // |proof|. |
66 // If the proof cannot be obtained synchronously, this method will return | 73 // If the proof cannot be obtained synchronously, this method will return |
67 // net::ERR_IO_PENDING and invoke |callback| once the query is complete. | 74 // net::ERR_IO_PENDING and invoke |callback| once the query is complete. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // Used to perform DNS queries. | 112 // Used to perform DNS queries. |
106 std::unique_ptr<net::DnsClient> dns_client_; | 113 std::unique_ptr<net::DnsClient> dns_client_; |
107 // Passed to the DNS client for logging. | 114 // Passed to the DNS client for logging. |
108 net::NetLogWithSource net_log_; | 115 net::NetLogWithSource net_log_; |
109 // A FIFO queue of ongoing queries. Since entries will always be appended to | 116 // A FIFO queue of ongoing queries. Since entries will always be appended to |
110 // the end and lookups will typically yield entries at the beginning, | 117 // the end and lookups will typically yield entries at the beginning, |
111 // std::list is an efficient choice. | 118 // std::list is an efficient choice. |
112 std::list<std::unique_ptr<AuditProofQuery>> audit_proof_queries_; | 119 std::list<std::unique_ptr<AuditProofQuery>> audit_proof_queries_; |
113 // The maximum number of queries that can be in flight at one time. | 120 // The maximum number of queries that can be in flight at one time. |
114 size_t max_concurrent_queries_; | 121 size_t max_concurrent_queries_; |
| 122 // Callbacks to invoke when the number of concurrent queries is at its limit. |
| 123 std::list<base::Closure> not_throttled_callbacks_; |
115 // Creates weak_ptrs to this, for callback purposes. | 124 // Creates weak_ptrs to this, for callback purposes. |
116 base::WeakPtrFactory<LogDnsClient> weak_ptr_factory_; | 125 base::WeakPtrFactory<LogDnsClient> weak_ptr_factory_; |
117 | 126 |
118 DISALLOW_COPY_AND_ASSIGN(LogDnsClient); | 127 DISALLOW_COPY_AND_ASSIGN(LogDnsClient); |
119 }; | 128 }; |
120 | 129 |
121 } // namespace certificate_transparency | 130 } // namespace certificate_transparency |
122 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_ | 131 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_DNS_CLIENT_H_ |
OLD | NEW |