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

Unified Diff: components/certificate_transparency/log_dns_client.h

Issue 2331923003: Allow LogDnsClient queries to be rate-limited (Closed)
Patch Set: Addresses last of Ryan's comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/certificate_transparency/log_dns_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/certificate_transparency/log_dns_client.h
diff --git a/components/certificate_transparency/log_dns_client.h b/components/certificate_transparency/log_dns_client.h
index 11b99990e2b002cf76ed963453d2d1302c6cb1c7..baf3cfe8c63db32d0e918925ff00e0412599ad29 100644
--- a/components/certificate_transparency/log_dns_client.h
+++ b/components/certificate_transparency/log_dns_client.h
@@ -50,12 +50,17 @@ class LogDnsClient : public net::NetworkChangeNotifier::DNSObserver {
// Creates a log client that will take ownership of |dns_client| and use it
// to perform DNS queries. Queries will be logged to |net_log|.
// The |dns_client| does not need to be configured first - this will be done
// automatically as needed.
+ // A limit can be set on the number of concurrent DNS queries by providing a
+ // positive value for |max_concurrent_queries|. Queries that would exceed this
+ // limit will fail with net::TEMPORARILY_THROTTLED. Setting this to 0 will
+ // disable this limit.
LogDnsClient(std::unique_ptr<net::DnsClient> dns_client,
- const net::NetLogWithSource& net_log);
+ const net::NetLogWithSource& net_log,
+ size_t max_concurrent_queries);
// Must be deleted on the same thread that it was created on.
~LogDnsClient() override;
// Called by NetworkChangeNotifier when the DNS config changes.
// The DnsClient's config will be updated in response.
@@ -106,10 +111,15 @@ class LogDnsClient : public net::NetworkChangeNotifier::DNSObserver {
uint64_t tree_size,
net::DnsTransaction* transaction,
int net_error,
const net::DnsResponse* response);
+ // Returns true if the maximum number of queries are currently in flight.
+ // If the maximum number of concurrency queries is set to 0, this will always
+ // return false.
+ bool HasMaxConcurrentQueriesInProgress() const;
+
// Updates the |dns_client_| config using NetworkChangeNotifier.
void UpdateDnsConfig();
// A DNS query that is in flight.
template <typename CallbackType>
@@ -124,10 +134,12 @@ class LogDnsClient : public net::NetworkChangeNotifier::DNSObserver {
net::NetLogWithSource net_log_;
// Leaf index queries that haven't completed yet.
std::list<Query<LeafIndexCallback>> leaf_index_queries_;
// Audit proof queries that haven't completed yet.
std::list<Query<AuditProofCallback>> audit_proof_queries_;
+ // The maximum number of queries that can be in flight at one time.
+ size_t max_concurrent_queries_;
// Creates weak_ptrs to this, for callback purposes.
base::WeakPtrFactory<LogDnsClient> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(LogDnsClient);
};
« no previous file with comments | « no previous file | components/certificate_transparency/log_dns_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698