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

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

Issue 1968563003: [Offline pages] Extracting callbacks from the Offline Page Model (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_OFFLINE_PAGE_STORAGE_MANAGER_H_ 5 #ifndef COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ 6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 18 matching lines...) Expand all
29 // It has its own throttle mechanism so calling the method would not be 29 // It has its own throttle mechanism so calling the method would not be
30 // guaranteed to clear the pages immediately. 30 // guaranteed to clear the pages immediately.
31 // 31 //
32 // OfflinePageModel should own and control the lifecycle of this manager. 32 // OfflinePageModel should own and control the lifecycle of this manager.
33 // And this manager would use OfflinePageModel to get/remove pages. 33 // And this manager would use OfflinePageModel to get/remove pages.
34 class OfflinePageStorageManager { 34 class OfflinePageStorageManager {
35 public: 35 public:
36 // Callback used when calling ClearPagesIfNeeded. 36 // Callback used when calling ClearPagesIfNeeded.
37 // int: the number of deleted pages. 37 // int: the number of deleted pages.
38 // DeletePageResult: result of deleting pages. 38 // DeletePageResult: result of deleting pages.
39 typedef base::Callback<void(int, OfflinePageModel::DeletePageResult)> 39 typedef base::Callback<void(int, DeletePageResult)>
40 ClearPageCallback; 40 ClearPageCallback;
41 41
42 explicit OfflinePageStorageManager(OfflinePageModel* model); 42 explicit OfflinePageStorageManager(OfflinePageModel* model);
43 43
44 ~OfflinePageStorageManager(); 44 ~OfflinePageStorageManager();
45 45
46 // The manager would *try* to clear pages when called. It may not delete any 46 // The manager would *try* to clear pages when called. It may not delete any
47 // pages (if clearing condition wasn't satisfied). 47 // pages (if clearing condition wasn't satisfied).
48 void ClearPagesIfNeeded(const ClearPageCallback& callback); 48 void ClearPagesIfNeeded(const ClearPageCallback& callback);
49 49
50 private: 50 private:
51 // Selects and removes pages that need to be expired. Triggered as a callback 51 // Selects and removes pages that need to be expired. Triggered as a callback
52 // to |GetAllPages|. 52 // to |GetAllPages|.
53 void ClearExpiredPages( 53 void ClearExpiredPages(
54 const ClearPageCallback& callback, 54 const ClearPageCallback& callback,
55 const OfflinePageModel::MultipleOfflinePageItemResult& pages); 55 const MultipleOfflinePageItemResult& pages);
56 56
57 // Gets offline IDs of all expired pages and return in |offline_ids|. 57 // Gets offline IDs of all expired pages and return in |offline_ids|.
58 void GetExpiredPageIds( 58 void GetExpiredPageIds(
59 const OfflinePageModel::MultipleOfflinePageItemResult& pages, 59 const MultipleOfflinePageItemResult& pages,
60 std::vector<int64_t>& offline_ids); 60 std::vector<int64_t>& offline_ids);
61 61
62 // Callback when expired pages has been deleted. 62 // Callback when expired pages has been deleted.
63 void OnExpiredPagesDeleted(const ClearPageCallback& callback, 63 void OnExpiredPagesDeleted(const ClearPageCallback& callback,
64 int pages_to_clear, 64 int pages_to_clear,
65 OfflinePageModel::DeletePageResult result); 65 DeletePageResult result);
66 66
67 // Determine if manager should clear pages. 67 // Determine if manager should clear pages.
68 bool ShouldClearPages(); 68 bool ShouldClearPages();
69 69
70 // Return true if |page| is expired. 70 // Return true if |page| is expired.
71 bool IsPageExpired(const OfflinePageItem& page); 71 bool IsPageExpired(const OfflinePageItem& page);
72 72
73 // Not owned. 73 // Not owned.
74 OfflinePageModel* model_; 74 OfflinePageModel* model_;
75 75
76 // Not owned. 76 // Not owned.
77 ClientPolicyController* policy_controller_; 77 ClientPolicyController* policy_controller_;
78 78
79 bool in_progress_; 79 bool in_progress_;
80 80
81 base::WeakPtrFactory<OfflinePageStorageManager> weak_ptr_factory_; 81 base::WeakPtrFactory<OfflinePageStorageManager> weak_ptr_factory_;
82 82
83 DISALLOW_COPY_AND_ASSIGN(OfflinePageStorageManager); 83 DISALLOW_COPY_AND_ASSIGN(OfflinePageStorageManager);
84 }; 84 };
85 85
86 } // namespace offline_pages 86 } // namespace offline_pages
87 87
88 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_ 88 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698