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

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

Issue 1843893002: Support resaving offline page right after it is being deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 years, 8 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (!CanSavePage(url)) { 155 if (!CanSavePage(url)) {
156 InformSavePageDone(callback, SavePageResult::SKIPPED, INVALID_OFFLINE_ID); 156 InformSavePageDone(callback, SavePageResult::SKIPPED, INVALID_OFFLINE_ID);
157 return; 157 return;
158 } 158 }
159 159
160 DCHECK(archiver.get()); 160 DCHECK(archiver.get());
161 161
162 int64_t offline_id = GenerateOfflineId(); 162 int64_t offline_id = GenerateOfflineId();
163 163
164 archiver->CreateArchive( 164 archiver->CreateArchive(
165 archives_dir_, base::Bind(&OfflinePageModel::OnCreateArchiveDone, 165 archives_dir_,
166 weak_ptr_factory_.GetWeakPtr(), url, offline_id, 166 offline_id,
167 client_id, base::Time::Now(), callback)); 167 base::Bind(&OfflinePageModel::OnCreateArchiveDone,
168 weak_ptr_factory_.GetWeakPtr(), url, offline_id,
169 client_id, base::Time::Now(), callback));
168 pending_archivers_.push_back(std::move(archiver)); 170 pending_archivers_.push_back(std::move(archiver));
169 } 171 }
170 172
171 void OfflinePageModel::MarkPageAccessed(int64_t offline_id) { 173 void OfflinePageModel::MarkPageAccessed(int64_t offline_id) {
172 DCHECK(is_loaded_); 174 DCHECK(is_loaded_);
173 auto iter = offline_pages_.find(offline_id); 175 auto iter = offline_pages_.find(offline_id);
174 if (iter == offline_pages_.end()) 176 if (iter == offline_pages_.end())
175 return; 177 return;
176 178
177 // MarkPageAccessed should not be called for a page that is being marked for 179 // MarkPageAccessed should not be called for a page that is being marked for
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 base::Bind(&OfflinePageModel::MarkPageForDeletion, 788 base::Bind(&OfflinePageModel::MarkPageForDeletion,
787 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback)); 789 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback));
788 } 790 }
789 return; 791 return;
790 } 792 }
791 for (const auto& id : offline_ids) { 793 for (const auto& id : offline_ids) {
792 MarkPageForDeletion(id, callback); 794 MarkPageForDeletion(id, callback);
793 } 795 }
794 } 796 }
795 } // namespace offline_pages 797 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_archiver.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