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

Side by Side Diff: components/offline_pages/offline_page_model_query.cc

Issue 2512073002: [Offline Pages] Removes two-step expiration related. (Closed)
Patch Set: adding unit in histograms. Created 4 years 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 #include "components/offline_pages/offline_page_model_query.h" 5 #include "components/offline_pages/offline_page_model_query.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <unordered_set> 8 #include <unordered_set>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return *this; 54 return *this;
55 } 55 }
56 56
57 OfflinePageModelQueryBuilder& 57 OfflinePageModelQueryBuilder&
58 OfflinePageModelQueryBuilder::RequireRestrictedToOriginalTab( 58 OfflinePageModelQueryBuilder::RequireRestrictedToOriginalTab(
59 Requirement original_tab) { 59 Requirement original_tab) {
60 restricted_to_original_tab_ = original_tab; 60 restricted_to_original_tab_ = original_tab;
61 return *this; 61 return *this;
62 } 62 }
63 63
64 OfflinePageModelQueryBuilder& OfflinePageModelQueryBuilder::AllowExpiredPages(
65 bool allow_expired) {
66 allow_expired_ = allow_expired;
67 return *this;
68 }
69
70 std::unique_ptr<OfflinePageModelQuery> OfflinePageModelQueryBuilder::Build( 64 std::unique_ptr<OfflinePageModelQuery> OfflinePageModelQueryBuilder::Build(
71 ClientPolicyController* controller) { 65 ClientPolicyController* controller) {
72 DCHECK(controller); 66 DCHECK(controller);
73 67
74 auto query = base::MakeUnique<OfflinePageModelQuery>(); 68 auto query = base::MakeUnique<OfflinePageModelQuery>();
75 69
76 query->allow_expired_ = allow_expired_;
77 query->urls_ = std::make_pair( 70 query->urls_ = std::make_pair(
78 urls_.first, std::set<GURL>(urls_.second.begin(), urls_.second.end())); 71 urls_.first, std::set<GURL>(urls_.second.begin(), urls_.second.end()));
79 urls_ = std::make_pair(Requirement::UNSET, std::vector<GURL>()); 72 urls_ = std::make_pair(Requirement::UNSET, std::vector<GURL>());
80 query->offline_ids_ = std::make_pair( 73 query->offline_ids_ = std::make_pair(
81 offline_ids_.first, std::set<int64_t>(offline_ids_.second.begin(), 74 offline_ids_.first, std::set<int64_t>(offline_ids_.second.begin(),
82 offline_ids_.second.end())); 75 offline_ids_.second.end()));
83 offline_ids_ = std::make_pair(Requirement::UNSET, std::vector<int64_t>()); 76 offline_ids_ = std::make_pair(Requirement::UNSET, std::vector<int64_t>());
84 query->client_ids_ = std::make_pair( 77 query->client_ids_ = std::make_pair(
85 client_ids_.first, 78 client_ids_.first,
86 std::set<ClientId>(client_ids_.second.begin(), client_ids_.second.end())); 79 std::set<ClientId>(client_ids_.second.begin(), client_ids_.second.end()));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 151 }
159 152
160 std::pair<Requirement, std::set<GURL>> 153 std::pair<Requirement, std::set<GURL>>
161 OfflinePageModelQuery::GetRestrictedToUrls() const { 154 OfflinePageModelQuery::GetRestrictedToUrls() const {
162 if (urls_.first == Requirement::UNSET) 155 if (urls_.first == Requirement::UNSET)
163 return std::make_pair(Requirement::UNSET, std::set<GURL>()); 156 return std::make_pair(Requirement::UNSET, std::set<GURL>());
164 157
165 return urls_; 158 return urls_;
166 } 159 }
167 160
168 bool OfflinePageModelQuery::GetAllowExpired() const {
169 return allow_expired_;
170 }
171
172 bool OfflinePageModelQuery::Matches(const OfflinePageItem& item) const { 161 bool OfflinePageModelQuery::Matches(const OfflinePageItem& item) const {
173 if (!allow_expired_ && item.IsExpired())
174 return false;
175
176 switch (offline_ids_.first) { 162 switch (offline_ids_.first) {
177 case Requirement::UNSET: 163 case Requirement::UNSET:
178 break; 164 break;
179 case Requirement::INCLUDE_MATCHING: 165 case Requirement::INCLUDE_MATCHING:
180 if (offline_ids_.second.count(item.offline_id) == 0) 166 if (offline_ids_.second.count(item.offline_id) == 0)
181 return false; 167 return false;
182 break; 168 break;
183 case Requirement::EXCLUDE_MATCHING: 169 case Requirement::EXCLUDE_MATCHING:
184 if (offline_ids_.second.count(item.offline_id) > 0) 170 if (offline_ids_.second.count(item.offline_id) > 0)
185 return false; 171 return false;
(...skipping 29 matching lines...) Expand all
215 case Requirement::EXCLUDE_MATCHING: 201 case Requirement::EXCLUDE_MATCHING:
216 if (client_ids_.second.count(client_id) > 0) 202 if (client_ids_.second.count(client_id) > 0)
217 return false; 203 return false;
218 break; 204 break;
219 } 205 }
220 206
221 return true; 207 return true;
222 } 208 }
223 209
224 } // namespace offline_pages 210 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model_query.h ('k') | components/offline_pages/offline_page_model_query_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698