| Index: chrome/browser/chromeos/base/file_flusher.h
|
| diff --git a/chrome/browser/chromeos/base/file_flusher.h b/chrome/browser/chromeos/base/file_flusher.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7998a17cb1e703639f3ddba9c7631be133385644
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/base/file_flusher.h
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_
|
| +#define CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_
|
| +
|
| +#include <vector>
|
| +
|
| +#include "base/files/file_path.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +
|
| +namespace chromeos {
|
| +
|
| +// Flushes files under the requested directories in the blocking pool. If the
|
| +// same directory is requested more than once, the last request cancels all
|
| +// previous ones and start a new flushing process.
|
| +class FileFlusher {
|
| + public:
|
| + FileFlusher();
|
| + ~FileFlusher();
|
| +
|
| + // Flush everything under |path| except the directories/files in |excludes|.
|
| + // |excluedes| can hold both absolute or relative paths, where absolute paths
|
| + // are used as-is and relative paths are appended to |path| to make it
|
| + // absolute.
|
| + void RequestFlush(const base::FilePath& path,
|
| + const std::vector<base::FilePath>& excludes);
|
| +
|
| + private:
|
| + // Job for the flushing requests.
|
| + class Job;
|
| +
|
| + // Starts the first job in |jobs_|.
|
| + void ScheduleJob();
|
| +
|
| + // Invoked by a Job when it finishes.
|
| + void OnJobDone(Job* job);
|
| +
|
| + // Not owned. Job manages its own life time.
|
| + std::vector<Job*> jobs_;
|
| +
|
| + base::WeakPtrFactory<FileFlusher> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(FileFlusher);
|
| +};
|
| +
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_BASE_FILE_FLUSHER_H_
|
|
|