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

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

Issue 1741123002: Add removal filter support for Cookies, Storage, and Content Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Android 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 std::vector<int64_t> offline_ids; 282 std::vector<int64_t> offline_ids;
283 for (const auto& id_page_pair : offline_pages_) 283 for (const auto& id_page_pair : offline_pages_)
284 offline_ids.push_back(id_page_pair.first); 284 offline_ids.push_back(id_page_pair.first);
285 DeletePagesByOfflineId( 285 DeletePagesByOfflineId(
286 offline_ids, 286 offline_ids,
287 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll, 287 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll,
288 weak_ptr_factory_.GetWeakPtr(), callback)); 288 weak_ptr_factory_.GetWeakPtr(), callback));
289 } 289 }
290 290
291 void OfflinePageModel::DeletePagesByURLPredicate(
292 const base::Callback<bool(const GURL&)>& predicate,
293 const DeletePageCallback& callback) {
294 if (!is_loaded_) {
295 delayed_tasks_.push_back(
296 base::Bind(&OfflinePageModel::DoDeletePagesByURLPredicate,
297 weak_ptr_factory_.GetWeakPtr(), predicate, callback));
298
299 return;
300 }
301 DoDeletePagesByURLPredicate(predicate, callback);
302 }
303
304 void OfflinePageModel::DoDeletePagesByURLPredicate(
305 const base::Callback<bool(const GURL&)>& predicate,
306 const DeletePageCallback& callback) {
307 DCHECK(is_loaded_);
308
309 std::vector<int64_t> offline_ids;
310 for (const auto& id_page_pair : offline_pages_) {
311 if (!id_page_pair.second.IsMarkedForDeletion() &&
312 predicate.Run(id_page_pair.second.url)) {
313 offline_ids.push_back(id_page_pair.first);
314 }
315 }
316 DoDeletePagesByOfflineId(offline_ids, callback);
317 }
318
291 bool OfflinePageModel::HasOfflinePages() const { 319 bool OfflinePageModel::HasOfflinePages() const {
292 // Since offline pages feature is enabled by default, 320 // Since offline pages feature is enabled by default,
293 // NetErrorTabHelper::SetHasOfflinePages might call this before the model is 321 // NetErrorTabHelper::SetHasOfflinePages might call this before the model is
294 // fully loaded. To address this, we need to switch to asynchonous model 322 // fully loaded. To address this, we need to switch to asynchonous model
295 // (crbug.com/589526). But for now, we just bail out to work around the test 323 // (crbug.com/589526). But for now, we just bail out to work around the test
296 // issue. 324 // issue.
297 if (!is_loaded_) 325 if (!is_loaded_)
298 return false; 326 return false;
299 327
300 // Check that at least one page is not marked for deletion. Because we have 328 // Check that at least one page is not marked for deletion. Because we have
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 base::Bind(&OfflinePageModel::MarkPageForDeletion, 816 base::Bind(&OfflinePageModel::MarkPageForDeletion,
789 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback)); 817 weak_ptr_factory_.GetWeakPtr(), offline_ids[i], callback));
790 } 818 }
791 return; 819 return;
792 } 820 }
793 for (const auto& id : offline_ids) { 821 for (const auto& id : offline_ids) {
794 MarkPageForDeletion(id, callback); 822 MarkPageForDeletion(id, callback);
795 } 823 }
796 } 824 }
797 } // namespace offline_pages 825 } // 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