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

Side by Side Diff: components/offline_pages/core/archive_manager.h

Issue 2889663004: [DO NOT COMMIT][Offline Pages] Moving Offline Page Cache to cache directory.
Patch Set: again? Created 3 years, 7 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 COMPONENTS_OFFLINE_PAGES_CORE_ARCHIVE_MANAGER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_ARCHIVE_MANAGER_H_
6 #define COMPONENTS_OFFLINE_PAGES_CORE_ARCHIVE_MANAGER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_CORE_ARCHIVE_MANAGER_H_
7 7
8 #include <map>
8 #include <set> 9 #include <set>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "components/offline_pages/core/offline_page_client_policy.h"
14 16
15 namespace base { 17 namespace base {
16 class SequencedTaskRunner; 18 class SequencedTaskRunner;
17 } // namespace base 19 } // namespace base
18 20
19 namespace offline_pages { 21 namespace offline_pages {
20 22
21 // Class that manages all archive files for offline pages. They are all stored 23 typedef std::map<LifetimePolicy::LifetimeType, base::FilePath>
22 // in a specific archive directory. 24 ArchiveDirectories;
25
26 // Class that manages all archive files for offline pages. They are stored in
27 // different archive directories separated by their lifetime types.
23 // All tasks are performed using |task_runner_|. 28 // All tasks are performed using |task_runner_|.
24 class ArchiveManager { 29 class ArchiveManager {
25 public: 30 public:
26 struct StorageStats { 31 struct StorageStats {
27 int64_t free_disk_space; 32 int64_t free_disk_space;
28 int64_t total_archives_size; 33 int64_t total_archives_size;
29 }; 34 };
30 35
31 ArchiveManager(const base::FilePath& archives_dir, 36 ArchiveManager(const ArchiveDirectories& archive_dirs,
32 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 37 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
33 virtual ~ArchiveManager(); 38 virtual ~ArchiveManager();
34 39
35 // Creates archives directory if one does not exist yet; 40 // Creates archives directory if one does not exist yet;
36 virtual void EnsureArchivesDirCreated(const base::Closure& callback); 41 virtual void EnsureArchivesDirCreated(const base::Closure& callback);
37 42
38 // Checks whether an archive with specified |archive_path| exists. 43 // Checks whether an archive with specified |archive_path| exists.
39 virtual void ExistsArchive(const base::FilePath& archive_path, 44 virtual void ExistsArchive(const base::FilePath& archive_path,
40 const base::Callback<void(bool)>& callback); 45 const base::Callback<void(bool)>& callback);
41 46
42 // Deletes an archive with specified |archive_path|. 47 // Deletes an archive with specified |archive_path|.
43 // It is considered successful to attempt to delete a file that does not 48 // It is considered successful to attempt to delete a file that does not
44 // exist. 49 // exist.
45 virtual void DeleteArchive(const base::FilePath& archive_path, 50 virtual void DeleteArchive(const base::FilePath& archive_path,
46 const base::Callback<void(bool)>& callback); 51 const base::Callback<void(bool)>& callback);
47 52
48 // Deletes multiple archives that are specified in |archive_paths|. 53 // Deletes multiple archives that are specified in |archive_paths|.
49 // It is considered successful to attempt to delete a file that does not 54 // It is considered successful to attempt to delete a file that does not
50 // exist. 55 // exist.
51 virtual void DeleteMultipleArchives( 56 virtual void DeleteMultipleArchives(
52 const std::vector<base::FilePath>& archive_paths, 57 const std::vector<base::FilePath>& archive_paths,
53 const base::Callback<void(bool)>& callback); 58 const base::Callback<void(bool)>& callback);
54 59
55 // Lists all archive files in the archive directory. 60 // Lists all archive files in all the archive directories.
56 virtual void GetAllArchives( 61 virtual void GetAllArchives(
57 const base::Callback<void(const std::set<base::FilePath>&)>& callback) 62 const base::Callback<void(const std::set<base::FilePath>&)>& callback)
58 const; 63 const;
59 64
60 // Gets stats about archive storage, i.e. total archive sizes and free disk 65 // Gets stats about archive storage, i.e. total archive sizes and free disk
61 // space. 66 // space for all clients with specified lifetime types.
62 virtual void GetStorageStats( 67 virtual void GetStorageStats(
68 const std::set<LifetimePolicy::LifetimeType>& lifetime_types,
63 const base::Callback<void(const StorageStats& storage_sizes)>& callback) 69 const base::Callback<void(const StorageStats& storage_sizes)>& callback)
64 const; 70 const;
65 71
66 protected: 72 protected:
67 ArchiveManager(); 73 ArchiveManager();
68 74
69 private: 75 private:
70 // Path under which all of the managed archives should be stored. 76 // A map of archive directories by lifetime type of archives.
71 base::FilePath archives_dir_; 77 ArchiveDirectories archive_dirs_;
72 // Task runner for running file operations. 78 // Task runner for running file operations.
73 scoped_refptr<base::SequencedTaskRunner> task_runner_; 79 scoped_refptr<base::SequencedTaskRunner> task_runner_;
74 }; 80 };
75 81
76 } // namespace offline_pages 82 } // namespace offline_pages
77 83
78 #endif // COMPONENTS_OFFLINE_PAGES_CORE_ARCHIVE_MANAGER_H_ 84 #endif // COMPONENTS_OFFLINE_PAGES_CORE_ARCHIVE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698