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

Unified Diff: chrome/browser/net/passive_log_collector.cc

Issue 4960001: Fix a DCHECK that could fire in PassiveLogCollector for a particular stream o... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rename x --> log Created 10 years, 1 month 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 | « chrome/browser/net/passive_log_collector.h ('k') | chrome/browser/net/passive_log_collector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/passive_log_collector.cc
===================================================================
--- chrome/browser/net/passive_log_collector.cc (revision 65117)
+++ chrome/browser/net/passive_log_collector.cc (working copy)
@@ -289,6 +289,15 @@
}
}
+void PassiveLogCollector::SourceTracker::EraseFromDeletionQueue(
+ uint32 source_id) {
+ DeletionQueue::iterator it =
+ std::remove(deletion_queue_.begin(), deletion_queue_.end(),
+ source_id);
+ DCHECK(it != deletion_queue_.end());
+ deletion_queue_.erase(it);
+}
+
void PassiveLogCollector::SourceTracker::AdjustReferenceCountForSource(
int offset, uint32 source_id) {
DCHECK(offset == -1 || offset == 1) << "invalid offset: " << offset;
@@ -306,7 +315,8 @@
DCHECK_GE(info.reference_count, 0);
info.reference_count += offset;
- if (info.reference_count < 0) {
+ bool released_unmatched_reference = info.reference_count < 0;
+ if (released_unmatched_reference) {
// In general this shouldn't happen, however it is possible to reach this
// state if SourceTracker::Clear() was called earlier.
LOG(WARNING) << "Released unmatched reference count.";
@@ -317,12 +327,10 @@
if (info.reference_count == 1 && offset == 1) {
// If we just added a reference to a dead source that had no references,
// it must have been in the deletion queue, so remove it from the queue.
- DeletionQueue::iterator it =
- std::remove(deletion_queue_.begin(), deletion_queue_.end(),
- source_id);
- DCHECK(it != deletion_queue_.end());
- deletion_queue_.erase(it);
+ EraseFromDeletionQueue(source_id);
} else if (info.reference_count == 0) {
+ if (released_unmatched_reference)
+ EraseFromDeletionQueue(source_id);
// If we just released the final reference to a dead source, go ahead
// and delete it right away.
DeleteSourceInfo(source_id);
« no previous file with comments | « chrome/browser/net/passive_log_collector.h ('k') | chrome/browser/net/passive_log_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698