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

Unified Diff: net/log/bounded_file_net_log_observer.cc

Issue 2567473003: Reduce the number of PostTasks done by BoundedFiledNetLog. (Closed)
Patch Set: Created 4 years 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 | net/log/bounded_file_net_log_observer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/log/bounded_file_net_log_observer.cc
diff --git a/net/log/bounded_file_net_log_observer.cc b/net/log/bounded_file_net_log_observer.cc
index 833e84753d522884027fe21643059bcaba6723d6..d7b78f31a05478a4c3c97170ea0621601f111817 100644
--- a/net/log/bounded_file_net_log_observer.cc
+++ b/net/log/bounded_file_net_log_observer.cc
@@ -259,8 +259,10 @@ void BoundedFileNetLogObserver::OnAddEntry(const NetLogEntry& entry) {
size_t queue_size = write_queue_->AddEntryToQueue(std::move(json));
// If events build up in |write_queue_|, trigger the file thread to drain
- // the queue.
- if (queue_size >= kNumWriteQueueEvents) {
+ // the queue. Because only 1 item is added to the queue at a time, if
+ // queue_size > kNumWriteQueueEvents a task has already been posted, or will
+ // be posted.
+ if (queue_size == kNumWriteQueueEvents) {
task_runner_->PostTask(
FROM_HERE, base::Bind(&BoundedFileNetLogObserver::FileWriter::Flush,
base::Unretained(file_writer_), write_queue_));
« no previous file with comments | « no previous file | net/log/bounded_file_net_log_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698