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

Unified Diff: chrome/browser/chromeos/base/file_flusher.cc

Issue 2342813003: Fix flaky FileFlusherTest.DuplicateRequests (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « chrome/browser/chromeos/base/file_flusher.h ('k') | chrome/browser/chromeos/base/file_flusher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/base/file_flusher.cc
diff --git a/chrome/browser/chromeos/base/file_flusher.cc b/chrome/browser/chromeos/base/file_flusher.cc
index 43e06b5875dd34e5c58c3c566196ba7c1a353dab..45d5d1375fee964cf59e69533b94c77b95b08283 100644
--- a/chrome/browser/chromeos/base/file_flusher.cc
+++ b/chrome/browser/chromeos/base/file_flusher.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/base/file_flusher.h"
+#include <algorithm>
#include <set>
#include "base/bind.h"
@@ -68,6 +69,7 @@ class FileFlusher::Job {
bool started_ = false;
base::CancellationFlag cancel_flag_;
+ bool finish_scheduled_ = false;
DISALLOW_COPY_AND_ASSIGN(Job);
};
@@ -143,6 +145,10 @@ bool FileFlusher::Job::ShouldExclude(const base::FilePath& path) const {
}
void FileFlusher::Job::ScheduleFinish() {
+ if (finish_scheduled_)
+ return;
+
+ finish_scheduled_ = true;
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&Job::FinishOnUIThread, base::Unretained(this)));
@@ -183,8 +189,19 @@ void FileFlusher::RequestFlush(const base::FilePath& path,
ScheduleJob();
}
+void FileFlusher::PauseForTest() {
+ DCHECK(std::none_of(jobs_.begin(), jobs_.end(),
achuithb 2016/09/15 18:36:56 Wow, nice. It's like python.
+ [](const Job* job) { return job->started(); }));
+ paused_for_test_ = true;
+}
+
+void FileFlusher::ResumeForTest() {
+ paused_for_test_ = false;
+ ScheduleJob();
+}
+
void FileFlusher::ScheduleJob() {
- if (jobs_.empty())
+ if (jobs_.empty() || paused_for_test_)
return;
auto* job = jobs_.front();
« no previous file with comments | « chrome/browser/chromeos/base/file_flusher.h ('k') | chrome/browser/chromeos/base/file_flusher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698