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

Side by Side Diff: components/offline_pages/core/cached_offline_page_utils.cc

Issue 2860573004: [Offline Pages] Add cached offline page utils and show usage in settings. (Closed)
Patch Set: comments from carlosk@. 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
(Empty)
1 // Copyright 2017 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 #include "components/offline_pages/core/cached_offline_page_utils.h"
6
7 #include <stdint.h>
8
9 #include "base/bind.h"
10 #include "base/time/time.h"
11 #include "components/offline_pages/core/offline_page_item.h"
12 #include "components/offline_pages/core/offline_page_model.h"
13 #include "components/offline_pages/core/offline_page_types.h"
14
15 namespace {
16
17 void DoCalculateSizeBetween(
18 const offline_pages::SizeCalculatedCallback& callback,
19 const base::Time& begin_time,
20 const base::Time& end_time,
21 const offline_pages::MultipleOfflinePageItemResult& result) {
22 int64_t total_size = 0;
23 for (auto& page : result) {
24 if (begin_time < page.creation_time && page.creation_time < end_time)
25 total_size += page.file_size;
26 }
27 callback.Run(total_size);
28 }
29
30 } // namespace
31
32 namespace offline_pages {
33
34 void GetCachedOfflinePageSizeBetween(OfflinePageModel* model,
35 const SizeCalculatedCallback& callback,
36 const base::Time& begin_time,
37 const base::Time& end_time) {
38 DCHECK(model);
39 OfflinePageModelQueryBuilder builder;
40 builder.RequireRemovedOnCacheReset(
41 OfflinePageModelQuery::Requirement::INCLUDE_MATCHING);
42 model->GetPagesMatchingQuery(
43 builder.Build(model->GetPolicyController()),
44 base::Bind(&DoCalculateSizeBetween, callback, begin_time, end_time));
45 }
46
47 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698