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

Side by Side Diff: chrome/browser/chromeos/base/file_flusher.h

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 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 #ifndef CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_
6 #define CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_ 6 #define CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 20 matching lines...) Expand all
31 const base::Closure& callback); 31 const base::Closure& callback);
32 32
33 // Set a callback for every file flush for test. Note the callback is 33 // Set a callback for every file flush for test. Note the callback is
34 // called on a blocking pool thread. 34 // called on a blocking pool thread.
35 using OnFlushCallback = base::Callback<void(const base::FilePath&)>; 35 using OnFlushCallback = base::Callback<void(const base::FilePath&)>;
36 void set_on_flush_callback_for_test( 36 void set_on_flush_callback_for_test(
37 const OnFlushCallback& on_flush_callback) { 37 const OnFlushCallback& on_flush_callback) {
38 on_flush_callback_for_test_ = on_flush_callback; 38 on_flush_callback_for_test_ = on_flush_callback;
39 } 39 }
40 40
41 void PauseForTest();
42 void ResumeForTest();
43
41 private: 44 private:
42 // Job for the flushing requests. 45 // Job for the flushing requests.
43 class Job; 46 class Job;
44 47
45 // Starts the first job in |jobs_|. 48 // Starts the first job in |jobs_|.
46 void ScheduleJob(); 49 void ScheduleJob();
47 50
48 // Invoked by a Job when it finishes. 51 // Invoked by a Job when it finishes.
49 void OnJobDone(Job* job); 52 void OnJobDone(Job* job);
50 53
51 // Not owned. Job manages its own life time. 54 // Not owned. Job manages its own life time.
52 std::vector<Job*> jobs_; 55 std::vector<Job*> jobs_;
53 56
54 // A callback for testing to be invoked when a file is flushed. 57 // A callback for testing to be invoked when a file is flushed.
55 OnFlushCallback on_flush_callback_for_test_; 58 OnFlushCallback on_flush_callback_for_test_;
56 59
60 bool paused_for_test_ = false;
61
57 base::WeakPtrFactory<FileFlusher> weak_factory_; 62 base::WeakPtrFactory<FileFlusher> weak_factory_;
58 63
59 DISALLOW_COPY_AND_ASSIGN(FileFlusher); 64 DISALLOW_COPY_AND_ASSIGN(FileFlusher);
60 }; 65 };
61 66
62 } // namespace chromeos 67 } // namespace chromeos
63 68
64 #endif // CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_ 69 #endif // CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/base/file_flusher.cc » ('j') | chrome/browser/chromeos/base/file_flusher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698