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

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: 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(), false, callback));
dewittj 2016/07/12 21:57:20 I slightly prefer an enum class or a bitfield here
romax 2016/07/13 20:01:08 Done.
454 }
455
456 void OfflinePageModelImpl::GetAllPagesWithExpired(
457 const MultipleOfflinePageItemCallback& callback) {
458 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::GetAllPagesAfterLoadDone,
459 weak_ptr_factory_.GetWeakPtr(), true, callback));
454 } 460 }
455 461
456 void OfflinePageModelImpl::GetAllPagesAfterLoadDone( 462 void OfflinePageModelImpl::GetAllPagesAfterLoadDone(
463 bool with_expired,
457 const MultipleOfflinePageItemCallback& callback) const { 464 const MultipleOfflinePageItemCallback& callback) const {
458 DCHECK(is_loaded_); 465 DCHECK(is_loaded_);
459 466
460 MultipleOfflinePageItemResult offline_pages; 467 MultipleOfflinePageItemResult offline_pages;
461 for (const auto& id_page_pair : offline_pages_) { 468 for (const auto& id_page_pair : offline_pages_) {
462 if (!id_page_pair.second.IsExpired()) 469 if (with_expired || !id_page_pair.second.IsExpired())
463 offline_pages.push_back(id_page_pair.second); 470 offline_pages.push_back(id_page_pair.second);
464 } 471 }
465 472
466 callback.Run(offline_pages); 473 callback.Run(offline_pages);
467 } 474 }
468 475
469 void OfflinePageModelImpl::GetOfflineIdsForClientId( 476 void OfflinePageModelImpl::GetOfflineIdsForClientId(
470 const ClientId& client_id, 477 const ClientId& client_id,
471 const MultipleOfflineIdCallback& callback) { 478 const MultipleOfflineIdCallback& callback) {
472 RunWhenLoaded( 479 RunWhenLoaded(
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) { 1066 void OfflinePageModelImpl::RunWhenLoaded(const base::Closure& task) {
1060 if (!is_loaded_) { 1067 if (!is_loaded_) {
1061 delayed_tasks_.push_back(task); 1068 delayed_tasks_.push_back(task);
1062 return; 1069 return;
1063 } 1070 }
1064 1071
1065 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 1072 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
1066 } 1073 }
1067 1074
1068 } // namespace offline_pages 1075 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698