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

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

Issue 1993953002: [Offline pages] Adding expiration capability to OfflinePageModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing feedback Created 4 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
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 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 } 501 }
502 502
503 void OfflinePageModel::CheckForExternalFileDeletion() { 503 void OfflinePageModel::CheckForExternalFileDeletion() {
504 DCHECK(is_loaded_); 504 DCHECK(is_loaded_);
505 505
506 archive_manager_->GetAllArchives( 506 archive_manager_->GetAllArchives(
507 base::Bind(&OfflinePageModel::ScanForMissingArchiveFiles, 507 base::Bind(&OfflinePageModel::ScanForMissingArchiveFiles,
508 weak_ptr_factory_.GetWeakPtr())); 508 weak_ptr_factory_.GetWeakPtr()));
509 } 509 }
510 510
511 void OfflinePageModel::ExpirePages(const std::vector<int64_t>& offline_ids,
512 const base::Time& expiration_time) {
513 for (int64_t offline_id : offline_ids) {
514 auto iter = offline_pages_.find(offline_id);
515 if (iter == offline_pages_.end())
516 continue;
517
518 OfflinePageItem offline_page = iter->second;
519 offline_page.expiration_time = expiration_time;
520
521 store_->AddOrUpdateOfflinePage(
522 offline_page, base::Bind(&OfflinePageModel::OnExpirePageDone,
523 weak_ptr_factory_.GetWeakPtr(), offline_id,
bburns 2016/05/23 16:50:16 nit: one parameter per line.
fgorski 2016/05/23 17:50:20 again. this is git cl formatted.
524 expiration_time));
525 }
526 }
527
528 void OfflinePageModel::OnExpirePageDone(int64_t offline_id,
529 const base::Time& expiration_time,
530 bool success) {
531 // TODO(romax): Report UMA about successful expiration.
532 if (success) {
533 auto iter = offline_pages_.find(offline_id);
534 if (iter != offline_pages_.end())
535 iter->second.expiration_time = expiration_time;
536 }
537 }
538
511 ClientPolicyController* OfflinePageModel::GetPolicyController() { 539 ClientPolicyController* OfflinePageModel::GetPolicyController() {
512 return policy_controller_.get(); 540 return policy_controller_.get();
513 } 541 }
514 542
515 OfflinePageMetadataStore* OfflinePageModel::GetStoreForTesting() { 543 OfflinePageMetadataStore* OfflinePageModel::GetStoreForTesting() {
516 return store_.get(); 544 return store_.get();
517 } 545 }
518 546
519 OfflinePageStorageManager* OfflinePageModel::GetStorageManager() { 547 OfflinePageStorageManager* OfflinePageModel::GetStorageManager() {
520 return storage_manager_.get(); 548 return storage_manager_.get();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) { 854 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) {
827 if (!is_loaded_) { 855 if (!is_loaded_) {
828 delayed_tasks_.push_back(task); 856 delayed_tasks_.push_back(task);
829 return; 857 return;
830 } 858 }
831 859
832 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 860 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
833 } 861 }
834 862
835 } // namespace offline_pages 863 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | components/offline_pages/offline_page_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698