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