| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/files/file_path.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 |
| 14 namespace chromeos { |
| 15 |
| 16 // Flushes files under the requested directories in the blocking pool. If the |
| 17 // same directory is requested more than once, the last request cancels all |
| 18 // previous ones and start a new flushing process. |
| 19 class FileFlusher { |
| 20 public: |
| 21 FileFlusher(); |
| 22 ~FileFlusher(); |
| 23 |
| 24 // Flush everything under |path| except the directories/files in |excludes|. |
| 25 // |excluedes| can hold both absolute or relative paths, where absolute paths |
| 26 // are used as-is and relative paths are appended to |path| to make it |
| 27 // absolute. |
| 28 void RequestFlush(const base::FilePath& path, |
| 29 const std::vector<base::FilePath>& excludes); |
| 30 |
| 31 private: |
| 32 // Job for the flushing requests. |
| 33 class Job; |
| 34 |
| 35 // Starts the first job in |jobs_|. |
| 36 void ScheduleJob(); |
| 37 |
| 38 // Invoked by a Job when it finishes. |
| 39 void OnJobDone(Job* job); |
| 40 |
| 41 // Not owned. Job manages its own life time. |
| 42 std::vector<Job*> jobs_; |
| 43 |
| 44 base::WeakPtrFactory<FileFlusher> weak_factory_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(FileFlusher); |
| 47 }; |
| 48 |
| 49 } // namespace chromeos |
| 50 |
| 51 #endif // CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_ |
| OLD | NEW |