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

Side by Side Diff: components/certificate_transparency/single_tree_tracker.cc

Issue 2668803004: Certificate Transparency: Discard entries pending auditing on network change (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 #include "components/certificate_transparency/single_tree_tracker.h" 5 #include "components/certificate_transparency/single_tree_tracker.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <list> 9 #include <list>
10 #include <utility> 10 #include <utility>
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 SingleTreeTracker::SingleTreeTracker( 215 SingleTreeTracker::SingleTreeTracker(
216 scoped_refptr<const net::CTLogVerifier> ct_log, 216 scoped_refptr<const net::CTLogVerifier> ct_log,
217 LogDnsClient* dns_client) 217 LogDnsClient* dns_client)
218 : ct_log_(std::move(ct_log)), 218 : ct_log_(std::move(ct_log)),
219 checked_entries_(kCheckedEntriesCacheSize), 219 checked_entries_(kCheckedEntriesCacheSize),
220 dns_client_(dns_client), 220 dns_client_(dns_client),
221 weak_factory_(this) { 221 weak_factory_(this) {
222 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind( 222 memory_pressure_listener_.reset(new base::MemoryPressureListener(base::Bind(
223 &SingleTreeTracker::OnMemoryPressure, base::Unretained(this)))); 223 &SingleTreeTracker::OnMemoryPressure, base::Unretained(this))));
224 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
224 } 225 }
225 226
226 SingleTreeTracker::~SingleTreeTracker() {} 227 SingleTreeTracker::~SingleTreeTracker() {
228 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
229 }
227 230
228 void SingleTreeTracker::OnSCTVerified(net::X509Certificate* cert, 231 void SingleTreeTracker::OnSCTVerified(net::X509Certificate* cert,
229 const SignedCertificateTimestamp* sct) { 232 const SignedCertificateTimestamp* sct) {
230 DCHECK_EQ(ct_log_->key_id(), sct->log_id); 233 DCHECK_EQ(ct_log_->key_id(), sct->log_id);
231 234
232 EntryToAudit entry(sct->timestamp); 235 EntryToAudit entry(sct->timestamp);
233 if (!GetLogEntryLeafHash(cert, sct, &entry.leaf_hash)) 236 if (!GetLogEntryLeafHash(cert, sct, &entry.leaf_hash))
234 return; 237 return;
235 238
236 // Avoid queueing multiple instances of the same entry. 239 // Avoid queueing multiple instances of the same entry.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 DCHECK_EQ(curr_entry->second.state, PENDING_NEWER_STH); 322 DCHECK_EQ(curr_entry->second.state, PENDING_NEWER_STH);
320 curr_entry->second.state = PENDING_INCLUSION_PROOF_REQUEST; 323 curr_entry->second.state = PENDING_INCLUSION_PROOF_REQUEST;
321 } 324 }
322 325
323 if (auditable_entries_begin == auditable_entries_end) 326 if (auditable_entries_begin == auditable_entries_end)
324 return; 327 return;
325 328
326 ProcessPendingEntries(); 329 ProcessPendingEntries();
327 } 330 }
328 331
332 void SingleTreeTracker::OnNetworkChanged(
333 net::NetworkChangeNotifier::ConnectionType type) {
334 pending_entries_.clear();
335 }
336
329 SingleTreeTracker::SCTInclusionStatus 337 SingleTreeTracker::SCTInclusionStatus
330 SingleTreeTracker::GetLogEntryInclusionStatus( 338 SingleTreeTracker::GetLogEntryInclusionStatus(
331 net::X509Certificate* cert, 339 net::X509Certificate* cert,
332 const SignedCertificateTimestamp* sct) { 340 const SignedCertificateTimestamp* sct) {
333 EntryToAudit entry(sct->timestamp); 341 EntryToAudit entry(sct->timestamp);
334 if (!GetLogEntryLeafHash(cert, sct, &entry.leaf_hash)) 342 if (!GetLogEntryLeafHash(cert, sct, &entry.leaf_hash))
335 return SCT_NOT_OBSERVED; 343 return SCT_NOT_OBSERVED;
336 return GetAuditedEntryInclusionStatus(entry); 344 return GetAuditedEntryInclusionStatus(entry);
337 } 345 }
338 346
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL: 457 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL:
450 pending_entries_.clear(); 458 pending_entries_.clear();
451 // Fall through to clearing the other cache. 459 // Fall through to clearing the other cache.
452 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE: 460 case base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE:
453 checked_entries_.Clear(); 461 checked_entries_.Clear();
454 break; 462 break;
455 } 463 }
456 } 464 }
457 465
458 } // namespace certificate_transparency 466 } // namespace certificate_transparency
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698