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

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

Issue 1947323002: [Offline Pages] Implement OfflinePageStorageManager. (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
(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_OFFLINE_PAGE_STORAGE_MANAGER_H_
6 #define COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_
7
8 #include <stdint.h>
9
10 #include <vector>
11
12 #include "components/offline_pages/client_policy_controller.h"
13 #include "components/offline_pages/offline_page_model.h"
fgorski 2016/05/05 04:53:08 Both can be forward declared. Include in .cc
romax 2016/05/05 21:00:03 Done.
romax 2016/05/06 01:02:32 I don't know how to forward declare a typedef in o
14
15 namespace offline_pages {
16
17 // TODO(romax): Keep this as a default value until I find a way to get
18 // storage size in C++. (20MB)
19 static const int64_t kDefaultStorageSize = 20 * (1 << 20);
20
21 // This class is used for storage management of offline pages. It provides
22 // a ClearPagesIfNeeded method which is used to clear expired offline pages
23 // based on last_access_time and lifetime policy of its namespace.
24 // It has its own throttle mechanism so calling the method would not be
25 // guaranteed to clear the pages immediately.
26 // This manager should be owned by OfflinePageModel since it needs the
fgorski 2016/05/05 04:53:09 This sentence is misleading. Message 1: OPM shoul
romax 2016/05/05 21:00:03 Done.
27 // functionality to delete/get pages.
28 class OfflinePageStorageManager {
fgorski 2016/05/05 04:53:09 please create explicit tests for this class.
fgorski 2016/05/06 05:57:24 ??
29 public:
30 typedef base::Callback<void(int)> ClearPageCallback;
fgorski 2016/05/05 04:53:09 ClearPagesCallback. add at least a boolean variab
romax 2016/05/06 01:02:32 In the next patch I'll be using DeletePageResult.
31
32 OfflinePageStorageManager(OfflinePageModel* model,
fgorski 2016/05/05 04:53:09 1. Will this work as an implicit constructor if I
romax 2016/05/06 01:02:32 Done.
33 int64_t totalSize = kDefaultStorageSize);
34 ~OfflinePageStorageManager();
35
36 void ClearPagesIfNeeded(const ClearPageCallback& callback);
fgorski 2016/05/05 04:53:09 documentation.
romax 2016/05/05 21:00:03 Acknowledged.
37
38 private:
39 void PurgePages(const ClearPageCallback& callback,
40 const OfflinePageModel::MultipleOfflinePageItemResult& pages);
41
42 int GetExpiredPageIds(
fgorski 2016/05/05 04:53:09 document. What is the result?
romax 2016/05/05 21:00:03 it was the same as offline_ids.size().. so changed
43 const OfflinePageModel::MultipleOfflinePageItemResult& pages,
44 std::vector<int64_t>& offline_ids);
fgorski 2016/05/05 04:53:09 const & ?
romax 2016/05/05 21:00:03 no I meant to change the value...
45
46 void OnExpiredPagesDeleted(const ClearPageCallback& callback,
47 int pages_to_clear,
48 OfflinePageModel::DeletePageResult result);
49
50 bool ShouldClearPages();
51
52 bool isPageExpired(const OfflinePageItem& page);
fgorski 2016/05/05 04:53:08 IsPageExpired
romax 2016/05/05 21:00:03 Done.
53
54 // Not owning.
fgorski 2016/05/05 04:53:09 Not owned.
romax 2016/05/05 21:00:03 Done.
55 OfflinePageModel* model_;
56
57 // Not owning
fgorski 2016/05/05 04:53:09 Not owned.
romax 2016/05/05 21:00:03 Done.
58 ClientPolicyController* policy_controller_;
59
60 bool in_progress_;
61
62 int64_t size_;
63
64 base::WeakPtrFactory<OfflinePageStorageManager> weak_ptr_factory_;
65
66 DISALLOW_COPY_AND_ASSIGN(OfflinePageStorageManager);
fgorski 2016/05/05 04:53:09 include base/macros.h
romax 2016/05/05 21:00:03 Done.
67 };
68
69 } // namespace offline_pages
70
71 #endif // COMPONENTS_OFFLINE_PAGES_OFFLINE_PAGE_STORAGE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698