Chromium Code Reviews| 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 #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 Loading... | |
| 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, | |
|
romax
2016/05/20 19:05:00
In .h you mentioned to clear files here but seems
fgorski
2016/05/20 20:54:54
Step by step. You'll be adding this code and it ma
| |
| 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/20 18:23:27
personally, I would place one parameter on each li
fgorski
2016/05/20 20:54:54
I am with you, it takes running git cl format once
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |