OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.h" | 5 #include "components/offline_pages/offline_page_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 for (const auto& id_page_pair : offline_pages_) | 173 for (const auto& id_page_pair : offline_pages_) |
174 offline_pages.push_back(id_page_pair.second); | 174 offline_pages.push_back(id_page_pair.second); |
175 return offline_pages; | 175 return offline_pages; |
176 } | 176 } |
177 | 177 |
178 const std::vector<OfflinePageItem> OfflinePageModel::GetPagesToCleanUp() const { | 178 const std::vector<OfflinePageItem> OfflinePageModel::GetPagesToCleanUp() const { |
179 DCHECK(is_loaded_); | 179 DCHECK(is_loaded_); |
180 std::vector<OfflinePageItem> offline_pages; | 180 std::vector<OfflinePageItem> offline_pages; |
181 base::Time now = base::Time::Now(); | 181 base::Time now = base::Time::Now(); |
182 for (const auto& id_page_pair : offline_pages_) { | 182 for (const auto& id_page_pair : offline_pages_) { |
183 if (now - id_page_pair.second.creation_time > kPageCleanUpThreshold) | 183 if (now - id_page_pair.second.last_access_time > kPageCleanUpThreshold) |
184 offline_pages.push_back(id_page_pair.second); | 184 offline_pages.push_back(id_page_pair.second); |
185 } | 185 } |
186 return offline_pages; | 186 return offline_pages; |
187 } | 187 } |
188 | 188 |
189 const OfflinePageItem* OfflinePageModel::GetPageByBookmarkId( | 189 const OfflinePageItem* OfflinePageModel::GetPageByBookmarkId( |
190 int64 bookmark_id) const { | 190 int64 bookmark_id) const { |
191 const auto iter = offline_pages_.find(bookmark_id); | 191 const auto iter = offline_pages_.find(bookmark_id); |
192 return iter != offline_pages_.end() ? &(iter->second) : nullptr; | 192 return iter != offline_pages_.end() ? &(iter->second) : nullptr; |
193 } | 193 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 void OfflinePageModel::InformDeletePageDone(const DeletePageCallback& callback, | 362 void OfflinePageModel::InformDeletePageDone(const DeletePageCallback& callback, |
363 DeletePageResult result) { | 363 DeletePageResult result) { |
364 UMA_HISTOGRAM_ENUMERATION( | 364 UMA_HISTOGRAM_ENUMERATION( |
365 "OfflinePages.DeletePageResult", | 365 "OfflinePages.DeletePageResult", |
366 static_cast<int>(result), | 366 static_cast<int>(result), |
367 static_cast<int>(DeletePageResult::RESULT_COUNT)); | 367 static_cast<int>(DeletePageResult::RESULT_COUNT)); |
368 callback.Run(result); | 368 callback.Run(result); |
369 } | 369 } |
370 | 370 |
371 } // namespace offline_pages | 371 } // namespace offline_pages |
OLD | NEW |