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

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

Issue 1988973002: [Offline pages] Moving disk size related calls to Archive Manager, reorganizing UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@archive-manager
Patch Set: Addressing feedback Created 4 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_ARCHIVE_MANAGER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_
6 #define COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 14
15 namespace base { 15 namespace base {
16 class SequencedTaskRunner; 16 class SequencedTaskRunner;
17 } // namespace base 17 } // namespace base
18 18
19 namespace offline_pages { 19 namespace offline_pages {
20 20
21 // Class that manages all archive files for offline pages. They are all stored 21 // Class that manages all archive files for offline pages. They are all stored
22 // in a specific archive directory. 22 // in a specific archive directory.
23 // All tasks are performed using |task_runner_|. 23 // All tasks are performed using |task_runner_|.
24 class ArchiveManager { 24 class ArchiveManager {
25 public: 25 public:
26 struct StorageStats {
27 int64_t free_disk_space;
28 int64_t total_archives_size;
29 };
30
26 ArchiveManager(const base::FilePath& archives_dir, 31 ArchiveManager(const base::FilePath& archives_dir,
27 const scoped_refptr<base::SequencedTaskRunner>& task_runner); 32 const scoped_refptr<base::SequencedTaskRunner>& task_runner);
28 virtual ~ArchiveManager(); 33 virtual ~ArchiveManager();
29 34
30 // Creates archives directory if one does not exist yet; 35 // Creates archives directory if one does not exist yet;
31 virtual void EnsureArchivesDirCreated(const base::Closure& callback); 36 virtual void EnsureArchivesDirCreated(const base::Closure& callback);
32 37
33 // Checks whether an archive with specified |archive_path| exists. 38 // Checks whether an archive with specified |archive_path| exists.
34 virtual void ExistsArchive(const base::FilePath& archive_path, 39 virtual void ExistsArchive(const base::FilePath& archive_path,
35 const base::Callback<void(bool)>& callback); 40 const base::Callback<void(bool)>& callback);
36 41
37 // Deletes an archive with specified |archive_path|. 42 // Deletes an archive with specified |archive_path|.
38 // It is considered successful to attempt to delete a file that does not 43 // It is considered successful to attempt to delete a file that does not
39 // exist. 44 // exist.
40 virtual void DeleteArchive(const base::FilePath& archive_path, 45 virtual void DeleteArchive(const base::FilePath& archive_path,
41 const base::Callback<void(bool)>& callback); 46 const base::Callback<void(bool)>& callback);
42 47
43 // Deletes multiple archives that are specified in |archive_paths|. 48 // Deletes multiple archives that are specified in |archive_paths|.
44 // It is considered successful to attempt to delete a file that does not 49 // It is considered successful to attempt to delete a file that does not
45 // exist. 50 // exist.
46 virtual void DeleteMultipleArchives( 51 virtual void DeleteMultipleArchives(
47 const std::vector<base::FilePath>& archive_paths, 52 const std::vector<base::FilePath>& archive_paths,
48 const base::Callback<void(bool)>& callback); 53 const base::Callback<void(bool)>& callback);
49 54
50 // Lists all archive files in the archive directory. 55 // Lists all archive files in the archive directory.
51 virtual void GetAllArchives( 56 virtual void GetAllArchives(
52 const base::Callback<void(const std::set<base::FilePath>&)>& callback) 57 const base::Callback<void(const std::set<base::FilePath>&)>& callback)
53 const; 58 const;
54 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
55 private: 66 private:
56 // Path under which all of the managed archives should be stored. 67 // Path under which all of the managed archives should be stored.
57 base::FilePath archives_dir_; 68 base::FilePath archives_dir_;
58 // Task runner for running file operations. 69 // Task runner for running file operations.
59 scoped_refptr<base::SequencedTaskRunner> task_runner_; 70 scoped_refptr<base::SequencedTaskRunner> task_runner_;
60 }; 71 };
61 72
62 } // namespace offline_pages 73 } // namespace offline_pages
63 74
64 #endif // COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_ 75 #endif // COMPONENTS_OFFLINE_PAGES_ARCHIVE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/offline_pages/offline_page_bridge.cc ('k') | components/offline_pages/archive_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698