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 COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_ | |
6 #define COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_ | |
7 | |
8 #include <set> | |
9 #include <vector> | |
10 | |
11 #include "base/callback_forward.h" | |
12 #include "base/files/file_path.h" | |
13 #include "base/memory/ref_counted.h" | |
14 | |
15 namespace base { | |
16 class SequencedTaskRunner; | |
17 } // namespace base | |
18 | |
19 namespace offline_pages { | |
20 | |
21 // Class that manages all archive files for offline pages. They are all stored | |
22 // in a specific archive directory. | |
23 // All tasks are performed using |task_runner_|. | |
24 class ArchiveManager { | |
25 public: | |
26 struct StorageStats { | |
27 int64_t free_disk_space; | |
28 int64_t total_archives_size; | |
29 }; | |
30 | |
31 ArchiveManager(const base::FilePath& archives_dir, | |
32 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | |
33 virtual ~ArchiveManager(); | |
34 | |
35 // Creates archives directory if one does not exist yet; | |
36 virtual void EnsureArchivesDirCreated(const base::Closure& callback); | |
37 | |
38 // Checks whether an archive with specified |archive_path| exists. | |
39 virtual void ExistsArchive(const base::FilePath& archive_path, | |
40 const base::Callback<void(bool)>& callback); | |
41 | |
42 // Deletes an archive with specified |archive_path|. | |
43 // It is considered successful to attempt to delete a file that does not | |
44 // exist. | |
45 virtual void DeleteArchive(const base::FilePath& archive_path, | |
46 const base::Callback<void(bool)>& callback); | |
47 | |
48 // Deletes multiple archives that are specified in |archive_paths|. | |
49 // It is considered successful to attempt to delete a file that does not | |
50 // exist. | |
51 virtual void DeleteMultipleArchives( | |
52 const std::vector<base::FilePath>& archive_paths, | |
53 const base::Callback<void(bool)>& callback); | |
54 | |
55 // Lists all archive files in the archive directory. | |
56 virtual void GetAllArchives( | |
57 const base::Callback<void(const std::set<base::FilePath>&)>& callback) | |
58 const; | |
59 | |
60 // Gets stats about archive storage, i.e. total archive sizes and free disk | |
61 // space. | |
62 virtual void GetStorageStats( | |
63 const base::Callback<void(const StorageStats& storage_sizes)>& callback) | |
64 const; | |
65 | |
66 protected: | |
67 ArchiveManager(); | |
68 | |
69 private: | |
70 // Path under which all of the managed archives should be stored. | |
71 base::FilePath archives_dir_; | |
72 // Task runner for running file operations. | |
73 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
74 }; | |
75 | |
76 } // namespace offline_pages | |
77 | |
78 #endif // COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_ | |
OLD | NEW |