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

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: ios fix, and fixed test Created 4 years, 9 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 278
279 std::vector<int64_t> offline_ids; 279 std::vector<int64_t> offline_ids;
280 for (const auto& id_page_pair : offline_pages_) 280 for (const auto& id_page_pair : offline_pages_)
281 offline_ids.push_back(id_page_pair.first); 281 offline_ids.push_back(id_page_pair.first);
282 DeletePagesByOfflineId( 282 DeletePagesByOfflineId(
283 offline_ids, 283 offline_ids,
284 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll, 284 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll,
285 weak_ptr_factory_.GetWeakPtr(), callback)); 285 weak_ptr_factory_.GetWeakPtr(), callback));
286 } 286 }
287 287
288 void OfflinePageModel::ClearWithURLPredicate(
289 const base::Callback<bool(const GURL&)> predicate,
290 const base::Closure& callback) {
291 DCHECK(is_loaded_);
292
293 std::vector<int64_t> offline_ids;
294 for (const auto& id_page_pair : offline_pages_) {
295 if (predicate.Run(GURL(id_page_pair.second.url)))
296 offline_ids.push_back(id_page_pair.first);
297 }
298 DeletePagesByOfflineId(
299 offline_ids,
300 base::Bind(&OfflinePageModel::OnRemoveAllFilesDoneForClearAll,
301 weak_ptr_factory_.GetWeakPtr(), callback));
302 }
303
288 bool OfflinePageModel::HasOfflinePages() const { 304 bool OfflinePageModel::HasOfflinePages() const {
289 // Since offline pages feature is enabled by default, 305 // Since offline pages feature is enabled by default,
290 // NetErrorTabHelper::SetHasOfflinePages might call this before the model is 306 // NetErrorTabHelper::SetHasOfflinePages might call this before the model is
291 // fully loaded. To address this, we need to switch to asynchonous model 307 // fully loaded. To address this, we need to switch to asynchonous model
292 // (crbug.com/589526). But for now, we just bail out to work around the test 308 // (crbug.com/589526). But for now, we just bail out to work around the test
293 // issue. 309 // issue.
294 if (!is_loaded_) 310 if (!is_loaded_)
295 return false; 311 return false;
296 312
297 // Check that at least one page is not marked for deletion. Because we have 313 // Check that at least one page is not marked for deletion. Because we have
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 offline_pages_.clear(); 802 offline_pages_.clear();
787 for (const auto& offline_page : offline_pages) 803 for (const auto& offline_page : offline_pages)
788 offline_pages_[offline_page.offline_id] = offline_page; 804 offline_pages_[offline_page.offline_id] = offline_page;
789 } 805 }
790 806
791 int64_t OfflinePageModel::GenerateOfflineId() { 807 int64_t OfflinePageModel::GenerateOfflineId() {
792 return base::RandGenerator(std::numeric_limits<int64_t>::max()) + 1; 808 return base::RandGenerator(std::numeric_limits<int64_t>::max()) + 1;
793 } 809 }
794 810
795 } // namespace offline_pages 811 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698