Chromium Code Reviews| 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 1344cb86ccdb682fcdcaeb64919e7e4a9e8776ae..a7601c0d3817ef6815e688cff2feb26fdc08ffb0 100644 |
| --- a/components/certificate_transparency/log_dns_client.cc |
| +++ b/components/certificate_transparency/log_dns_client.cc |
| @@ -352,10 +352,16 @@ void LogDnsClient::OnDNSChanged() { |
| void LogDnsClient::OnInitialDNSConfigRead() { |
| UpdateDnsConfig(); |
| } |
| +void LogDnsClient::NotifyWhenNotThrottled( |
| + const NotThrottledCallback& callback) { |
| + DCHECK(HasMaxConcurrentQueriesInProgress()); |
| + not_throttled_callbacks_.push_back(callback); |
| +} |
| + |
| net::Error LogDnsClient::QueryAuditProof(base::StringPiece domain_for_log, |
| base::StringPiece leaf_hash, |
| uint64_t tree_size, |
| const AuditProofCallback& callback) { |
| if (domain_for_log.empty() || leaf_hash.size() != crypto::kSHA256Length) { |
| @@ -399,10 +405,16 @@ void LogDnsClient::QueryAuditProofComplete(const AuditProofCallback& callback, |
| DCHECK(query_iterator != audit_proof_queries_.end()); |
| audit_proof_queries_.erase(query_iterator); |
| base::ThreadTaskRunnerHandle::Get()->PostTask( |
| FROM_HERE, base::Bind(callback, result, base::Passed(&proof))); |
| + |
| + for (const NotThrottledCallback& callback : not_throttled_callbacks_) { |
| + base::ThreadTaskRunnerHandle::Get()->PostTask( |
| + FROM_HERE, base::Bind(callback, weak_ptr_factory_.GetWeakPtr())); |
|
Ryan Sleevi
2016/10/03 23:56:04
From a design perspective: Why asynchronously? Why
Rob Percival
2016/10/04 18:53:03
An abundance of caution, but actually this can be
|
| + } |
| + not_throttled_callbacks_.clear(); |
| } |
| bool LogDnsClient::HasMaxConcurrentQueriesInProgress() const { |
| return max_concurrent_queries_ != 0 && |
| audit_proof_queries_.size() >= max_concurrent_queries_; |