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

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

Issue 1815853002: cros: Flush profile files at critical moments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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_
« 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