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

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

Issue 2142703002: [Offline Pages] Showing expired pages in internal page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests. Created 4 years, 5 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 #include "components/offline_pages/offline_page_model_impl.h" 5 #include "components/offline_pages/offline_page_model_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 auto iter = urls.find(id_page_pair.second.url); 443 auto iter = urls.find(id_page_pair.second.url);
444 if (iter != urls.end()) 444 if (iter != urls.end())
445 result.insert(*iter); 445 result.insert(*iter);
446 } 446 }
447 callback.Run(result); 447 callback.Run(result);
448 } 448 }
449 449
450 void OfflinePageModelImpl::GetAllPages( 450 void OfflinePageModelImpl::GetAllPages(
451 const MultipleOfflinePageItemCallback& callback) { 451 const MultipleOfflinePageItemCallback& callback) {
452 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::GetAllPagesAfterLoadDone, 452 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::GetAllPagesAfterLoadDone,
453 weak_ptr_factory_.GetWeakPtr(), callback)); 453 weak_ptr_factory_.GetWeakPtr(), GetAllPageMode::ALL,
454 callback));
455 }
456
457 void OfflinePageModelImpl::GetAllPagesWithExpired(
458 const MultipleOfflinePageItemCallback& callback) {
459 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::GetAllPagesAfterLoadDone,
460 weak_ptr_factory_.GetWeakPtr(),
461 GetAllPageMode::ALL_WITH_EXPIRED, callback));
454 } 462 }
455 463
456 void OfflinePageModelImpl::GetAllPagesAfterLoadDone( 464 void OfflinePageModelImpl::GetAllPagesAfterLoadDone(
465 GetAllPageMode mode,
457 const MultipleOfflinePageItemCallback& callback) const { 466 const MultipleOfflinePageItemCallback& callback) const {
458 DCHECK(is_loaded_); 467 DCHECK(is_loaded_);
459 468
460 MultipleOfflinePageItemResult offline_pages; 469 MultipleOfflinePageItemResult offline_pages;
461 for (const auto& id_page_pair : offline_pages_) { 470 for (const auto& id_page_pair : offline_pages_) {
462 if (!id_page_pair.second.IsExpired()) 471 if (mode == GetAllPageMode::ALL_WITH_EXPIRED ||
472 !id_page_pair.second.IsExpired())
463 offline_pages.push_back(id_page_pair.second); 473 offline_pages.push_back(id_page_pair.second);
464 } 474 }
465 475
466 callback.Run(offline_pages); 476 callback.Run(offline_pages);
467 } 477 }
468 478
469 void OfflinePageModelImpl::GetOfflineIdsForClientId( 479 void OfflinePageModelImpl::GetOfflineIdsForClientId(
470 const ClientId& client_id, 480 const ClientId& client_id,
471 const MultipleOfflineIdCallback& callback) { 481 const MultipleOfflineIdCallback& callback) {
472 RunWhenLoaded( 482 RunWhenLoaded(
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) { 1069 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) {
1060 if (!is_loaded_) { 1070 if (!is_loaded_) {
1061 delayed_tasks_.push_back(task); 1071 delayed_tasks_.push_back(task);
1062 return; 1072 return;
1063 } 1073 }
1064 1074
1065 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 1075 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
1066 } 1076 }
1067 1077
1068 } // namespace offline_pages 1078 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model_impl.h ('k') | components/offline_pages/stub_offline_page_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698