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

Unified Diff: components/certificate_transparency/log_dns_client.cc

Issue 2380293002: Adds LogDnsClient::NotifyWhenNotThrottled (Closed)
Patch Set: Addresses Ryan's comment 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
Index: components/certificate_transparency/log_dns_client.cc
diff --git a/components/certificate_transparency/log_dns_client.cc b/components/certificate_transparency/log_dns_client.cc
index cd2ef9c7b818f7cb971e2f9d2543de2bccf71d4c..dd7810d04c9072d930e3b8c6095439daf13c5178 100644
--- a/components/certificate_transparency/log_dns_client.cc
+++ b/components/certificate_transparency/log_dns_client.cc
@@ -406,10 +406,15 @@ void LogDnsClient::OnDNSChanged() {
void LogDnsClient::OnInitialDNSConfigRead() {
UpdateDnsConfig();
}
+void LogDnsClient::NotifyWhenNotThrottled(const base::Closure& callback) {
+ DCHECK(HasMaxConcurrentQueriesInProgress());
+ not_throttled_callbacks_.push_back(callback);
+}
+
// |leaf_hash| is not a const-ref to allow callers to std::move that string into
// the method, avoiding LogDnsClient::AuditProofQuery having to make a copy.
net::Error LogDnsClient::QueryAuditProof(
base::StringPiece domain_for_log,
std::string leaf_hash,
@@ -452,10 +457,16 @@ void LogDnsClient::QueryAuditProofComplete(
});
DCHECK(query_iterator != audit_proof_queries_.end());
audit_proof_queries_.erase(query_iterator);
callback.Run(net_error);
+
+ // Notify interested parties that the next query will not be throttled.
+ std::list<base::Closure> callbacks = std::move(not_throttled_callbacks_);
+ for (const base::Closure& callback : callbacks) {
+ callback.Run();
+ }
}
bool LogDnsClient::HasMaxConcurrentQueriesInProgress() const {
return max_concurrent_queries_ != 0 &&
audit_proof_queries_.size() >= max_concurrent_queries_;
« no previous file with comments | « components/certificate_transparency/log_dns_client.h ('k') | components/certificate_transparency/log_dns_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698